From 267439fc344f22f5d58a9bf2d71ec67f5f5e3310 Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Thu, 23 Feb 2023 01:47:13 -0800 Subject: [PATCH] net: rework autoSelectFamily implementation PR-URL: https://github.com/nodejs/node/pull/46587 Backport-PR-URL: https://github.com/nodejs/node/pull/49183 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- doc/api/net.md | 64 +++++++++----- lib/_tls_wrap.js | 70 +++++++++------ lib/internal/net.js | 2 +- lib/net.js | 87 +++++++++++++------ test/parallel/test-http-autoselectfamily.js | 10 +-- .../test-http2-ping-settings-heapdump.js | 10 ++- test/parallel/test-https-autoselectfamily.js | 12 +-- ...net-autoselectfamily-commandline-option.js | 10 +-- .../test-net-autoselectfamily-ipv4first.js | 10 +-- test/parallel/test-net-autoselectfamily.js | 10 +-- test/parallel/test-net-dns-custom-lookup.js | 19 +++- test/parallel/test-net-dns-lookup.js | 4 +- test/parallel/test-net-options-lookup.js | 6 +- test/parallel/test-net-server-reset.js | 18 ++-- ...-invalid-autoselectfamilyattempttimeout.js | 6 ++ .../test-tls-autoselectfamily-servername.js | 37 ++++++++ 16 files changed, 247 insertions(+), 128 deletions(-) create mode 100644 test/parallel/test-tls-autoselectfamily-servername.js diff --git a/doc/api/net.md b/doc/api/net.md index 91766ad8e0f2d2..eca3c1ffcfec83 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -935,7 +935,7 @@ For TCP connections, available `options` are: * `autoSelectFamilyAttemptTimeout` {number}: The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. If set to a positive integer less than `10`, then the value `10` will be used instead. - **Default:** `250`. + **Default:** initially `250`, but it can be changed at runtime using [`net.setDefaultAutoSelectFamilyAttemptTimeout(value)`][] For [IPC][] connections, available `options` are: @@ -1520,26 +1520,6 @@ immediately initiates connection with [`socket.connect(port[, host][, connectListener])`][`socket.connect(port)`], then returns the `net.Socket` that starts the connection. -## `net.setDefaultAutoSelectFamily(value)` - - - -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])` + +Gets the current default value of the `autoSelectFamily` option of [`socket.connect(options)`][]. + +* Returns: {boolean} The current default value of the `autoSelectFamily` option. + +## `net.setDefaultAutoSelectFamily(value)` + + + +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.getDefaultAutoSelectFamilyAttemptTimeout()` + + + +Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of [`socket.connect(options)`][]. + +* Returns: {number} The current default value of the `autoSelectFamilyAttemptTimeout` option. + +## `net.setDefaultAutoSelectFamilyAttemptTimeout(value)` + + + +Sets the default value of the `autoSelectFamilyAttemptTimeout` option of [`socket.connect(options)`][]. + +* `value` {number} The new default value, which must be a positive number. If the number is less than `10`, + the value `10` is used insted The initial default value is `250`. + ## `net.isIP(input)`