From 866bb051a154a2d3276f8d3b09852c6702577d88 Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Sat, 24 Dec 2022 15:44:11 +0100 Subject: [PATCH] net: add autoSelectFamily global getter and setter PR-URL: https://github.com/nodejs/node/pull/45777 Reviewed-By: Matteo Collina --- doc/api/cli.md | 10 ++ doc/api/net.md | 46 +++++- lib/net.js | 31 +++- src/node_options.cc | 4 + src/node_options.h | 1 + ...balls.js => test-http-autoselectfamily.js} | 0 ...alls.js => test-https-autoselectfamily.js} | 0 ...net-autoselectfamily-commandline-option.js | 108 ++++++++++++++ ...=> test-net-autoselectfamily-ipv4first.js} | 0 ...eballs.js => test-net-autoselectfamily.js} | 15 +- .../test-net-autoselectfamilydefault.js | 140 ++++++++++++++++++ ...socket-connect-invalid-autoselectfamily.js | 9 ++ 12 files changed, 355 insertions(+), 9 deletions(-) rename test/parallel/{test-http-happy-eyeballs.js => test-http-autoselectfamily.js} (100%) rename test/parallel/{test-https-happy-eyeballs.js => test-https-autoselectfamily.js} (100%) create mode 100644 test/parallel/test-net-autoselectfamily-commandline-option.js rename test/parallel/{test-net-happy-eyeballs-ipv4first.js => test-net-autoselectfamily-ipv4first.js} (100%) rename test/parallel/{test-net-happy-eyeballs.js => test-net-autoselectfamily.js} (91%) create mode 100644 test/parallel/test-net-autoselectfamilydefault.js create mode 100644 test/parallel/test-net-socket-connect-invalid-autoselectfamily.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 0a83ab6087c03b..12058a1ccb3de2 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -314,6 +314,15 @@ added: v6.0.0 Enable FIPS-compliant crypto at startup. (Requires Node.js to be built against FIPS-compatible OpenSSL.) +### `--enable-network-family-autoselection` + + + +Enables the family autoselection algorithm unless connection options explicitly +disables it. + ### `--enable-source-maps` + +* {string\[]} + +This property is only present if the family autoselection algorithm is enabled in +[`socket.connect(options)`][] and it is an array of the addresses that have been attempted. + +Each address is a string in the form of `$IP:$PORT`. If the connection was successful, +then the last address is the one that the socket is currently connected to. + ### `socket.bufferSize` + +Sets the default value of the `autoSelectFamily` option of [`socket.connect(options)`][]. + +* `value` {boolean} The new default value. The initial default value is `false`. + +## `net.getDefaultAutoSelectFamily()` + + + +Gets the current default value of the `autoSelectFamily` option of [`socket.connect(options)`][]. + +* Returns: {boolean} The current default value of the `autoSelectFamily` option. + ## `net.createServer([options][, connectionListener])`