From 58f423b36539fec709bf123d51e50afc55c7524a Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Wed, 7 Dec 2022 21:38:24 +0100 Subject: [PATCH] net: add autoSelectFamily global getter and setter --- doc/api/net.md | 44 +++++- lib/net.js | 30 +++- ...balls.js => test-http-autoselectfamily.js} | 0 ...alls.js => test-https-autoselectfamily.js} | 0 ...=> test-net-autoselectfamily-ipv4first.js} | 0 ...eballs.js => test-net-autoselectfamily.js} | 15 +- .../test-net-autoselectfamilydefault.js | 140 ++++++++++++++++++ ...socket-connect-invalid-autoselectfamily.js | 9 ++ 8 files changed, 229 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%) 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/net.md b/doc/api/net.md index c0cb1dbd7341c5..e27c8fcddfc966 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -780,6 +780,20 @@ Returns the bound `address`, the address `family` name and `port` of the socket as reported by the operating system: `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }` +### `socket.autoSelectFamilyAttemptedAddresses` + + + +* {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])`