From 62266dbdfea6c8ca7414f3de8794cb07a70827fd 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 83c76711d01ffc..a60ef3929c6feb 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])`