From 5bef0de4bfc7cebaf985d05d72e2c65095b5f97d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis <info@bnoordhuis.nl> Date: Wed, 29 Jan 2020 13:12:15 +0100 Subject: [PATCH 01/27] dns: default to verbatim=true in dns.lookup() Switch the default from false (reorder the result so that IPv4 addresses come before IPv6 addresses) to true (return them exactly as the resolver sent them to us.) Fixes: https://github.com/nodejs/node/issues/31566 Refs: https://github.com/nodejs/node/issues/6307 Refs: https://github.com/nodejs/node/pull/20710 Reissue of https://github.com/nodejs/node/pull/31567 --- doc/api/dns.md | 7 ++++--- lib/dns.js | 4 ++-- lib/internal/dns/promises.js | 4 ++-- test/sequential/test-net-better-error-messages-port.js | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/api/dns.md b/doc/api/dns.md index cdb948309f173f..868a5039bf237e 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -163,6 +163,9 @@ section if a custom port is used. <!-- YAML added: v0.1.90 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/37681 + description: The `verbatim` options defaults to `true` now. - version: v8.5.0 pr-url: https://github.com/nodejs/node/pull/14731 description: The `verbatim` option is supported now. @@ -183,9 +186,7 @@ changes: * `verbatim` {boolean} When `true`, the callback receives IPv4 and IPv6 addresses in the order the DNS resolver returned them. When `false`, IPv4 addresses are placed before IPv6 addresses. - **Default:** currently `false` (addresses are reordered) but this is - expected to change in the not too distant future. - New code should use `{ verbatim: true }`. + **Default:** `true`. * `callback` {Function} * `err` {Error} * `address` {string} A string representation of an IPv4 or IPv6 address. diff --git a/lib/dns.js b/lib/dns.js index b75ca1ca7da082..6d631bd2600571 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -96,7 +96,7 @@ function lookup(hostname, options, callback) { let hints = 0; let family = -1; let all = false; - let verbatim = false; + let verbatim = true; // Parse arguments if (hostname) { @@ -113,7 +113,7 @@ function lookup(hostname, options, callback) { hints = options.hints >>> 0; family = options.family >>> 0; all = options.all === true; - verbatim = options.verbatim === true; + verbatim = options.verbatim !== false; validateHints(hints); } else { diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index e0158eef81307e..6e08ff343180d8 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -103,7 +103,7 @@ function lookup(hostname, options) { var hints = 0; var family = -1; var all = false; - var verbatim = false; + var verbatim = true; // Parse arguments if (hostname && typeof hostname !== 'string') { @@ -112,7 +112,7 @@ function lookup(hostname, options) { hints = options.hints >>> 0; family = options.family >>> 0; all = options.all === true; - verbatim = options.verbatim === true; + verbatim = options.verbatim !== false; validateHints(hints); } else { diff --git a/test/sequential/test-net-better-error-messages-port.js b/test/sequential/test-net-better-error-messages-port.js index 789b2e31801da1..e8756838063e72 100644 --- a/test/sequential/test-net-better-error-messages-port.js +++ b/test/sequential/test-net-better-error-messages-port.js @@ -10,5 +10,5 @@ c.on('connect', common.mustNotCall()); c.on('error', common.mustCall(function(e) { assert.strictEqual(e.code, 'ECONNREFUSED'); assert.strictEqual(e.port, common.PORT); - assert.strictEqual(e.address, '127.0.0.1'); + assert.match(e.address, '/^127\.0\.0\.1$|^::1$/'); })); From 4be87a0294d6e0b59948ed491b188ee39e41d7bb Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 10 Mar 2021 11:04:53 +0100 Subject: [PATCH 02/27] Fixes for IPv6 compatibility; new const 'common.localhostIP' --- test/addons/openssl-client-cert-engine/test.js | 4 ++-- test/addons/openssl-key-engine/test.js | 4 ++-- test/async-hooks/test-getnameinforeqwrap.js | 2 +- test/async-hooks/test-httpparser-reuse.js | 2 +- test/common/index.js | 4 ++++ test/common/inspector-helper.js | 5 +++-- test/known_issues/test-inspector-cluster-port-clash.js | 2 +- test/parallel/test-child-process-send-keep-open.js | 2 +- test/parallel/test-cluster-message.js | 2 +- test/parallel/test-cluster-worker-wait-server-close.js | 4 ++-- .../parallel/test-http-client-reject-unexpected-agent.js | 2 +- .../test-http-client-timeout-option-listeners.js | 2 +- test/parallel/test-http-flush-response-headers.js | 4 ++-- test/parallel/test-http-localaddress.js | 6 +++--- test/parallel/test-http-request-dont-override-options.js | 4 ++-- test/parallel/test-http-same-map.js | 2 +- test/parallel/test-http-upgrade-client.js | 2 +- test/parallel/test-http2-connect-options.js | 6 +++--- test/parallel/test-https-client-get-url.js | 3 ++- test/parallel/test-https-localaddress.js | 6 +++--- .../parallel/test-inspect-async-hook-setup-at-inspect.js | 2 +- test/parallel/test-inspect-publish-uid.js | 2 +- test/parallel/test-inspector-esm.js | 2 +- test/parallel/test-inspector-inspect-brk-node.js | 3 ++- test/parallel/test-inspector-wait-for-connection.js | 2 +- test/parallel/test-inspector-waiting-for-disconnect.js | 3 ++- test/parallel/test-net-client-bind-twice.js | 8 ++++---- test/parallel/test-net-dns-lookup.js | 6 +++--- test/parallel/test-net-local-address-port.js | 6 +++--- test/parallel/test-net-remote-address-port.js | 1 + test/parallel/test-net-socket-local-address.js | 4 ++-- test/parallel/test-repl-require.js | 4 ++-- test/parallel/test-tcp-wrap-connect.js | 6 ++++-- test/parallel/test-tcp-wrap-listen.js | 2 +- ...rs-socket-timeout-removes-other-socket-unref-timer.js | 2 +- test/parallel/test-tls-alpn-server-client.js | 2 +- test/parallel/test-tls-client-getephemeralkeyinfo.js | 2 +- test/parallel/test-tls-client-mindhsize.js | 2 +- test/parallel/test-tls-getprotocol.js | 4 ++-- test/parallel/test-tls-multiple-cas-as-string.js | 2 +- test/parallel/test-tls-wrap-econnreset-localaddress.js | 7 ++++--- test/parallel/test-tls-wrap-econnreset.js | 4 ++-- test/sequential/test-child-process-pass-fd.js | 4 ++-- test/sequential/test-cluster-inspect-brk.js | 4 ++-- test/sequential/test-dgram-bind-shared-ports.js | 9 +++++---- test/sequential/test-http-max-sockets.js | 7 ++++--- test/sequential/test-https-connect-localport.js | 4 ++-- test/sequential/test-inspector-break-when-eval.js | 3 ++- test/sequential/test-inspector-console.js | 2 +- test/sequential/test-inspector-debug-brk-flag.js | 3 ++- test/sequential/test-inspector-debug-end.js | 4 ++-- test/sequential/test-inspector-not-blocked-on-idle.js | 2 +- test/sequential/test-inspector-open.js | 4 ++-- test/sequential/test-inspector-port-zero.js | 4 ++++ test/sequential/test-inspector-scriptparsed-context.js | 3 ++- .../sequential/test-inspector-stop-profile-after-done.js | 2 +- test/sequential/test-net-GH-5504.js | 4 ++-- test/sequential/test-net-better-error-messages-port.js | 2 +- test/sequential/test-net-connect-local-error.js | 4 +++- test/sequential/test-net-localport.js | 2 +- test/sequential/test-net-response-size.js | 4 ++-- 61 files changed, 119 insertions(+), 96 deletions(-) diff --git a/test/addons/openssl-client-cert-engine/test.js b/test/addons/openssl-client-cert-engine/test.js index e843e4bf433bff..9dd14cc9706983 100644 --- a/test/addons/openssl-client-cert-engine/test.js +++ b/test/addons/openssl-client-cert-engine/test.js @@ -32,10 +32,10 @@ const serverOptions = { const server = https.createServer(serverOptions, common.mustCall((req, res) => { res.writeHead(200); res.end('hello world'); -})).listen(0, common.localhostIPv4, common.mustCall(() => { +})).listen(0, common.localhostIP, common.mustCall(() => { const clientOptions = { method: 'GET', - host: common.localhostIPv4, + host: common.localhostIP, port: server.address().port, path: '/test', clientCertEngine: engine, // `engine` will provide key+cert diff --git a/test/addons/openssl-key-engine/test.js b/test/addons/openssl-key-engine/test.js index 2cd7ddabc17095..b525e45c0b8e03 100644 --- a/test/addons/openssl-key-engine/test.js +++ b/test/addons/openssl-key-engine/test.js @@ -32,10 +32,10 @@ const serverOptions = { const server = https.createServer(serverOptions, common.mustCall((req, res) => { res.writeHead(200); res.end('hello world'); -})).listen(0, common.localhostIPv4, common.mustCall(() => { +})).listen(0, common.localhostIP, common.mustCall(() => { const clientOptions = { method: 'GET', - host: common.localhostIPv4, + host: common.localhostIP, port: server.address().port, path: '/test', privateKeyEngine: engine, diff --git a/test/async-hooks/test-getnameinforeqwrap.js b/test/async-hooks/test-getnameinforeqwrap.js index c7a3937ff3ceef..d5027ab447c400 100644 --- a/test/async-hooks/test-getnameinforeqwrap.js +++ b/test/async-hooks/test-getnameinforeqwrap.js @@ -13,7 +13,7 @@ if (!common.isMainThread) const hooks = initHooks(); hooks.enable(); -dns.lookupService('127.0.0.1', 80, common.mustCall(onlookupService)); +dns.lookupService(common.localhostIP, 80, common.mustCall(onlookupService)); function onlookupService() { // We don't care about the error here in order to allow // tests to run offline (lookup will fail in that case and the err be set) diff --git a/test/async-hooks/test-httpparser-reuse.js b/test/async-hooks/test-httpparser-reuse.js index 70248970df364c..9ece674e04f29b 100644 --- a/test/async-hooks/test-httpparser-reuse.js +++ b/test/async-hooks/test-httpparser-reuse.js @@ -49,7 +49,7 @@ const server = http.createServer((req, res) => { server.listen(0, common.mustCall(() => { const PORT = server.address().port; - const url = `http://127.0.0.1:${PORT}`; + const url = `http://localhost:${PORT}`; http.get(url, common.mustCall(() => { server.close(common.mustCall(() => { server.listen(PORT, common.mustCall(() => { diff --git a/test/common/index.js b/test/common/index.js index b70972b1a54d26..2655a48ee8eb96 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -823,6 +823,10 @@ const common = { return localhostIPv4; }, + get localhostIP() { + return this.hasIPv6 ? '::1' : this.localhostIPv4; + }, + // opensslCli defined lazily to reduce overhead of spawnSync get opensslCli() { if (opensslCli !== null) return opensslCli; diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index 666624490e79a9..e9f7028f65c49d 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -326,7 +326,8 @@ class InspectorSession { } class NodeInstance extends EventEmitter { - constructor(inspectorFlags = ['--inspect-brk=0', '--expose-internals'], + constructor(inspectorFlags = ['--inspect-brk=localhost:0', + '--expose-internals'], scriptContents = '', scriptFile = _MAINSCRIPT) { super(); @@ -363,7 +364,7 @@ class NodeInstance extends EventEmitter { static async startViaSignal(scriptContents) { const instance = new NodeInstance( - ['--expose-internals'], + ['--inspect=localhost', '--expose-internals'], `${scriptContents}\nprocess._rawDebug('started');`, undefined); const msg = 'Timed out waiting for process to start'; while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== diff --git a/test/known_issues/test-inspector-cluster-port-clash.js b/test/known_issues/test-inspector-cluster-port-clash.js index e5daee61b78ff6..986e56986a56a2 100644 --- a/test/known_issues/test-inspector-cluster-port-clash.js +++ b/test/known_issues/test-inspector-cluster-port-clash.js @@ -52,7 +52,7 @@ if (cluster.isPrimary) { // Block one of the ports with a listening socket. const server = net.createServer(); - server.listen(clashPort, common.localhostIPv4, common.mustCall(() => { + server.listen(clashPort, common.localhostIP, common.mustCall(() => { // Try to fork 3 workers. No.2 should fail. Promise.all([serialFork(), serialFork(), serialFork()]) .then(common.mustNotCall()) diff --git a/test/parallel/test-child-process-send-keep-open.js b/test/parallel/test-child-process-send-keep-open.js index 54169dc1885f66..dd9db7bef13c8e 100644 --- a/test/parallel/test-child-process-send-keep-open.js +++ b/test/parallel/test-child-process-send-keep-open.js @@ -36,7 +36,7 @@ if (process.argv[2] !== 'child') { }); server.listen(0, () => { - const socket = net.connect(server.address().port, common.localhostIPv4); + const socket = net.connect(server.address().port, common.localhostIP); socket.setEncoding('utf8'); socket.on('data', (data) => result += data); }); diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js index 45854c77a5a347..33b8457f016e8e 100644 --- a/test/parallel/test-cluster-message.js +++ b/test/parallel/test-cluster-message.js @@ -60,7 +60,7 @@ if (cluster.isWorker) { maybeReply(); }); - server.listen(0, '127.0.0.1'); + server.listen(0, 'localhost'); } else if (cluster.isPrimary) { const checks = { diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index 71a8cacb5260a3..98b72aa46baa86 100644 --- a/test/parallel/test-cluster-worker-wait-server-close.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -12,7 +12,7 @@ if (cluster.isWorker) { // Wait for any data, then close connection socket.write('.'); socket.on('data', () => {}); - }).listen(0, common.localhostIPv4); + }).listen(0, common.localhostIP); server.once('close', function() { serverClosed = true; @@ -34,7 +34,7 @@ if (cluster.isWorker) { // Disconnect worker when it is ready worker.once('listening', function(address) { - const socket = net.createConnection(address.port, common.localhostIPv4); + const socket = net.createConnection(address.port, common.localhostIP); socket.on('connect', function() { socket.on('data', function() { diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js index 8ec6506888bb05..784f00eac160b1 100644 --- a/test/parallel/test-http-client-reject-unexpected-agent.js +++ b/test/parallel/test-http-client-reject-unexpected-agent.js @@ -6,7 +6,7 @@ const http = require('http'); const baseOptions = { method: 'GET', port: undefined, - host: common.localhostIPv4, + host: common.localhostIP, }; const failingAgentOptions = [ diff --git a/test/parallel/test-http-client-timeout-option-listeners.js b/test/parallel/test-http-client-timeout-option-listeners.js index 1122eaf79e46f8..98a4d94fba6dce 100644 --- a/test/parallel/test-http-client-timeout-option-listeners.js +++ b/test/parallel/test-http-client-timeout-option-listeners.js @@ -16,7 +16,7 @@ const options = { agent, method: 'GET', port: undefined, - host: common.localhostIPv4, + host: common.localhostIP, path: '/', timeout: timeout }; diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js index 0f0a1387b56733..5e71dfaf47faab 100644 --- a/test/parallel/test-http-flush-response-headers.js +++ b/test/parallel/test-http-flush-response-headers.js @@ -10,10 +10,10 @@ server.on('request', function(req, res) { res.flushHeaders(); res.flushHeaders(); // Should be idempotent. }); -server.listen(0, common.localhostIPv4, function() { +server.listen(0, common.localhostIP, function() { const req = http.request({ method: 'GET', - host: common.localhostIPv4, + host: common.localhostIP, port: this.address().port, }, onResponse); diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index e237c3bff1ac84..76a154c238adae 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -30,7 +30,7 @@ const assert = require('assert'); const server = http.createServer((req, res) => { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); + assert.match(req.connection.remoteAddress, /^(127\.0\.0\.2|::1)$/); req.on('end', () => { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -39,12 +39,12 @@ const server = http.createServer((req, res) => { req.resume(); }); -server.listen(0, '127.0.0.1', () => { +server.listen(0, 'localhost', () => { const options = { host: 'localhost', port: server.address().port, path: '/', method: 'GET', - localAddress: '127.0.0.2' }; + localAddress: common.hasIPv6 ? '::1' : '127.0.0.2' }; const req = http.request(options, function(res) { res.on('end', () => { diff --git a/test/parallel/test-http-request-dont-override-options.js b/test/parallel/test-http-request-dont-override-options.js index 19b847dc0390f5..c1d14f20c5cf77 100644 --- a/test/parallel/test-http-request-dont-override-options.js +++ b/test/parallel/test-http-request-dont-override-options.js @@ -19,7 +19,7 @@ server.listen(0, function() { // be mutable / modified const options = { host: undefined, - hostname: common.localhostIPv4, + hostname: common.localhostIP, port: undefined, defaultPort: undefined, path: undefined, @@ -31,7 +31,7 @@ server.listen(0, function() { res.resume(); server.close(); assert.strictEqual(options.host, undefined); - assert.strictEqual(options.hostname, common.localhostIPv4); + assert.strictEqual(options.hostname, common.localhostIP); assert.strictEqual(options.port, undefined); assert.strictEqual(options.defaultPort, undefined); assert.strictEqual(options.path, undefined); diff --git a/test/parallel/test-http-same-map.js b/test/parallel/test-http-same-map.js index 3d8d325ad7b0d1..ab595437b08839 100644 --- a/test/parallel/test-http-same-map.js +++ b/test/parallel/test-http-same-map.js @@ -6,7 +6,7 @@ const assert = require('assert'); const http = require('http'); const server = - http.createServer(onrequest).listen(0, common.localhostIPv4, () => next(0)); + http.createServer(onrequest).listen(0, common.localhostIP, () => next(0)); function onrequest(req, res) { res.end('ok'); diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js index 8fe756f469f09a..a206e46af569e2 100644 --- a/test/parallel/test-http-upgrade-client.js +++ b/test/parallel/test-http-upgrade-client.js @@ -49,7 +49,7 @@ const server = net.createServer(function(c) { }); }); -server.listen(0, '127.0.0.1', common.mustCall(function() { +server.listen(0, 'localhost', common.mustCall(function() { const port = this.address().port; const headers = [ { diff --git a/test/parallel/test-http2-connect-options.js b/test/parallel/test-http2-connect-options.js index 0c7ec807b84d38..bc5304c2437ade 100644 --- a/test/parallel/test-http2-connect-options.js +++ b/test/parallel/test-http2-connect-options.js @@ -12,7 +12,7 @@ const assert = require('assert'); const server = http2.createServer((req, res) => { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); + assert.match(req.connection.remoteAddress, /^(127\.0\.0\.2|::1)$/); req.on('end', common.mustCall(() => { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -21,8 +21,8 @@ const server = http2.createServer((req, res) => { req.resume(); }); -server.listen(0, '127.0.0.1', common.mustCall(() => { - const options = { localAddress: '127.0.0.2' }; +server.listen(0, 'localhost', common.mustCall(() => { + const options = { localAddress: common.hasIPv6 ? '::1' : '127.0.0.2' }; const client = http2.connect( 'http://localhost:' + server.address().port, diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js index fb91a4f1e7cb8a..e30d77725e54cc 100644 --- a/test/parallel/test-https-client-get-url.js +++ b/test/parallel/test-https-client-get-url.js @@ -46,7 +46,8 @@ const server = https.createServer(options, common.mustCall((req, res) => { }, 3)); server.listen(0, common.mustCall(() => { - const u = `https://${common.localhostIPv4}:${server.address().port}/foo?bar`; + const localhost = common.hasIPv6 ? '[::1]' : common.localhostIPv4; + const u = `https://${localhost}:${server.address().port}/foo?bar`; https.get(u, common.mustCall(() => { https.get(url.parse(u), common.mustCall(() => { https.get(new URL(u), common.mustCall(() => { diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index 0ac8414b2d4b35..880cdba5eee695 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -39,7 +39,7 @@ const options = { const server = https.createServer(options, function(req, res) { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); + assert.match(req.connection.remoteAddress, /^(127\.0\.0\.2|::1)$/); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -48,13 +48,13 @@ const server = https.createServer(options, function(req, res) { req.resume(); }); -server.listen(0, '127.0.0.1', function() { +server.listen(0, 'localhost', function() { const options = { host: 'localhost', port: this.address().port, path: '/', method: 'GET', - localAddress: '127.0.0.2', + localAddress: common.hasIPv6 ? '::1' : '127.0.0.2', rejectUnauthorized: false }; diff --git a/test/parallel/test-inspect-async-hook-setup-at-inspect.js b/test/parallel/test-inspect-async-hook-setup-at-inspect.js index b68617b5d52276..971485cfc8f61f 100644 --- a/test/parallel/test-inspect-async-hook-setup-at-inspect.js +++ b/test/parallel/test-inspect-async-hook-setup-at-inspect.js @@ -45,7 +45,7 @@ async function checkAsyncStackTrace(session) { } async function runTests() { - const instance = new NodeInstance(['--inspect=0'], script); + const instance = new NodeInstance(['--inspect=localhost:0'], script); const session = await instance.connectInspectorSession(); await session.send([ { 'method': 'Runtime.enable' }, diff --git a/test/parallel/test-inspect-publish-uid.js b/test/parallel/test-inspect-publish-uid.js index 2479a37a2d6901..745913c10f1ed1 100644 --- a/test/parallel/test-inspect-publish-uid.js +++ b/test/parallel/test-inspect-publish-uid.js @@ -18,7 +18,7 @@ async function testArg(argValue) { const hasStderr = argValue.split(',').includes('stderr'); const nodeProcess = spawnSync(process.execPath, [ - '--inspect=0', + '--inspect=localhost:0', `--inspect-publish-uid=${argValue}`, '-e', `(${scriptMain.toString()})(${hasHttp ? 200 : 404})` ]); diff --git a/test/parallel/test-inspector-esm.js b/test/parallel/test-inspector-esm.js index da3bd17e33f4bc..b8f32e7fd319f0 100644 --- a/test/parallel/test-inspector-esm.js +++ b/test/parallel/test-inspector-esm.js @@ -98,7 +98,7 @@ async function testBreakpoint(session) { } async function runTest() { - const child = new NodeInstance(['--inspect-brk=0'], '', + const child = new NodeInstance(['--inspect-brk=localhost:0'], '', fixtures.path('es-modules/loop.mjs')); const session = await child.connectInspectorSession(); diff --git a/test/parallel/test-inspector-inspect-brk-node.js b/test/parallel/test-inspector-inspect-brk-node.js index 0f4795ed7b87e4..f6baf5f0e3b8b2 100644 --- a/test/parallel/test-inspector-inspect-brk-node.js +++ b/test/parallel/test-inspector-inspect-brk-node.js @@ -8,7 +8,8 @@ common.skipIfInspectorDisabled(); const { NodeInstance } = require('../common/inspector-helper.js'); async function runTest() { - const child = new NodeInstance(['--inspect-brk-node=0', '-p', '42']); + const child = new NodeInstance(['--inspect-brk-node=localhost:0', + '-p', '42']); const session = await child.connectInspectorSession(); await session.send({ method: 'Runtime.enable' }); await session.send({ method: 'Debugger.enable' }); diff --git a/test/parallel/test-inspector-wait-for-connection.js b/test/parallel/test-inspector-wait-for-connection.js index 0f562faede1e55..3b45c339f95b44 100644 --- a/test/parallel/test-inspector-wait-for-connection.js +++ b/test/parallel/test-inspector-wait-for-connection.js @@ -42,7 +42,7 @@ async function runTests() { function main(prefix) { const inspector = require('inspector'); - inspector.open(0, undefined, false); + inspector.open(0, 'localhost', false); process._ws = inspector.url(); console.log('before wait for debugger'); inspector.waitForDebugger(); diff --git a/test/parallel/test-inspector-waiting-for-disconnect.js b/test/parallel/test-inspector-waiting-for-disconnect.js index e9d39978d7aaf0..40ca75033ed56b 100644 --- a/test/parallel/test-inspector-waiting-for-disconnect.js +++ b/test/parallel/test-inspector-waiting-for-disconnect.js @@ -12,7 +12,8 @@ function mainContextDestroyed(notification) { } async function runTest() { - const child = new NodeInstance(['--inspect-brk=0', '-e', 'process.exit(55)']); + const child = new NodeInstance(['--inspect-brk=localhost:0', '-e', + 'process.exit(55)']); const session = await child.connectInspectorSession(); const oldStyleSession = await child.connectInspectorSession(); await oldStyleSession.send([ diff --git a/test/parallel/test-net-client-bind-twice.js b/test/parallel/test-net-client-bind-twice.js index ca7eb502d85ba5..97d1921b1f4493 100644 --- a/test/parallel/test-net-client-bind-twice.js +++ b/test/parallel/test-net-client-bind-twice.js @@ -7,13 +7,13 @@ const assert = require('assert'); const net = require('net'); const server1 = net.createServer(common.mustNotCall()); -server1.listen(0, common.localhostIPv4, common.mustCall(() => { +server1.listen(0, common.localhostIP, common.mustCall(() => { const server2 = net.createServer(common.mustNotCall()); - server2.listen(0, common.localhostIPv4, common.mustCall(() => { + server2.listen(0, common.localhostIP, common.mustCall(() => { const client = net.connect({ - host: common.localhostIPv4, + host: common.localhostIP, port: server1.address().port, - localAddress: common.localhostIPv4, + localAddress: common.localhostIP, localPort: server2.address().port }, common.mustNotCall()); diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 53052de716ee9e..4ae31412855365 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -29,12 +29,12 @@ const server = net.createServer(function(client) { server.close(); }); -server.listen(0, '127.0.0.1', common.mustCall(function() { +server.listen(0, common.localhostIP, common.mustCall(function() { net.connect(this.address().port, 'localhost') .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); - assert.strictEqual(ip, '127.0.0.1'); - assert.strictEqual(type, 4); + assert.strictEqual(ip, common.hasIPv6 ? '::1' : '127.0.0.1'); + assert.strictEqual(type, common.hasIPv6 ? 6 : 4); assert.strictEqual(host, 'localhost'); })); })); diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js index dfd7ef359b71d2..0bf003ffe76160 100644 --- a/test/parallel/test-net-local-address-port.js +++ b/test/parallel/test-net-local-address-port.js @@ -25,7 +25,7 @@ const assert = require('assert'); const net = require('net'); const server = net.createServer(common.mustCall(function(socket) { - assert.strictEqual(socket.localAddress, common.localhostIPv4); + assert.strictEqual(socket.localAddress, common.localhostIP); assert.strictEqual(socket.localPort, this.address().port); socket.on('end', function() { server.close(); @@ -33,9 +33,9 @@ const server = net.createServer(common.mustCall(function(socket) { socket.resume(); })); -server.listen(0, common.localhostIPv4, function() { +server.listen(0, common.localhostIP, function() { const client = net.createConnection(this.address() - .port, common.localhostIPv4); + .port, common.localhostIP); client.on('connect', function() { client.end(); }); diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 094206f85df34d..001566de557589 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -29,6 +29,7 @@ let conns_closed = 0; const remoteAddrCandidates = [ common.localhostIPv4 ]; if (common.hasIPv6) remoteAddrCandidates.push('::ffff:127.0.0.1'); +if (common.hasIPv6) remoteAddrCandidates.push('::1'); const remoteFamilyCandidates = ['IPv4']; if (common.hasIPv6) remoteFamilyCandidates.push('IPv6'); diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 58645322f45100..a6217f60c2e7cd 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -22,7 +22,7 @@ server.on('close', common.mustCall(() => { assert.strictEqual(conns, 2); })); -server.listen(0, common.localhostIPv4, connect); +server.listen(0, common.localhostIP, connect); function connect() { if (conns === 2) { @@ -34,7 +34,7 @@ function connect() { client.once('close', connect); assert.strictEqual( client, - client.connect(server.address().port, common.localhostIPv4, () => { + client.connect(server.address().port, common.localhostIP, () => { clientLocalPorts.push(client.localPort); }) ); diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index 391b629b1b3a3b..d729e170b3d927 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -19,7 +19,7 @@ const repl = require('repl'); }); }); - const host = common.localhostIPv4; + const host = common.localhostIP; const port = 0; const options = { host, port }; @@ -49,7 +49,7 @@ const repl = require('repl'); }); }); - const host = common.localhostIPv4; + const host = common.localhostIP; const port = 0; const options = { host, port }; diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js index 5e3e81f6e11712..1defff923ee67f 100644 --- a/test/parallel/test-tcp-wrap-connect.js +++ b/test/parallel/test-tcp-wrap-connect.js @@ -1,6 +1,6 @@ // Flags: --expose-internals 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); const { @@ -14,7 +14,9 @@ function makeConnection() { const client = new TCP(TCPConstants.SOCKET); const req = new TCPConnectWrap(); - const err = client.connect(req, '127.0.0.1', this.address().port); + const err = common.hasIPv6 ? + client.connect6(req, '::1', this.address().port) : + client.connect(req, '127.0.0.1', this.address().port); assert.strictEqual(err, 0); req.oncomplete = function(status, client_, req_, readable, writable) { diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index 72981b683ccea3..f49693b4918c01 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -14,7 +14,7 @@ const { const server = new TCP(TCPConstants.SOCKET); -const r = server.bind('0.0.0.0', 0); +const r = common.hasIPv6 ? server.bind6('::', 0) : server.bind('0.0.0.0', 0); assert.strictEqual(r, 0); let port = {}; server.getsockname(port); diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js index ccecfe4c63a6a1..242bf33a2b0c17 100644 --- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -28,7 +28,7 @@ const server = net.createServer(function onClient(client) { } }); -server.listen(0, common.localhostIPv4, common.mustCall(() => { +server.listen(0, 'localhost', common.mustCall(() => { const countdown = new Countdown(2, () => server.close()); { diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js index 3da24c67fbe522..8204fb459843bf 100644 --- a/test/parallel/test-tls-alpn-server-client.js +++ b/test/parallel/test-tls-alpn-server-client.js @@ -12,7 +12,7 @@ function loadPEM(n) { return fixtures.readKey(`${n}.pem`); } -const serverIP = common.localhostIPv4; +const serverIP = common.localhostIP; function checkResults(result, expected) { assert.strictEqual(result.server.ALPN, expected.server.ALPN); diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js index 73ac215102ddbb..51831bd18f5007 100644 --- a/test/parallel/test-tls-client-getephemeralkeyinfo.js +++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js @@ -37,7 +37,7 @@ function test(size, type, name, cipher) { server.on('close', common.mustSucceed()); - server.listen(0, '127.0.0.1', common.mustCall(() => { + server.listen(0, 'localhost', common.mustCall(() => { const client = tls.connect({ port: server.address().port, rejectUnauthorized: false diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index a6fbc67bd88361..484ef913bc361a 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -34,7 +34,7 @@ function test(size, err, next) { if (next) next(); }); - server.listen(0, '127.0.0.1', function() { + server.listen(0, 'localhost', function() { // Client set minimum DH parameter size to 2048 bits so that // it fails when it make a connection to the tls server where // dhparams is 1024 bits diff --git a/test/parallel/test-tls-getprotocol.js b/test/parallel/test-tls-getprotocol.js index a76ff0f3442a97..fa834cd4eddadc 100644 --- a/test/parallel/test-tls-getprotocol.js +++ b/test/parallel/test-tls-getprotocol.js @@ -24,11 +24,11 @@ const serverConfig = { const server = tls.createServer(serverConfig, common.mustCall(function() { -}, clientConfigs.length)).listen(0, common.localhostIPv4, function() { +}, clientConfigs.length)).listen(0, common.localhostIP, function() { let connected = 0; clientConfigs.forEach(function(v) { tls.connect({ - host: common.localhostIPv4, + host: common.localhostIP, port: server.address().port, rejectUnauthorized: false, secureProtocol: v.secureProtocol diff --git a/test/parallel/test-tls-multiple-cas-as-string.js b/test/parallel/test-tls-multiple-cas-as-string.js index 679d6b6c4cdc42..40f86e001e112d 100644 --- a/test/parallel/test-tls-multiple-cas-as-string.js +++ b/test/parallel/test-tls-multiple-cas-as-string.js @@ -20,7 +20,7 @@ function test(ca) { server.addContext('agent3', { ca, cert, key }); - const host = common.localhostIPv4; + const host = common.localhostIP; server.listen(0, host, common.mustCall(() => { const socket = tls.connect({ servername: 'agent3', diff --git a/test/parallel/test-tls-wrap-econnreset-localaddress.js b/test/parallel/test-tls-wrap-econnreset-localaddress.js index 30d3a8873fa8f0..7150abe2d72bfd 100644 --- a/test/parallel/test-tls-wrap-econnreset-localaddress.js +++ b/test/parallel/test-tls-wrap-econnreset-localaddress.js @@ -16,14 +16,15 @@ const server = net.createServer((c) => { let errored = false; tls.connect({ port: port, - localAddress: common.localhostIPv4 - }, common.localhostIPv4) + localAddress: common.localhostIP, + family: common.hasIPv6 ? 6 : 4, + }, common.localhostIP) .once('error', common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNRESET'); assert.strictEqual(e.path, undefined); assert.strictEqual(e.host, undefined); assert.strictEqual(e.port, port); - assert.strictEqual(e.localAddress, common.localhostIPv4); + assert.match(e.localAddress, /^(127\.0\.0\.1|::1)$/); server.close(); errored = true; })) diff --git a/test/parallel/test-tls-wrap-econnreset.js b/test/parallel/test-tls-wrap-econnreset.js index 6ed268e766f704..b321909a507114 100644 --- a/test/parallel/test-tls-wrap-econnreset.js +++ b/test/parallel/test-tls-wrap-econnreset.js @@ -14,11 +14,11 @@ const server = net.createServer((c) => { const port = server.address().port; let errored = false; - tls.connect(port, common.localhostIPv4) + tls.connect(port, common.localhostIP) .once('error', common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNRESET'); assert.strictEqual(e.path, undefined); - assert.strictEqual(e.host, common.localhostIPv4); + assert.strictEqual(e.host, common.localhostIP); assert.strictEqual(e.port, port); assert.strictEqual(e.localAddress, undefined); server.close(); diff --git a/test/sequential/test-child-process-pass-fd.js b/test/sequential/test-child-process-pass-fd.js index 98832c57a3df67..47b1a614e5666d 100644 --- a/test/sequential/test-child-process-pass-fd.js +++ b/test/sequential/test-child-process-pass-fd.js @@ -77,8 +77,8 @@ if (process.argv[2] !== 'child') { }); socketConnected(); }).unref(); - server.listen(0, common.localhostIPv4, () => { + server.listen(0, common.localhostIP, () => { const { port } = server.address(); - socket = net.connect(port, common.localhostIPv4, socketConnected).unref(); + socket = net.connect(port, common.localhostIP, socketConnected).unref(); }); } diff --git a/test/sequential/test-cluster-inspect-brk.js b/test/sequential/test-cluster-inspect-brk.js index fbae27f9ba4eb4..93a7050de73d27 100644 --- a/test/sequential/test-cluster-inspect-brk.js +++ b/test/sequential/test-cluster-inspect-brk.js @@ -29,8 +29,8 @@ if (cluster.isPrimary) { })); } - test(['--inspect-brk']); - test([`--inspect-brk=${debuggerPort}`]); + test(['--inspect-brk=localhost']); + test([`--inspect-brk=localhost:${debuggerPort}`]); } else { // Cluster worker is at a breakpoint, should not reach here. assert.fail('Test failed: cluster worker should be at a breakpoint.'); diff --git a/test/sequential/test-dgram-bind-shared-ports.js b/test/sequential/test-dgram-bind-shared-ports.js index c68cfac969dedf..f83eed49122be5 100644 --- a/test/sequential/test-dgram-bind-shared-ports.js +++ b/test/sequential/test-dgram-bind-shared-ports.js @@ -73,9 +73,10 @@ if (cluster.isPrimary) { }), 1); const isSecondWorker = process.env.WORKER2_NAME === WORKER2_NAME; - const socket1 = dgram.createSocket('udp4', common.mustNotCall()); - const socket2 = dgram.createSocket('udp4', common.mustNotCall()); - const socket3 = dgram.createSocket('udp4', common.mustNotCall()); + const type = common.hasIPv6 ? 'udp6' : 'udp4'; + const socket1 = dgram.createSocket(type, common.mustNotCall()); + const socket2 = dgram.createSocket(type, common.mustNotCall()); + const socket3 = dgram.createSocket(type, common.mustNotCall()); socket1.on('error', (err) => assert.fail(err)); socket2.on('error', (err) => assert.fail(err)); @@ -96,7 +97,7 @@ if (cluster.isPrimary) { common.mustCall((err) => { process.send(`socket3:${err.code}`); }); - const address = common.localhostIPv4; + const address = common.localhostIP; const opt1 = { address, port: 0, exclusive: false }; const opt2 = { address, port: common.PORT, exclusive: false }; const opt3 = { address, port: common.PORT + 1, exclusive: true }; diff --git a/test/sequential/test-http-max-sockets.js b/test/sequential/test-http-max-sockets.js index 24629448f7ac77..f8c6490ef9c5d6 100644 --- a/test/sequential/test-http-max-sockets.js +++ b/test/sequential/test-http-max-sockets.js @@ -40,12 +40,13 @@ const server = http.createServer(function(req, res) { res.end('Hello World\n'); }); -const addrString = agent.getName({ host: '127.0.0.1', port: common.PORT }); +const addrString = agent.getName({ host: common.localhostIP, + port: common.PORT }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(common.PORT, common.localhostIP, function() { for (let i = 0; i < N; i++) { const options = { - host: '127.0.0.1', + host: common.localhostIP, port: common.PORT }; diff --git a/test/sequential/test-https-connect-localport.js b/test/sequential/test-https-connect-localport.js index e703fb2287d369..8ce98468a86c1a 100644 --- a/test/sequential/test-https-connect-localport.js +++ b/test/sequential/test-https-connect-localport.js @@ -17,13 +17,13 @@ const assert = require('assert'); res.end(); })); - server.listen(0, 'localhost', common.mustCall(() => { + server.listen(0, common.localhostIP, common.mustCall(() => { const port = server.address().port; const req = https.get({ host: 'localhost', pathname: '/', port, - family: 4, + family: common.hasIPv6 ? 6 : 4, localPort: common.PORT, rejectUnauthorized: false, }, common.mustCall(() => { diff --git a/test/sequential/test-inspector-break-when-eval.js b/test/sequential/test-inspector-break-when-eval.js index 0dd66588ed23b9..0172855569f794 100644 --- a/test/sequential/test-inspector-break-when-eval.js +++ b/test/sequential/test-inspector-break-when-eval.js @@ -62,7 +62,8 @@ async function stepOverConsoleStatement(session) { async function runTests() { // NOTE(mmarchini): Use --inspect-brk to improve avoid undeterministic // behavior. - const child = new NodeInstance(['--inspect-brk=0'], undefined, script); + const child = new NodeInstance(['--inspect-brk=localhost:0'], + undefined, script); const session = await child.connectInspectorSession(); await setupDebugger(session); await breakOnLine(session); diff --git a/test/sequential/test-inspector-console.js b/test/sequential/test-inspector-console.js index bb0f0ce42a3d03..4722729b948470 100644 --- a/test/sequential/test-inspector-console.js +++ b/test/sequential/test-inspector-console.js @@ -8,7 +8,7 @@ const assert = require('assert'); async function runTest() { const script = 'require(\'inspector\').console.log(\'hello world\');'; - const child = new NodeInstance('--inspect-brk=0', script, ''); + const child = new NodeInstance('--inspect-brk=localhost:0', script, ''); let out = ''; child.on('stdout', (line) => out += line); diff --git a/test/sequential/test-inspector-debug-brk-flag.js b/test/sequential/test-inspector-debug-brk-flag.js index f1312b47ad8d8b..143faf617bdbff 100644 --- a/test/sequential/test-inspector-debug-brk-flag.js +++ b/test/sequential/test-inspector-debug-brk-flag.js @@ -27,7 +27,8 @@ async function testBreakpointOnStart(session) { } async function runTests() { - const child = new NodeInstance(['--inspect', '--inspect-brk']); + const child = new NodeInstance(['--inspect=localhost', + '--inspect-brk=localhost']); const session = await child.connectInspectorSession(); await testBreakpointOnStart(session); diff --git a/test/sequential/test-inspector-debug-end.js b/test/sequential/test-inspector-debug-end.js index f3e343a0dadb25..d9252d0fc96286 100644 --- a/test/sequential/test-inspector-debug-end.js +++ b/test/sequential/test-inspector-debug-end.js @@ -14,7 +14,7 @@ async function testNoServerNoCrash() { async function testNoSessionNoCrash() { console.log('Test there\'s no crash stopping server without connecting'); - const instance = new NodeInstance('--inspect=0', + const instance = new NodeInstance('--inspect=localhost:0', 'process._debugEnd();process.exit(42);'); strictEqual((await instance.expectShutdown()).exitCode, 42); } @@ -28,7 +28,7 @@ async function testSessionNoCrash() { process.exit(42); });`; - const instance = new NodeInstance('--inspect-brk=0', script); + const instance = new NodeInstance('--inspect-brk=localhost:0', script); const session = await instance.connectInspectorSession(); await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' }); await session.waitForServerDisconnect(); diff --git a/test/sequential/test-inspector-not-blocked-on-idle.js b/test/sequential/test-inspector-not-blocked-on-idle.js index fbf26d15c91f12..0a94a86ae74516 100644 --- a/test/sequential/test-inspector-not-blocked-on-idle.js +++ b/test/sequential/test-inspector-not-blocked-on-idle.js @@ -5,7 +5,7 @@ const { NodeInstance } = require('../common/inspector-helper.js'); async function runTests() { const script = 'setInterval(() => {debugger;}, 60000);'; - const node = new NodeInstance('--inspect=0', script); + const node = new NodeInstance('--inspect=localhost:0', script); // 1 second wait to make sure the inferior began running the script await new Promise((resolve) => setTimeout(() => resolve(), 1000)); const session = await node.connectInspectorSession(); diff --git a/test/sequential/test-inspector-open.js b/test/sequential/test-inspector-open.js index 190a99e7282e52..78ba3339e1c045 100644 --- a/test/sequential/test-inspector-open.js +++ b/test/sequential/test-inspector-open.js @@ -98,10 +98,10 @@ function beChild() { process.on('message', (msg) => { if (msg.cmd === 'open') { if (msg.args[0] === kFirstOpen) { - inspector.open(0, false, undefined); + inspector.open(0, 'localhost', undefined); } else if (msg.args[0] === kOpenWhileOpen) { assert.throws(() => { - inspector.open(0, false, undefined); + inspector.open(0, 'localhost', undefined); }, { code: 'ERR_INSPECTOR_ALREADY_ACTIVATED' }); diff --git a/test/sequential/test-inspector-port-zero.js b/test/sequential/test-inspector-port-zero.js index 1683394a1dd4a3..4f993d1083fe3d 100644 --- a/test/sequential/test-inspector-port-zero.js +++ b/test/sequential/test-inspector-port-zero.js @@ -1,5 +1,6 @@ 'use strict'; const { mustCall, skipIfInspectorDisabled } = require('../common'); +const common = require('../common'); skipIfInspectorDisabled(); @@ -42,14 +43,17 @@ function test(arg, port = '') { test('--inspect=0'); test('--inspect=127.0.0.1:0'); +if (common.hasIPv6) test('--inspect=[::1]:0'); test('--inspect=localhost:0'); test('--inspect-brk=0'); test('--inspect-brk=127.0.0.1:0'); +if (common.hasIPv6) test('--inspect-brk=[::1]:0'); test('--inspect-brk=localhost:0'); // In these cases, the inspector doesn't listen, so an ephemeral port is not // allocated and the expected value of `process.debugPort` is `0`. test('--inspect-port=0', '0'); test('--inspect-port=127.0.0.1:0', '0'); +if (common.hasIPv6) test('--inspect-port=[::1]:0', '0'); test('--inspect-port=localhost:0', '0'); diff --git a/test/sequential/test-inspector-scriptparsed-context.js b/test/sequential/test-inspector-scriptparsed-context.js index e656436879ce63..bd0cc0b937245e 100644 --- a/test/sequential/test-inspector-scriptparsed-context.js +++ b/test/sequential/test-inspector-scriptparsed-context.js @@ -43,7 +43,8 @@ async function checkScriptContext(session, context) { } async function runTests() { - const instance = new NodeInstance(['--inspect-brk=0', '--expose-internals'], + const instance = new NodeInstance(['--inspect-brk=localhost:0', + '--expose-internals'], script); const session = await instance.connectInspectorSession(); await session.send([ diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index f81884ecfd4e46..816a8ceeb330e1 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -5,7 +5,7 @@ const assert = require('assert'); const { NodeInstance } = require('../common/inspector-helper.js'); async function runTests() { - const child = new NodeInstance(['--inspect-brk=0'], + const child = new NodeInstance(['--inspect-brk=localhost:0'], `let c = 0; const interval = setInterval(() => { console.log(new Object()); diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index ebe987d0443b6c..e5531be1c3726c 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -52,7 +52,7 @@ function server() { console.error('_socketEnd'); }); socket.write(content); - }).listen(common.PORT, common.localhostIPv4, function() { + }).listen(common.PORT, common.localhostIP, function() { console.log('listening'); }); } @@ -60,7 +60,7 @@ function server() { function client() { const net = require('net'); const client = net.connect({ - host: common.localhostIPv4, + host: common.localhostIP, port: common.PORT }, function() { client.destroy(); diff --git a/test/sequential/test-net-better-error-messages-port.js b/test/sequential/test-net-better-error-messages-port.js index e8756838063e72..c21427ee395139 100644 --- a/test/sequential/test-net-better-error-messages-port.js +++ b/test/sequential/test-net-better-error-messages-port.js @@ -10,5 +10,5 @@ c.on('connect', common.mustNotCall()); c.on('error', common.mustCall(function(e) { assert.strictEqual(e.code, 'ECONNREFUSED'); assert.strictEqual(e.port, common.PORT); - assert.match(e.address, '/^127\.0\.0\.1$|^::1$/'); + assert.match(e.address, /^(127\.0\.0\.1|::1)$/); })); diff --git a/test/sequential/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js index 030c4de750cb4d..ecf58fc3b197f8 100644 --- a/test/sequential/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -10,7 +10,8 @@ const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; const optionsIPv4 = { port: common.PORT, localPort: common.PORT + 1, - localAddress: common.localhostIPv4 + localAddress: common.localhostIPv4, + family: 4 }; const optionsIPv6 = { @@ -18,6 +19,7 @@ const optionsIPv6 = { port: common.PORT + 2, localPort: common.PORT + 3, localAddress: '::1', + family: 6 }; function onError(err, options) { diff --git a/test/sequential/test-net-localport.js b/test/sequential/test-net-localport.js index e90df73e524b51..a44b6411ee306f 100644 --- a/test/sequential/test-net-localport.js +++ b/test/sequential/test-net-localport.js @@ -11,7 +11,7 @@ const server = net.createServer(function(socket) { }); }).listen(0).on('listening', function() { const client = net.connect({ - host: '127.0.0.1', + host: 'localhost', port: this.address().port, localPort: common.PORT, }).on('connect', function() { diff --git a/test/sequential/test-net-response-size.js b/test/sequential/test-net-response-size.js index c5d7e9b600e05d..b5d7ac2f994a0e 100644 --- a/test/sequential/test-net-response-size.js +++ b/test/sequential/test-net-response-size.js @@ -42,7 +42,7 @@ if (process.argv[2] === 'server') { }); }); - server.listen(common.PORT, '127.0.0.1', function() { + server.listen(common.PORT, 'localhost', function() { console.log('Server running.'); }); @@ -54,7 +54,7 @@ if (process.argv[2] === 'server') { serverProcess.stderr.pipe(process.stdout); serverProcess.stdout.once('data', function() { - const client = net.createConnection(common.PORT, '127.0.0.1'); + const client = net.createConnection(common.PORT, 'localhost'); client.on('connect', function() { const alot = Buffer.allocUnsafe(1024); const alittle = Buffer.allocUnsafe(1); From 43d1492738d152783d3d97b6a09dfb5be79f039d Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sat, 13 Mar 2021 15:46:59 +0100 Subject: [PATCH 03/27] Update test-net-dns-lookup.js --- test/parallel/test-net-dns-lookup.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 4ae31412855365..2aa4850fe100aa 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -29,12 +29,12 @@ const server = net.createServer(function(client) { server.close(); }); -server.listen(0, common.localhostIP, common.mustCall(function() { +server.listen(0, '127.0.0.1', common.mustCall(function() { net.connect(this.address().port, 'localhost') .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); - assert.strictEqual(ip, common.hasIPv6 ? '::1' : '127.0.0.1'); - assert.strictEqual(type, common.hasIPv6 ? 6 : 4); + assert.match(ip, /^(127\.0\.0\.1|::1)$/); + assert.strictEqual(type.toString(), /^(4|6)$/); assert.strictEqual(host, 'localhost'); })); })); From beb6420f524b1d57815ccb71267ddb9b538b323b Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sat, 13 Mar 2021 17:52:32 +0100 Subject: [PATCH 04/27] Update test-net-dns-lookup.js --- test/parallel/test-net-dns-lookup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 2aa4850fe100aa..fa0e0127904bb7 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -34,7 +34,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); assert.match(ip, /^(127\.0\.0\.1|::1)$/); - assert.strictEqual(type.toString(), /^(4|6)$/); + assert.match(type.toString(), /^(4|6)$/); assert.strictEqual(host, 'localhost'); })); })); From 604366cb67a575f048eae471c497d54c29f370fa Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sat, 13 Mar 2021 19:05:18 +0100 Subject: [PATCH 05/27] Fix test-net-dns-lookup.js --- test/parallel/test-net-dns-lookup.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index fa0e0127904bb7..dd12174e70bb03 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -29,12 +29,16 @@ const server = net.createServer(function(client) { server.close(); }); -server.listen(0, '127.0.0.1', common.mustCall(function() { - net.connect(this.address().port, 'localhost') +server.listen(0, common.localhostIP, common.mustCall(function() { + net.connect({ + port: this.address().port, + host: 'localhost', + family: common.hasIPv6 ? 6 : 4, + }) .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); - assert.match(ip, /^(127\.0\.0\.1|::1)$/); - assert.match(type.toString(), /^(4|6)$/); + assert.strictEqual(ip, common.hasIPv6 ? '::1' : '127.0.0.1'); + assert.strictEqual(type, common.hasIPv6 ? 6 : 4); assert.strictEqual(host, 'localhost'); })); })); From 1bb0e551da4e59da490b4d9f065ba69b0d251748 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sun, 14 Mar 2021 00:54:48 +0100 Subject: [PATCH 06/27] Apply suggestions from code review Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> --- test/sequential/test-net-connect-local-error.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js index ecf58fc3b197f8..5eabbff756e1cd 100644 --- a/test/sequential/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -11,7 +11,7 @@ const optionsIPv4 = { port: common.PORT, localPort: common.PORT + 1, localAddress: common.localhostIPv4, - family: 4 + family: 4, }; const optionsIPv6 = { @@ -19,7 +19,7 @@ const optionsIPv6 = { port: common.PORT + 2, localPort: common.PORT + 3, localAddress: '::1', - family: 6 + family: 6, }; function onError(err, options) { From 16a1682e466eec589853acbed7b245decb79278e Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sun, 14 Mar 2021 14:02:42 +0100 Subject: [PATCH 07/27] IPv6 fixes --- test/common/inspector-helper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index e9f7028f65c49d..fe10ae9ce856db 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -326,7 +326,11 @@ class InspectorSession { } class NodeInstance extends EventEmitter { - constructor(inspectorFlags = ['--inspect-brk=localhost:0', + constructor(inspectorFlags = ['--inspect-brk=' + + (common.hasIPv6 ? + '[::1]' : + common.localhostIPv4) + + ':0', '--expose-internals'], scriptContents = '', scriptFile = _MAINSCRIPT) { @@ -364,7 +368,7 @@ class NodeInstance extends EventEmitter { static async startViaSignal(scriptContents) { const instance = new NodeInstance( - ['--inspect=localhost', '--expose-internals'], + ['--inspect=' + common.localhostIP, '--expose-internals'], `${scriptContents}\nprocess._rawDebug('started');`, undefined); const msg = 'Timed out waiting for process to start'; while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== From 178683c3c287e951879b9f248f9df36d712ed0e5 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sun, 14 Mar 2021 18:27:38 +0100 Subject: [PATCH 08/27] Update inspector-helper.js --- test/common/inspector-helper.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index fe10ae9ce856db..e9f7028f65c49d 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -326,11 +326,7 @@ class InspectorSession { } class NodeInstance extends EventEmitter { - constructor(inspectorFlags = ['--inspect-brk=' + - (common.hasIPv6 ? - '[::1]' : - common.localhostIPv4) + - ':0', + constructor(inspectorFlags = ['--inspect-brk=localhost:0', '--expose-internals'], scriptContents = '', scriptFile = _MAINSCRIPT) { @@ -368,7 +364,7 @@ class NodeInstance extends EventEmitter { static async startViaSignal(scriptContents) { const instance = new NodeInstance( - ['--inspect=' + common.localhostIP, '--expose-internals'], + ['--inspect=localhost', '--expose-internals'], `${scriptContents}\nprocess._rawDebug('started');`, undefined); const msg = 'Timed out waiting for process to start'; while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== From 2b67c17958f497076c817ed204b6999114eda28a Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Tue, 16 Mar 2021 09:47:51 +0100 Subject: [PATCH 09/27] Revert "Fixes for IPv6 compatibility; new const 'common.localhostIP'" This reverts commit 4be87a0294d6e0b59948ed491b188ee39e41d7bb. --- test/addons/openssl-client-cert-engine/test.js | 4 ++-- test/addons/openssl-key-engine/test.js | 4 ++-- test/async-hooks/test-getnameinforeqwrap.js | 2 +- test/async-hooks/test-httpparser-reuse.js | 2 +- test/common/index.js | 4 ---- test/common/inspector-helper.js | 5 ++--- .../test-inspector-cluster-port-clash.js | 2 +- test/parallel/test-child-process-send-keep-open.js | 2 +- test/parallel/test-cluster-message.js | 2 +- .../test-cluster-worker-wait-server-close.js | 4 ++-- .../test-http-client-reject-unexpected-agent.js | 2 +- .../test-http-client-timeout-option-listeners.js | 2 +- test/parallel/test-http-flush-response-headers.js | 4 ++-- test/parallel/test-http-localaddress.js | 6 +++--- .../test-http-request-dont-override-options.js | 4 ++-- test/parallel/test-http-same-map.js | 2 +- test/parallel/test-http-upgrade-client.js | 2 +- test/parallel/test-http2-connect-options.js | 6 +++--- test/parallel/test-https-client-get-url.js | 3 +-- test/parallel/test-https-localaddress.js | 6 +++--- .../test-inspect-async-hook-setup-at-inspect.js | 2 +- test/parallel/test-inspect-publish-uid.js | 2 +- test/parallel/test-inspector-esm.js | 2 +- test/parallel/test-inspector-inspect-brk-node.js | 3 +-- test/parallel/test-inspector-wait-for-connection.js | 2 +- .../test-inspector-waiting-for-disconnect.js | 3 +-- test/parallel/test-net-client-bind-twice.js | 8 ++++---- test/parallel/test-net-dns-lookup.js | 12 ++++-------- test/parallel/test-net-local-address-port.js | 6 +++--- test/parallel/test-net-remote-address-port.js | 1 - test/parallel/test-net-socket-local-address.js | 4 ++-- test/parallel/test-repl-require.js | 4 ++-- test/parallel/test-tcp-wrap-connect.js | 6 ++---- test/parallel/test-tcp-wrap-listen.js | 2 +- ...ocket-timeout-removes-other-socket-unref-timer.js | 2 +- test/parallel/test-tls-alpn-server-client.js | 2 +- test/parallel/test-tls-client-getephemeralkeyinfo.js | 2 +- test/parallel/test-tls-client-mindhsize.js | 2 +- test/parallel/test-tls-getprotocol.js | 4 ++-- test/parallel/test-tls-multiple-cas-as-string.js | 2 +- .../test-tls-wrap-econnreset-localaddress.js | 7 +++---- test/parallel/test-tls-wrap-econnreset.js | 4 ++-- test/sequential/test-child-process-pass-fd.js | 4 ++-- test/sequential/test-cluster-inspect-brk.js | 4 ++-- test/sequential/test-dgram-bind-shared-ports.js | 9 ++++----- test/sequential/test-http-max-sockets.js | 7 +++---- test/sequential/test-https-connect-localport.js | 4 ++-- test/sequential/test-inspector-break-when-eval.js | 3 +-- test/sequential/test-inspector-console.js | 2 +- test/sequential/test-inspector-debug-brk-flag.js | 3 +-- test/sequential/test-inspector-debug-end.js | 4 ++-- .../sequential/test-inspector-not-blocked-on-idle.js | 2 +- test/sequential/test-inspector-open.js | 4 ++-- test/sequential/test-inspector-port-zero.js | 4 ---- .../test-inspector-scriptparsed-context.js | 3 +-- .../test-inspector-stop-profile-after-done.js | 2 +- test/sequential/test-net-GH-5504.js | 4 ++-- .../test-net-better-error-messages-port.js | 2 +- test/sequential/test-net-connect-local-error.js | 4 +--- test/sequential/test-net-localport.js | 2 +- test/sequential/test-net-response-size.js | 4 ++-- 61 files changed, 97 insertions(+), 124 deletions(-) diff --git a/test/addons/openssl-client-cert-engine/test.js b/test/addons/openssl-client-cert-engine/test.js index 9dd14cc9706983..e843e4bf433bff 100644 --- a/test/addons/openssl-client-cert-engine/test.js +++ b/test/addons/openssl-client-cert-engine/test.js @@ -32,10 +32,10 @@ const serverOptions = { const server = https.createServer(serverOptions, common.mustCall((req, res) => { res.writeHead(200); res.end('hello world'); -})).listen(0, common.localhostIP, common.mustCall(() => { +})).listen(0, common.localhostIPv4, common.mustCall(() => { const clientOptions = { method: 'GET', - host: common.localhostIP, + host: common.localhostIPv4, port: server.address().port, path: '/test', clientCertEngine: engine, // `engine` will provide key+cert diff --git a/test/addons/openssl-key-engine/test.js b/test/addons/openssl-key-engine/test.js index b525e45c0b8e03..2cd7ddabc17095 100644 --- a/test/addons/openssl-key-engine/test.js +++ b/test/addons/openssl-key-engine/test.js @@ -32,10 +32,10 @@ const serverOptions = { const server = https.createServer(serverOptions, common.mustCall((req, res) => { res.writeHead(200); res.end('hello world'); -})).listen(0, common.localhostIP, common.mustCall(() => { +})).listen(0, common.localhostIPv4, common.mustCall(() => { const clientOptions = { method: 'GET', - host: common.localhostIP, + host: common.localhostIPv4, port: server.address().port, path: '/test', privateKeyEngine: engine, diff --git a/test/async-hooks/test-getnameinforeqwrap.js b/test/async-hooks/test-getnameinforeqwrap.js index d5027ab447c400..c7a3937ff3ceef 100644 --- a/test/async-hooks/test-getnameinforeqwrap.js +++ b/test/async-hooks/test-getnameinforeqwrap.js @@ -13,7 +13,7 @@ if (!common.isMainThread) const hooks = initHooks(); hooks.enable(); -dns.lookupService(common.localhostIP, 80, common.mustCall(onlookupService)); +dns.lookupService('127.0.0.1', 80, common.mustCall(onlookupService)); function onlookupService() { // We don't care about the error here in order to allow // tests to run offline (lookup will fail in that case and the err be set) diff --git a/test/async-hooks/test-httpparser-reuse.js b/test/async-hooks/test-httpparser-reuse.js index 9ece674e04f29b..70248970df364c 100644 --- a/test/async-hooks/test-httpparser-reuse.js +++ b/test/async-hooks/test-httpparser-reuse.js @@ -49,7 +49,7 @@ const server = http.createServer((req, res) => { server.listen(0, common.mustCall(() => { const PORT = server.address().port; - const url = `http://localhost:${PORT}`; + const url = `http://127.0.0.1:${PORT}`; http.get(url, common.mustCall(() => { server.close(common.mustCall(() => { server.listen(PORT, common.mustCall(() => { diff --git a/test/common/index.js b/test/common/index.js index 2655a48ee8eb96..b70972b1a54d26 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -823,10 +823,6 @@ const common = { return localhostIPv4; }, - get localhostIP() { - return this.hasIPv6 ? '::1' : this.localhostIPv4; - }, - // opensslCli defined lazily to reduce overhead of spawnSync get opensslCli() { if (opensslCli !== null) return opensslCli; diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index e9f7028f65c49d..666624490e79a9 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -326,8 +326,7 @@ class InspectorSession { } class NodeInstance extends EventEmitter { - constructor(inspectorFlags = ['--inspect-brk=localhost:0', - '--expose-internals'], + constructor(inspectorFlags = ['--inspect-brk=0', '--expose-internals'], scriptContents = '', scriptFile = _MAINSCRIPT) { super(); @@ -364,7 +363,7 @@ class NodeInstance extends EventEmitter { static async startViaSignal(scriptContents) { const instance = new NodeInstance( - ['--inspect=localhost', '--expose-internals'], + ['--expose-internals'], `${scriptContents}\nprocess._rawDebug('started');`, undefined); const msg = 'Timed out waiting for process to start'; while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== diff --git a/test/known_issues/test-inspector-cluster-port-clash.js b/test/known_issues/test-inspector-cluster-port-clash.js index 986e56986a56a2..e5daee61b78ff6 100644 --- a/test/known_issues/test-inspector-cluster-port-clash.js +++ b/test/known_issues/test-inspector-cluster-port-clash.js @@ -52,7 +52,7 @@ if (cluster.isPrimary) { // Block one of the ports with a listening socket. const server = net.createServer(); - server.listen(clashPort, common.localhostIP, common.mustCall(() => { + server.listen(clashPort, common.localhostIPv4, common.mustCall(() => { // Try to fork 3 workers. No.2 should fail. Promise.all([serialFork(), serialFork(), serialFork()]) .then(common.mustNotCall()) diff --git a/test/parallel/test-child-process-send-keep-open.js b/test/parallel/test-child-process-send-keep-open.js index dd9db7bef13c8e..54169dc1885f66 100644 --- a/test/parallel/test-child-process-send-keep-open.js +++ b/test/parallel/test-child-process-send-keep-open.js @@ -36,7 +36,7 @@ if (process.argv[2] !== 'child') { }); server.listen(0, () => { - const socket = net.connect(server.address().port, common.localhostIP); + const socket = net.connect(server.address().port, common.localhostIPv4); socket.setEncoding('utf8'); socket.on('data', (data) => result += data); }); diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js index 33b8457f016e8e..45854c77a5a347 100644 --- a/test/parallel/test-cluster-message.js +++ b/test/parallel/test-cluster-message.js @@ -60,7 +60,7 @@ if (cluster.isWorker) { maybeReply(); }); - server.listen(0, 'localhost'); + server.listen(0, '127.0.0.1'); } else if (cluster.isPrimary) { const checks = { diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index 98b72aa46baa86..71a8cacb5260a3 100644 --- a/test/parallel/test-cluster-worker-wait-server-close.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -12,7 +12,7 @@ if (cluster.isWorker) { // Wait for any data, then close connection socket.write('.'); socket.on('data', () => {}); - }).listen(0, common.localhostIP); + }).listen(0, common.localhostIPv4); server.once('close', function() { serverClosed = true; @@ -34,7 +34,7 @@ if (cluster.isWorker) { // Disconnect worker when it is ready worker.once('listening', function(address) { - const socket = net.createConnection(address.port, common.localhostIP); + const socket = net.createConnection(address.port, common.localhostIPv4); socket.on('connect', function() { socket.on('data', function() { diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js index 784f00eac160b1..8ec6506888bb05 100644 --- a/test/parallel/test-http-client-reject-unexpected-agent.js +++ b/test/parallel/test-http-client-reject-unexpected-agent.js @@ -6,7 +6,7 @@ const http = require('http'); const baseOptions = { method: 'GET', port: undefined, - host: common.localhostIP, + host: common.localhostIPv4, }; const failingAgentOptions = [ diff --git a/test/parallel/test-http-client-timeout-option-listeners.js b/test/parallel/test-http-client-timeout-option-listeners.js index 98a4d94fba6dce..1122eaf79e46f8 100644 --- a/test/parallel/test-http-client-timeout-option-listeners.js +++ b/test/parallel/test-http-client-timeout-option-listeners.js @@ -16,7 +16,7 @@ const options = { agent, method: 'GET', port: undefined, - host: common.localhostIP, + host: common.localhostIPv4, path: '/', timeout: timeout }; diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js index 5e71dfaf47faab..0f0a1387b56733 100644 --- a/test/parallel/test-http-flush-response-headers.js +++ b/test/parallel/test-http-flush-response-headers.js @@ -10,10 +10,10 @@ server.on('request', function(req, res) { res.flushHeaders(); res.flushHeaders(); // Should be idempotent. }); -server.listen(0, common.localhostIP, function() { +server.listen(0, common.localhostIPv4, function() { const req = http.request({ method: 'GET', - host: common.localhostIP, + host: common.localhostIPv4, port: this.address().port, }, onResponse); diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index 76a154c238adae..e237c3bff1ac84 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -30,7 +30,7 @@ const assert = require('assert'); const server = http.createServer((req, res) => { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.match(req.connection.remoteAddress, /^(127\.0\.0\.2|::1)$/); + assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); req.on('end', () => { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -39,12 +39,12 @@ const server = http.createServer((req, res) => { req.resume(); }); -server.listen(0, 'localhost', () => { +server.listen(0, '127.0.0.1', () => { const options = { host: 'localhost', port: server.address().port, path: '/', method: 'GET', - localAddress: common.hasIPv6 ? '::1' : '127.0.0.2' }; + localAddress: '127.0.0.2' }; const req = http.request(options, function(res) { res.on('end', () => { diff --git a/test/parallel/test-http-request-dont-override-options.js b/test/parallel/test-http-request-dont-override-options.js index c1d14f20c5cf77..19b847dc0390f5 100644 --- a/test/parallel/test-http-request-dont-override-options.js +++ b/test/parallel/test-http-request-dont-override-options.js @@ -19,7 +19,7 @@ server.listen(0, function() { // be mutable / modified const options = { host: undefined, - hostname: common.localhostIP, + hostname: common.localhostIPv4, port: undefined, defaultPort: undefined, path: undefined, @@ -31,7 +31,7 @@ server.listen(0, function() { res.resume(); server.close(); assert.strictEqual(options.host, undefined); - assert.strictEqual(options.hostname, common.localhostIP); + assert.strictEqual(options.hostname, common.localhostIPv4); assert.strictEqual(options.port, undefined); assert.strictEqual(options.defaultPort, undefined); assert.strictEqual(options.path, undefined); diff --git a/test/parallel/test-http-same-map.js b/test/parallel/test-http-same-map.js index ab595437b08839..3d8d325ad7b0d1 100644 --- a/test/parallel/test-http-same-map.js +++ b/test/parallel/test-http-same-map.js @@ -6,7 +6,7 @@ const assert = require('assert'); const http = require('http'); const server = - http.createServer(onrequest).listen(0, common.localhostIP, () => next(0)); + http.createServer(onrequest).listen(0, common.localhostIPv4, () => next(0)); function onrequest(req, res) { res.end('ok'); diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js index a206e46af569e2..8fe756f469f09a 100644 --- a/test/parallel/test-http-upgrade-client.js +++ b/test/parallel/test-http-upgrade-client.js @@ -49,7 +49,7 @@ const server = net.createServer(function(c) { }); }); -server.listen(0, 'localhost', common.mustCall(function() { +server.listen(0, '127.0.0.1', common.mustCall(function() { const port = this.address().port; const headers = [ { diff --git a/test/parallel/test-http2-connect-options.js b/test/parallel/test-http2-connect-options.js index bc5304c2437ade..0c7ec807b84d38 100644 --- a/test/parallel/test-http2-connect-options.js +++ b/test/parallel/test-http2-connect-options.js @@ -12,7 +12,7 @@ const assert = require('assert'); const server = http2.createServer((req, res) => { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.match(req.connection.remoteAddress, /^(127\.0\.0\.2|::1)$/); + assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); req.on('end', common.mustCall(() => { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -21,8 +21,8 @@ const server = http2.createServer((req, res) => { req.resume(); }); -server.listen(0, 'localhost', common.mustCall(() => { - const options = { localAddress: common.hasIPv6 ? '::1' : '127.0.0.2' }; +server.listen(0, '127.0.0.1', common.mustCall(() => { + const options = { localAddress: '127.0.0.2' }; const client = http2.connect( 'http://localhost:' + server.address().port, diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js index e30d77725e54cc..fb91a4f1e7cb8a 100644 --- a/test/parallel/test-https-client-get-url.js +++ b/test/parallel/test-https-client-get-url.js @@ -46,8 +46,7 @@ const server = https.createServer(options, common.mustCall((req, res) => { }, 3)); server.listen(0, common.mustCall(() => { - const localhost = common.hasIPv6 ? '[::1]' : common.localhostIPv4; - const u = `https://${localhost}:${server.address().port}/foo?bar`; + const u = `https://${common.localhostIPv4}:${server.address().port}/foo?bar`; https.get(u, common.mustCall(() => { https.get(url.parse(u), common.mustCall(() => { https.get(new URL(u), common.mustCall(() => { diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index 880cdba5eee695..0ac8414b2d4b35 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -39,7 +39,7 @@ const options = { const server = https.createServer(options, function(req, res) { console.log(`Connect from: ${req.connection.remoteAddress}`); - assert.match(req.connection.remoteAddress, /^(127\.0\.0\.2|::1)$/); + assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -48,13 +48,13 @@ const server = https.createServer(options, function(req, res) { req.resume(); }); -server.listen(0, 'localhost', function() { +server.listen(0, '127.0.0.1', function() { const options = { host: 'localhost', port: this.address().port, path: '/', method: 'GET', - localAddress: common.hasIPv6 ? '::1' : '127.0.0.2', + localAddress: '127.0.0.2', rejectUnauthorized: false }; diff --git a/test/parallel/test-inspect-async-hook-setup-at-inspect.js b/test/parallel/test-inspect-async-hook-setup-at-inspect.js index 971485cfc8f61f..b68617b5d52276 100644 --- a/test/parallel/test-inspect-async-hook-setup-at-inspect.js +++ b/test/parallel/test-inspect-async-hook-setup-at-inspect.js @@ -45,7 +45,7 @@ async function checkAsyncStackTrace(session) { } async function runTests() { - const instance = new NodeInstance(['--inspect=localhost:0'], script); + const instance = new NodeInstance(['--inspect=0'], script); const session = await instance.connectInspectorSession(); await session.send([ { 'method': 'Runtime.enable' }, diff --git a/test/parallel/test-inspect-publish-uid.js b/test/parallel/test-inspect-publish-uid.js index 745913c10f1ed1..2479a37a2d6901 100644 --- a/test/parallel/test-inspect-publish-uid.js +++ b/test/parallel/test-inspect-publish-uid.js @@ -18,7 +18,7 @@ async function testArg(argValue) { const hasStderr = argValue.split(',').includes('stderr'); const nodeProcess = spawnSync(process.execPath, [ - '--inspect=localhost:0', + '--inspect=0', `--inspect-publish-uid=${argValue}`, '-e', `(${scriptMain.toString()})(${hasHttp ? 200 : 404})` ]); diff --git a/test/parallel/test-inspector-esm.js b/test/parallel/test-inspector-esm.js index b8f32e7fd319f0..da3bd17e33f4bc 100644 --- a/test/parallel/test-inspector-esm.js +++ b/test/parallel/test-inspector-esm.js @@ -98,7 +98,7 @@ async function testBreakpoint(session) { } async function runTest() { - const child = new NodeInstance(['--inspect-brk=localhost:0'], '', + const child = new NodeInstance(['--inspect-brk=0'], '', fixtures.path('es-modules/loop.mjs')); const session = await child.connectInspectorSession(); diff --git a/test/parallel/test-inspector-inspect-brk-node.js b/test/parallel/test-inspector-inspect-brk-node.js index f6baf5f0e3b8b2..0f4795ed7b87e4 100644 --- a/test/parallel/test-inspector-inspect-brk-node.js +++ b/test/parallel/test-inspector-inspect-brk-node.js @@ -8,8 +8,7 @@ common.skipIfInspectorDisabled(); const { NodeInstance } = require('../common/inspector-helper.js'); async function runTest() { - const child = new NodeInstance(['--inspect-brk-node=localhost:0', - '-p', '42']); + const child = new NodeInstance(['--inspect-brk-node=0', '-p', '42']); const session = await child.connectInspectorSession(); await session.send({ method: 'Runtime.enable' }); await session.send({ method: 'Debugger.enable' }); diff --git a/test/parallel/test-inspector-wait-for-connection.js b/test/parallel/test-inspector-wait-for-connection.js index 3b45c339f95b44..0f562faede1e55 100644 --- a/test/parallel/test-inspector-wait-for-connection.js +++ b/test/parallel/test-inspector-wait-for-connection.js @@ -42,7 +42,7 @@ async function runTests() { function main(prefix) { const inspector = require('inspector'); - inspector.open(0, 'localhost', false); + inspector.open(0, undefined, false); process._ws = inspector.url(); console.log('before wait for debugger'); inspector.waitForDebugger(); diff --git a/test/parallel/test-inspector-waiting-for-disconnect.js b/test/parallel/test-inspector-waiting-for-disconnect.js index 40ca75033ed56b..e9d39978d7aaf0 100644 --- a/test/parallel/test-inspector-waiting-for-disconnect.js +++ b/test/parallel/test-inspector-waiting-for-disconnect.js @@ -12,8 +12,7 @@ function mainContextDestroyed(notification) { } async function runTest() { - const child = new NodeInstance(['--inspect-brk=localhost:0', '-e', - 'process.exit(55)']); + const child = new NodeInstance(['--inspect-brk=0', '-e', 'process.exit(55)']); const session = await child.connectInspectorSession(); const oldStyleSession = await child.connectInspectorSession(); await oldStyleSession.send([ diff --git a/test/parallel/test-net-client-bind-twice.js b/test/parallel/test-net-client-bind-twice.js index 97d1921b1f4493..ca7eb502d85ba5 100644 --- a/test/parallel/test-net-client-bind-twice.js +++ b/test/parallel/test-net-client-bind-twice.js @@ -7,13 +7,13 @@ const assert = require('assert'); const net = require('net'); const server1 = net.createServer(common.mustNotCall()); -server1.listen(0, common.localhostIP, common.mustCall(() => { +server1.listen(0, common.localhostIPv4, common.mustCall(() => { const server2 = net.createServer(common.mustNotCall()); - server2.listen(0, common.localhostIP, common.mustCall(() => { + server2.listen(0, common.localhostIPv4, common.mustCall(() => { const client = net.connect({ - host: common.localhostIP, + host: common.localhostIPv4, port: server1.address().port, - localAddress: common.localhostIP, + localAddress: common.localhostIPv4, localPort: server2.address().port }, common.mustNotCall()); diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index dd12174e70bb03..53052de716ee9e 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -29,16 +29,12 @@ const server = net.createServer(function(client) { server.close(); }); -server.listen(0, common.localhostIP, common.mustCall(function() { - net.connect({ - port: this.address().port, - host: 'localhost', - family: common.hasIPv6 ? 6 : 4, - }) +server.listen(0, '127.0.0.1', common.mustCall(function() { + net.connect(this.address().port, 'localhost') .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); - assert.strictEqual(ip, common.hasIPv6 ? '::1' : '127.0.0.1'); - assert.strictEqual(type, common.hasIPv6 ? 6 : 4); + assert.strictEqual(ip, '127.0.0.1'); + assert.strictEqual(type, 4); assert.strictEqual(host, 'localhost'); })); })); diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js index 0bf003ffe76160..dfd7ef359b71d2 100644 --- a/test/parallel/test-net-local-address-port.js +++ b/test/parallel/test-net-local-address-port.js @@ -25,7 +25,7 @@ const assert = require('assert'); const net = require('net'); const server = net.createServer(common.mustCall(function(socket) { - assert.strictEqual(socket.localAddress, common.localhostIP); + assert.strictEqual(socket.localAddress, common.localhostIPv4); assert.strictEqual(socket.localPort, this.address().port); socket.on('end', function() { server.close(); @@ -33,9 +33,9 @@ const server = net.createServer(common.mustCall(function(socket) { socket.resume(); })); -server.listen(0, common.localhostIP, function() { +server.listen(0, common.localhostIPv4, function() { const client = net.createConnection(this.address() - .port, common.localhostIP); + .port, common.localhostIPv4); client.on('connect', function() { client.end(); }); diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 001566de557589..094206f85df34d 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -29,7 +29,6 @@ let conns_closed = 0; const remoteAddrCandidates = [ common.localhostIPv4 ]; if (common.hasIPv6) remoteAddrCandidates.push('::ffff:127.0.0.1'); -if (common.hasIPv6) remoteAddrCandidates.push('::1'); const remoteFamilyCandidates = ['IPv4']; if (common.hasIPv6) remoteFamilyCandidates.push('IPv6'); diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index a6217f60c2e7cd..58645322f45100 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -22,7 +22,7 @@ server.on('close', common.mustCall(() => { assert.strictEqual(conns, 2); })); -server.listen(0, common.localhostIP, connect); +server.listen(0, common.localhostIPv4, connect); function connect() { if (conns === 2) { @@ -34,7 +34,7 @@ function connect() { client.once('close', connect); assert.strictEqual( client, - client.connect(server.address().port, common.localhostIP, () => { + client.connect(server.address().port, common.localhostIPv4, () => { clientLocalPorts.push(client.localPort); }) ); diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index d729e170b3d927..391b629b1b3a3b 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -19,7 +19,7 @@ const repl = require('repl'); }); }); - const host = common.localhostIP; + const host = common.localhostIPv4; const port = 0; const options = { host, port }; @@ -49,7 +49,7 @@ const repl = require('repl'); }); }); - const host = common.localhostIP; + const host = common.localhostIPv4; const port = 0; const options = { host, port }; diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js index 1defff923ee67f..5e3e81f6e11712 100644 --- a/test/parallel/test-tcp-wrap-connect.js +++ b/test/parallel/test-tcp-wrap-connect.js @@ -1,6 +1,6 @@ // Flags: --expose-internals 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); const { @@ -14,9 +14,7 @@ function makeConnection() { const client = new TCP(TCPConstants.SOCKET); const req = new TCPConnectWrap(); - const err = common.hasIPv6 ? - client.connect6(req, '::1', this.address().port) : - client.connect(req, '127.0.0.1', this.address().port); + const err = client.connect(req, '127.0.0.1', this.address().port); assert.strictEqual(err, 0); req.oncomplete = function(status, client_, req_, readable, writable) { diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index f49693b4918c01..72981b683ccea3 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -14,7 +14,7 @@ const { const server = new TCP(TCPConstants.SOCKET); -const r = common.hasIPv6 ? server.bind6('::', 0) : server.bind('0.0.0.0', 0); +const r = server.bind('0.0.0.0', 0); assert.strictEqual(r, 0); let port = {}; server.getsockname(port); diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js index 242bf33a2b0c17..ccecfe4c63a6a1 100644 --- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -28,7 +28,7 @@ const server = net.createServer(function onClient(client) { } }); -server.listen(0, 'localhost', common.mustCall(() => { +server.listen(0, common.localhostIPv4, common.mustCall(() => { const countdown = new Countdown(2, () => server.close()); { diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js index 8204fb459843bf..3da24c67fbe522 100644 --- a/test/parallel/test-tls-alpn-server-client.js +++ b/test/parallel/test-tls-alpn-server-client.js @@ -12,7 +12,7 @@ function loadPEM(n) { return fixtures.readKey(`${n}.pem`); } -const serverIP = common.localhostIP; +const serverIP = common.localhostIPv4; function checkResults(result, expected) { assert.strictEqual(result.server.ALPN, expected.server.ALPN); diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js index 51831bd18f5007..73ac215102ddbb 100644 --- a/test/parallel/test-tls-client-getephemeralkeyinfo.js +++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js @@ -37,7 +37,7 @@ function test(size, type, name, cipher) { server.on('close', common.mustSucceed()); - server.listen(0, 'localhost', common.mustCall(() => { + server.listen(0, '127.0.0.1', common.mustCall(() => { const client = tls.connect({ port: server.address().port, rejectUnauthorized: false diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index 484ef913bc361a..a6fbc67bd88361 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -34,7 +34,7 @@ function test(size, err, next) { if (next) next(); }); - server.listen(0, 'localhost', function() { + server.listen(0, '127.0.0.1', function() { // Client set minimum DH parameter size to 2048 bits so that // it fails when it make a connection to the tls server where // dhparams is 1024 bits diff --git a/test/parallel/test-tls-getprotocol.js b/test/parallel/test-tls-getprotocol.js index fa834cd4eddadc..a76ff0f3442a97 100644 --- a/test/parallel/test-tls-getprotocol.js +++ b/test/parallel/test-tls-getprotocol.js @@ -24,11 +24,11 @@ const serverConfig = { const server = tls.createServer(serverConfig, common.mustCall(function() { -}, clientConfigs.length)).listen(0, common.localhostIP, function() { +}, clientConfigs.length)).listen(0, common.localhostIPv4, function() { let connected = 0; clientConfigs.forEach(function(v) { tls.connect({ - host: common.localhostIP, + host: common.localhostIPv4, port: server.address().port, rejectUnauthorized: false, secureProtocol: v.secureProtocol diff --git a/test/parallel/test-tls-multiple-cas-as-string.js b/test/parallel/test-tls-multiple-cas-as-string.js index 40f86e001e112d..679d6b6c4cdc42 100644 --- a/test/parallel/test-tls-multiple-cas-as-string.js +++ b/test/parallel/test-tls-multiple-cas-as-string.js @@ -20,7 +20,7 @@ function test(ca) { server.addContext('agent3', { ca, cert, key }); - const host = common.localhostIP; + const host = common.localhostIPv4; server.listen(0, host, common.mustCall(() => { const socket = tls.connect({ servername: 'agent3', diff --git a/test/parallel/test-tls-wrap-econnreset-localaddress.js b/test/parallel/test-tls-wrap-econnreset-localaddress.js index 7150abe2d72bfd..30d3a8873fa8f0 100644 --- a/test/parallel/test-tls-wrap-econnreset-localaddress.js +++ b/test/parallel/test-tls-wrap-econnreset-localaddress.js @@ -16,15 +16,14 @@ const server = net.createServer((c) => { let errored = false; tls.connect({ port: port, - localAddress: common.localhostIP, - family: common.hasIPv6 ? 6 : 4, - }, common.localhostIP) + localAddress: common.localhostIPv4 + }, common.localhostIPv4) .once('error', common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNRESET'); assert.strictEqual(e.path, undefined); assert.strictEqual(e.host, undefined); assert.strictEqual(e.port, port); - assert.match(e.localAddress, /^(127\.0\.0\.1|::1)$/); + assert.strictEqual(e.localAddress, common.localhostIPv4); server.close(); errored = true; })) diff --git a/test/parallel/test-tls-wrap-econnreset.js b/test/parallel/test-tls-wrap-econnreset.js index b321909a507114..6ed268e766f704 100644 --- a/test/parallel/test-tls-wrap-econnreset.js +++ b/test/parallel/test-tls-wrap-econnreset.js @@ -14,11 +14,11 @@ const server = net.createServer((c) => { const port = server.address().port; let errored = false; - tls.connect(port, common.localhostIP) + tls.connect(port, common.localhostIPv4) .once('error', common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNRESET'); assert.strictEqual(e.path, undefined); - assert.strictEqual(e.host, common.localhostIP); + assert.strictEqual(e.host, common.localhostIPv4); assert.strictEqual(e.port, port); assert.strictEqual(e.localAddress, undefined); server.close(); diff --git a/test/sequential/test-child-process-pass-fd.js b/test/sequential/test-child-process-pass-fd.js index 47b1a614e5666d..98832c57a3df67 100644 --- a/test/sequential/test-child-process-pass-fd.js +++ b/test/sequential/test-child-process-pass-fd.js @@ -77,8 +77,8 @@ if (process.argv[2] !== 'child') { }); socketConnected(); }).unref(); - server.listen(0, common.localhostIP, () => { + server.listen(0, common.localhostIPv4, () => { const { port } = server.address(); - socket = net.connect(port, common.localhostIP, socketConnected).unref(); + socket = net.connect(port, common.localhostIPv4, socketConnected).unref(); }); } diff --git a/test/sequential/test-cluster-inspect-brk.js b/test/sequential/test-cluster-inspect-brk.js index 93a7050de73d27..fbae27f9ba4eb4 100644 --- a/test/sequential/test-cluster-inspect-brk.js +++ b/test/sequential/test-cluster-inspect-brk.js @@ -29,8 +29,8 @@ if (cluster.isPrimary) { })); } - test(['--inspect-brk=localhost']); - test([`--inspect-brk=localhost:${debuggerPort}`]); + test(['--inspect-brk']); + test([`--inspect-brk=${debuggerPort}`]); } else { // Cluster worker is at a breakpoint, should not reach here. assert.fail('Test failed: cluster worker should be at a breakpoint.'); diff --git a/test/sequential/test-dgram-bind-shared-ports.js b/test/sequential/test-dgram-bind-shared-ports.js index f83eed49122be5..c68cfac969dedf 100644 --- a/test/sequential/test-dgram-bind-shared-ports.js +++ b/test/sequential/test-dgram-bind-shared-ports.js @@ -73,10 +73,9 @@ if (cluster.isPrimary) { }), 1); const isSecondWorker = process.env.WORKER2_NAME === WORKER2_NAME; - const type = common.hasIPv6 ? 'udp6' : 'udp4'; - const socket1 = dgram.createSocket(type, common.mustNotCall()); - const socket2 = dgram.createSocket(type, common.mustNotCall()); - const socket3 = dgram.createSocket(type, common.mustNotCall()); + const socket1 = dgram.createSocket('udp4', common.mustNotCall()); + const socket2 = dgram.createSocket('udp4', common.mustNotCall()); + const socket3 = dgram.createSocket('udp4', common.mustNotCall()); socket1.on('error', (err) => assert.fail(err)); socket2.on('error', (err) => assert.fail(err)); @@ -97,7 +96,7 @@ if (cluster.isPrimary) { common.mustCall((err) => { process.send(`socket3:${err.code}`); }); - const address = common.localhostIP; + const address = common.localhostIPv4; const opt1 = { address, port: 0, exclusive: false }; const opt2 = { address, port: common.PORT, exclusive: false }; const opt3 = { address, port: common.PORT + 1, exclusive: true }; diff --git a/test/sequential/test-http-max-sockets.js b/test/sequential/test-http-max-sockets.js index f8c6490ef9c5d6..24629448f7ac77 100644 --- a/test/sequential/test-http-max-sockets.js +++ b/test/sequential/test-http-max-sockets.js @@ -40,13 +40,12 @@ const server = http.createServer(function(req, res) { res.end('Hello World\n'); }); -const addrString = agent.getName({ host: common.localhostIP, - port: common.PORT }); +const addrString = agent.getName({ host: '127.0.0.1', port: common.PORT }); -server.listen(common.PORT, common.localhostIP, function() { +server.listen(common.PORT, '127.0.0.1', function() { for (let i = 0; i < N; i++) { const options = { - host: common.localhostIP, + host: '127.0.0.1', port: common.PORT }; diff --git a/test/sequential/test-https-connect-localport.js b/test/sequential/test-https-connect-localport.js index 8ce98468a86c1a..e703fb2287d369 100644 --- a/test/sequential/test-https-connect-localport.js +++ b/test/sequential/test-https-connect-localport.js @@ -17,13 +17,13 @@ const assert = require('assert'); res.end(); })); - server.listen(0, common.localhostIP, common.mustCall(() => { + server.listen(0, 'localhost', common.mustCall(() => { const port = server.address().port; const req = https.get({ host: 'localhost', pathname: '/', port, - family: common.hasIPv6 ? 6 : 4, + family: 4, localPort: common.PORT, rejectUnauthorized: false, }, common.mustCall(() => { diff --git a/test/sequential/test-inspector-break-when-eval.js b/test/sequential/test-inspector-break-when-eval.js index 0172855569f794..0dd66588ed23b9 100644 --- a/test/sequential/test-inspector-break-when-eval.js +++ b/test/sequential/test-inspector-break-when-eval.js @@ -62,8 +62,7 @@ async function stepOverConsoleStatement(session) { async function runTests() { // NOTE(mmarchini): Use --inspect-brk to improve avoid undeterministic // behavior. - const child = new NodeInstance(['--inspect-brk=localhost:0'], - undefined, script); + const child = new NodeInstance(['--inspect-brk=0'], undefined, script); const session = await child.connectInspectorSession(); await setupDebugger(session); await breakOnLine(session); diff --git a/test/sequential/test-inspector-console.js b/test/sequential/test-inspector-console.js index 4722729b948470..bb0f0ce42a3d03 100644 --- a/test/sequential/test-inspector-console.js +++ b/test/sequential/test-inspector-console.js @@ -8,7 +8,7 @@ const assert = require('assert'); async function runTest() { const script = 'require(\'inspector\').console.log(\'hello world\');'; - const child = new NodeInstance('--inspect-brk=localhost:0', script, ''); + const child = new NodeInstance('--inspect-brk=0', script, ''); let out = ''; child.on('stdout', (line) => out += line); diff --git a/test/sequential/test-inspector-debug-brk-flag.js b/test/sequential/test-inspector-debug-brk-flag.js index 143faf617bdbff..f1312b47ad8d8b 100644 --- a/test/sequential/test-inspector-debug-brk-flag.js +++ b/test/sequential/test-inspector-debug-brk-flag.js @@ -27,8 +27,7 @@ async function testBreakpointOnStart(session) { } async function runTests() { - const child = new NodeInstance(['--inspect=localhost', - '--inspect-brk=localhost']); + const child = new NodeInstance(['--inspect', '--inspect-brk']); const session = await child.connectInspectorSession(); await testBreakpointOnStart(session); diff --git a/test/sequential/test-inspector-debug-end.js b/test/sequential/test-inspector-debug-end.js index d9252d0fc96286..f3e343a0dadb25 100644 --- a/test/sequential/test-inspector-debug-end.js +++ b/test/sequential/test-inspector-debug-end.js @@ -14,7 +14,7 @@ async function testNoServerNoCrash() { async function testNoSessionNoCrash() { console.log('Test there\'s no crash stopping server without connecting'); - const instance = new NodeInstance('--inspect=localhost:0', + const instance = new NodeInstance('--inspect=0', 'process._debugEnd();process.exit(42);'); strictEqual((await instance.expectShutdown()).exitCode, 42); } @@ -28,7 +28,7 @@ async function testSessionNoCrash() { process.exit(42); });`; - const instance = new NodeInstance('--inspect-brk=localhost:0', script); + const instance = new NodeInstance('--inspect-brk=0', script); const session = await instance.connectInspectorSession(); await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' }); await session.waitForServerDisconnect(); diff --git a/test/sequential/test-inspector-not-blocked-on-idle.js b/test/sequential/test-inspector-not-blocked-on-idle.js index 0a94a86ae74516..fbf26d15c91f12 100644 --- a/test/sequential/test-inspector-not-blocked-on-idle.js +++ b/test/sequential/test-inspector-not-blocked-on-idle.js @@ -5,7 +5,7 @@ const { NodeInstance } = require('../common/inspector-helper.js'); async function runTests() { const script = 'setInterval(() => {debugger;}, 60000);'; - const node = new NodeInstance('--inspect=localhost:0', script); + const node = new NodeInstance('--inspect=0', script); // 1 second wait to make sure the inferior began running the script await new Promise((resolve) => setTimeout(() => resolve(), 1000)); const session = await node.connectInspectorSession(); diff --git a/test/sequential/test-inspector-open.js b/test/sequential/test-inspector-open.js index 78ba3339e1c045..190a99e7282e52 100644 --- a/test/sequential/test-inspector-open.js +++ b/test/sequential/test-inspector-open.js @@ -98,10 +98,10 @@ function beChild() { process.on('message', (msg) => { if (msg.cmd === 'open') { if (msg.args[0] === kFirstOpen) { - inspector.open(0, 'localhost', undefined); + inspector.open(0, false, undefined); } else if (msg.args[0] === kOpenWhileOpen) { assert.throws(() => { - inspector.open(0, 'localhost', undefined); + inspector.open(0, false, undefined); }, { code: 'ERR_INSPECTOR_ALREADY_ACTIVATED' }); diff --git a/test/sequential/test-inspector-port-zero.js b/test/sequential/test-inspector-port-zero.js index 4f993d1083fe3d..1683394a1dd4a3 100644 --- a/test/sequential/test-inspector-port-zero.js +++ b/test/sequential/test-inspector-port-zero.js @@ -1,6 +1,5 @@ 'use strict'; const { mustCall, skipIfInspectorDisabled } = require('../common'); -const common = require('../common'); skipIfInspectorDisabled(); @@ -43,17 +42,14 @@ function test(arg, port = '') { test('--inspect=0'); test('--inspect=127.0.0.1:0'); -if (common.hasIPv6) test('--inspect=[::1]:0'); test('--inspect=localhost:0'); test('--inspect-brk=0'); test('--inspect-brk=127.0.0.1:0'); -if (common.hasIPv6) test('--inspect-brk=[::1]:0'); test('--inspect-brk=localhost:0'); // In these cases, the inspector doesn't listen, so an ephemeral port is not // allocated and the expected value of `process.debugPort` is `0`. test('--inspect-port=0', '0'); test('--inspect-port=127.0.0.1:0', '0'); -if (common.hasIPv6) test('--inspect-port=[::1]:0', '0'); test('--inspect-port=localhost:0', '0'); diff --git a/test/sequential/test-inspector-scriptparsed-context.js b/test/sequential/test-inspector-scriptparsed-context.js index bd0cc0b937245e..e656436879ce63 100644 --- a/test/sequential/test-inspector-scriptparsed-context.js +++ b/test/sequential/test-inspector-scriptparsed-context.js @@ -43,8 +43,7 @@ async function checkScriptContext(session, context) { } async function runTests() { - const instance = new NodeInstance(['--inspect-brk=localhost:0', - '--expose-internals'], + const instance = new NodeInstance(['--inspect-brk=0', '--expose-internals'], script); const session = await instance.connectInspectorSession(); await session.send([ diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 816a8ceeb330e1..f81884ecfd4e46 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -5,7 +5,7 @@ const assert = require('assert'); const { NodeInstance } = require('../common/inspector-helper.js'); async function runTests() { - const child = new NodeInstance(['--inspect-brk=localhost:0'], + const child = new NodeInstance(['--inspect-brk=0'], `let c = 0; const interval = setInterval(() => { console.log(new Object()); diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index e5531be1c3726c..ebe987d0443b6c 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -52,7 +52,7 @@ function server() { console.error('_socketEnd'); }); socket.write(content); - }).listen(common.PORT, common.localhostIP, function() { + }).listen(common.PORT, common.localhostIPv4, function() { console.log('listening'); }); } @@ -60,7 +60,7 @@ function server() { function client() { const net = require('net'); const client = net.connect({ - host: common.localhostIP, + host: common.localhostIPv4, port: common.PORT }, function() { client.destroy(); diff --git a/test/sequential/test-net-better-error-messages-port.js b/test/sequential/test-net-better-error-messages-port.js index c21427ee395139..e8756838063e72 100644 --- a/test/sequential/test-net-better-error-messages-port.js +++ b/test/sequential/test-net-better-error-messages-port.js @@ -10,5 +10,5 @@ c.on('connect', common.mustNotCall()); c.on('error', common.mustCall(function(e) { assert.strictEqual(e.code, 'ECONNREFUSED'); assert.strictEqual(e.port, common.PORT); - assert.match(e.address, /^(127\.0\.0\.1|::1)$/); + assert.match(e.address, '/^127\.0\.0\.1$|^::1$/'); })); diff --git a/test/sequential/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js index 5eabbff756e1cd..030c4de750cb4d 100644 --- a/test/sequential/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -10,8 +10,7 @@ const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; const optionsIPv4 = { port: common.PORT, localPort: common.PORT + 1, - localAddress: common.localhostIPv4, - family: 4, + localAddress: common.localhostIPv4 }; const optionsIPv6 = { @@ -19,7 +18,6 @@ const optionsIPv6 = { port: common.PORT + 2, localPort: common.PORT + 3, localAddress: '::1', - family: 6, }; function onError(err, options) { diff --git a/test/sequential/test-net-localport.js b/test/sequential/test-net-localport.js index a44b6411ee306f..e90df73e524b51 100644 --- a/test/sequential/test-net-localport.js +++ b/test/sequential/test-net-localport.js @@ -11,7 +11,7 @@ const server = net.createServer(function(socket) { }); }).listen(0).on('listening', function() { const client = net.connect({ - host: 'localhost', + host: '127.0.0.1', port: this.address().port, localPort: common.PORT, }).on('connect', function() { diff --git a/test/sequential/test-net-response-size.js b/test/sequential/test-net-response-size.js index b5d7ac2f994a0e..c5d7e9b600e05d 100644 --- a/test/sequential/test-net-response-size.js +++ b/test/sequential/test-net-response-size.js @@ -42,7 +42,7 @@ if (process.argv[2] === 'server') { }); }); - server.listen(common.PORT, 'localhost', function() { + server.listen(common.PORT, '127.0.0.1', function() { console.log('Server running.'); }); @@ -54,7 +54,7 @@ if (process.argv[2] === 'server') { serverProcess.stderr.pipe(process.stdout); serverProcess.stdout.once('data', function() { - const client = net.createConnection(common.PORT, 'localhost'); + const client = net.createConnection(common.PORT, '127.0.0.1'); client.on('connect', function() { const alot = Buffer.allocUnsafe(1024); const alittle = Buffer.allocUnsafe(1); From 4b0638304cac30ff6aa85645d76e158e6156f5af Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Tue, 16 Mar 2021 09:59:32 +0100 Subject: [PATCH 10/27] Update test-net-better-error-messages-port.js --- test/sequential/test-net-better-error-messages-port.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-net-better-error-messages-port.js b/test/sequential/test-net-better-error-messages-port.js index e8756838063e72..789b2e31801da1 100644 --- a/test/sequential/test-net-better-error-messages-port.js +++ b/test/sequential/test-net-better-error-messages-port.js @@ -10,5 +10,5 @@ c.on('connect', common.mustNotCall()); c.on('error', common.mustCall(function(e) { assert.strictEqual(e.code, 'ECONNREFUSED'); assert.strictEqual(e.port, common.PORT); - assert.match(e.address, '/^127\.0\.0\.1$|^::1$/'); + assert.strictEqual(e.address, '127.0.0.1'); })); From 6340f1320f7d897765034726a89ee3a8b999816b Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Tue, 16 Mar 2021 14:49:54 +0100 Subject: [PATCH 11/27] Test suite fixes. Hardcode localhost IPv4. --- test/common/inspector-helper.js | 3 ++- test/parallel/test-cluster-message.js | 2 +- test/parallel/test-http-localaddress.js | 1 + test/parallel/test-http-upgrade-client.js | 1 + test/parallel/test-http2-connect-options.js | 2 +- test/parallel/test-https-localaddress.js | 1 + test/parallel/test-net-dns-lookup.js | 2 +- test/parallel/test-net-remote-address-port.js | 6 +++--- test/parallel/test-tcp-wrap-listen.js | 2 +- ...imers-socket-timeout-removes-other-socket-unref-timer.js | 6 ++++-- test/parallel/test-tls-client-getephemeralkeyinfo.js | 1 + test/parallel/test-tls-client-mindhsize.js | 1 + test/parallel/test-tls-wrap-econnreset-localaddress.js | 1 + test/sequential/test-https-connect-localport.js | 2 +- test/sequential/test-inspector-open.js | 2 +- test/sequential/test-net-better-error-messages-port.js | 2 +- test/sequential/test-net-connect-local-error.js | 4 +++- 17 files changed, 25 insertions(+), 14 deletions(-) diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index 666624490e79a9..a55828338222ef 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -393,7 +393,7 @@ class NodeInstance extends EventEmitter { console.log('[test]', `Testing ${path}`); const headers = hostHeaderValue ? { 'Host': hostHeaderValue } : null; return this.portPromise.then((port) => new Promise((resolve, reject) => { - const req = http.get({ host, port, path, headers }, (res) => { + const req = http.get({ host, family: 4, port, path, headers }, (res) => { let response = ''; res.setEncoding('utf8'); res @@ -418,6 +418,7 @@ class NodeInstance extends EventEmitter { const devtoolsUrl = response[0].webSocketDebuggerUrl; const port = await this.portPromise; return http.get({ + family: 4, port, path: parseURL(devtoolsUrl).path, headers: { diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js index 45854c77a5a347..5b1c2901b1a9ca 100644 --- a/test/parallel/test-cluster-message.js +++ b/test/parallel/test-cluster-message.js @@ -111,7 +111,7 @@ if (cluster.isWorker) { // When a TCP server is listening in the worker connect to it worker.on('listening', function(address) { - client = net.connect(address.port, function() { + client = net.connect(address.port, '127.0.0.1', function() { // Send message to worker. worker.send('message from primary'); }); diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index e237c3bff1ac84..d45b53f7dbeb00 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -41,6 +41,7 @@ const server = http.createServer((req, res) => { server.listen(0, '127.0.0.1', () => { const options = { host: 'localhost', + family: 4, port: server.address().port, path: '/', method: 'GET', diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js index 8fe756f469f09a..7a7d7e02f261a6 100644 --- a/test/parallel/test-http-upgrade-client.js +++ b/test/parallel/test-http-upgrade-client.js @@ -67,6 +67,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { headers.forEach(function(h) { const req = http.get({ + host: '127.0.0.1', port: port, headers: h }); diff --git a/test/parallel/test-http2-connect-options.js b/test/parallel/test-http2-connect-options.js index 0c7ec807b84d38..0ab5c6983cc28b 100644 --- a/test/parallel/test-http2-connect-options.js +++ b/test/parallel/test-http2-connect-options.js @@ -25,7 +25,7 @@ server.listen(0, '127.0.0.1', common.mustCall(() => { const options = { localAddress: '127.0.0.2' }; const client = http2.connect( - 'http://localhost:' + server.address().port, + 'http://127.0.0.1:' + server.address().port, options ); const req = client.request({ diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index 0ac8414b2d4b35..f138c36b64f494 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -51,6 +51,7 @@ const server = https.createServer(options, function(req, res) { server.listen(0, '127.0.0.1', function() { const options = { host: 'localhost', + family: 4, port: this.address().port, path: '/', method: 'GET', diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 53052de716ee9e..09bdac898db188 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -30,7 +30,7 @@ const server = net.createServer(function(client) { }); server.listen(0, '127.0.0.1', common.mustCall(function() { - net.connect(this.address().port, 'localhost') + net.connect({ port: this.address().port, host: 'localhost', family: 4 }) .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); assert.strictEqual(ip, '127.0.0.1'); diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 094206f85df34d..ef6ead635f7534 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -48,9 +48,9 @@ const server = net.createServer(common.mustCall(function(socket) { socket.resume(); }, 2)); -server.listen(0, 'localhost', function() { - const client = net.createConnection(this.address().port, 'localhost'); - const client2 = net.createConnection(this.address().port); +server.listen(0, '127.0.0.1', function() { + const client = net.createConnection(this.address().port, '127.0.0.1'); + const client2 = net.createConnection(this.address().port, '127.0.0.1'); client.on('connect', function() { assert.ok(remoteAddrCandidates.includes(client.remoteAddress)); assert.ok(remoteFamilyCandidates.includes(client.remoteFamily)); diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index 72981b683ccea3..9c24179a34b1ae 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -84,7 +84,7 @@ server.onconnection = (err, client) => { const net = require('net'); -const c = net.createConnection(port); +const c = net.createConnection(port, '127.0.0.1'); c.on('connect', common.mustCall(() => { c.end('hello world'); })); diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js index ccecfe4c63a6a1..def50194a778e8 100644 --- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -32,12 +32,14 @@ server.listen(0, common.localhostIPv4, common.mustCall(() => { const countdown = new Countdown(2, () => server.close()); { - const client = net.connect({ port: server.address().port }); + const client = net.connect({ port: server.address().port, + host: '127.0.0.1' }); client.on('end', () => countdown.dec()); } { - const client = net.connect({ port: server.address().port }); + const client = net.connect({ port: server.address().port, + host: '127.0.0.1' }); client.on('end', () => countdown.dec()); } })); diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js index 73ac215102ddbb..4473ccfe3fa3d6 100644 --- a/test/parallel/test-tls-client-getephemeralkeyinfo.js +++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js @@ -40,6 +40,7 @@ function test(size, type, name, cipher) { server.listen(0, '127.0.0.1', common.mustCall(() => { const client = tls.connect({ port: server.address().port, + host: '127.0.0.1', rejectUnauthorized: false }, common.mustCall(function() { const ekeyinfo = client.getEphemeralKeyInfo(); diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index a6fbc67bd88361..e90a2a2d623c9d 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -41,6 +41,7 @@ function test(size, err, next) { const client = tls.connect({ minDHSize: 2048, port: this.address().port, + host: '127.0.0.1', rejectUnauthorized: false }, function() { nsuccess++; diff --git a/test/parallel/test-tls-wrap-econnreset-localaddress.js b/test/parallel/test-tls-wrap-econnreset-localaddress.js index 30d3a8873fa8f0..b51ddb29ba8b55 100644 --- a/test/parallel/test-tls-wrap-econnreset-localaddress.js +++ b/test/parallel/test-tls-wrap-econnreset-localaddress.js @@ -16,6 +16,7 @@ const server = net.createServer((c) => { let errored = false; tls.connect({ port: port, + family: 4, localAddress: common.localhostIPv4 }, common.localhostIPv4) .once('error', common.mustCall((e) => { diff --git a/test/sequential/test-https-connect-localport.js b/test/sequential/test-https-connect-localport.js index e703fb2287d369..10d358c8a92146 100644 --- a/test/sequential/test-https-connect-localport.js +++ b/test/sequential/test-https-connect-localport.js @@ -17,7 +17,7 @@ const assert = require('assert'); res.end(); })); - server.listen(0, 'localhost', common.mustCall(() => { + server.listen(0, '127.0.0.1', common.mustCall(() => { const port = server.address().port; const req = https.get({ host: 'localhost', diff --git a/test/sequential/test-inspector-open.js b/test/sequential/test-inspector-open.js index 190a99e7282e52..f0f8d2d07d1d03 100644 --- a/test/sequential/test-inspector-open.js +++ b/test/sequential/test-inspector-open.js @@ -80,7 +80,7 @@ function reopenAfterClose(msg) { } function ping(port, callback) { - net.connect(port) + net.connect(port, '127.0.0.1') .on('connect', function() { close(this); }) .on('error', function(err) { close(this, err); }); diff --git a/test/sequential/test-net-better-error-messages-port.js b/test/sequential/test-net-better-error-messages-port.js index 789b2e31801da1..1238633c506a39 100644 --- a/test/sequential/test-net-better-error-messages-port.js +++ b/test/sequential/test-net-better-error-messages-port.js @@ -3,7 +3,7 @@ const common = require('../common'); const net = require('net'); const assert = require('assert'); -const c = net.createConnection(common.PORT); +const c = net.createConnection(common.PORT, common.localhostIPv4); c.on('connect', common.mustNotCall()); diff --git a/test/sequential/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js index 030c4de750cb4d..ecf58fc3b197f8 100644 --- a/test/sequential/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -10,7 +10,8 @@ const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; const optionsIPv4 = { port: common.PORT, localPort: common.PORT + 1, - localAddress: common.localhostIPv4 + localAddress: common.localhostIPv4, + family: 4 }; const optionsIPv6 = { @@ -18,6 +19,7 @@ const optionsIPv6 = { port: common.PORT + 2, localPort: common.PORT + 3, localAddress: '::1', + family: 6 }; function onError(err, options) { From 2f7edf00c2e55be4ac970fd2e372c1ad805289c5 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Tue, 16 Mar 2021 20:24:07 +0100 Subject: [PATCH 12/27] More localhost/127.0.0.1 fixes. --- test/parallel/test-net-connect-options-port.js | 14 +++++++------- test/parallel/test-net-pingpong.js | 8 +++----- test/parallel/test-net-writable.js | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-net-connect-options-port.js b/test/parallel/test-net-connect-options-port.js index 74e78240abb5ba..d0529c208770fb 100644 --- a/test/parallel/test-net-connect-options-port.js +++ b/test/parallel/test-net-connect-options-port.js @@ -83,7 +83,7 @@ const net = require('net'); } }, expectedConnections)); - server.listen(0, 'localhost', common.mustCall(() => { + server.listen(0, '127.0.0.1', common.mustCall(() => { const port = server.address().port; // Total connections = 3 * 4(canConnect) * 6(doConnect) = 72 @@ -167,25 +167,25 @@ function canConnect(port) { const noop = () => common.mustCall(); // connect(port, cb) and connect(port) - const portArgFunctions = doConnect([port], noop); + const portArgFunctions = doConnect([port, '127.0.0.1'], noop); for (const fn of portArgFunctions) { fn(); } // connect(port, host, cb) and connect(port, host) - const portHostArgFunctions = doConnect([port, 'localhost'], noop); + const portHostArgFunctions = doConnect([port, '127.0.0.1'], noop); for (const fn of portHostArgFunctions) { fn(); } // connect({port}, cb) and connect({port}) - const portOptFunctions = doConnect([{ port }], noop); + const portOptFunctions = doConnect([{ port, family: 4 }], noop); for (const fn of portOptFunctions) { fn(); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptFns = doConnect([{ port, host: 'localhost' }], noop); + const portHostOptFns = doConnect([{ port, host: '127.0.0.1' }], noop); for (const fn of portHostOptFns) { fn(); } @@ -205,13 +205,13 @@ function asyncFailToConnect(port) { } // connect({port}, cb) and connect({port}) - const portOptFunctions = doConnect([{ port }], dont); + const portOptFunctions = doConnect([{ port, family: 4 }], dont); for (const fn of portOptFunctions) { fn().on('error', onError()); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptFns = doConnect([{ port, host: 'localhost' }], dont); + const portHostOptFns = doConnect([{ port, host: '127.0.0.1' }], dont); for (const fn of portHostOptFns) { fn().on('error', onError()); } diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index 7fb6678fe1a897..dde946adb84aea 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -81,11 +81,11 @@ function pingPongTest(port, host) { } - server.listen(port, host, common.mustCall(function() { + server.listen(port, '127.0.0.1', common.mustCall(function() { if (this.address().port) port = this.address().port; - const client = net.createConnection(port, host); + const client = net.createConnection(port, '127.0.0.1'); client.setEncoding('ascii'); client.on('connect', common.mustCall(function() { @@ -130,6 +130,4 @@ const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); pingPongTest(common.PIPE); pingPongTest(0); -pingPongTest(0, 'localhost'); -if (common.hasIPv6) - pingPongTest(0, '::1'); +pingPongTest(0, '127.0.0.1'); diff --git a/test/parallel/test-net-writable.js b/test/parallel/test-net-writable.js index dcbb64e272b830..3659869efbb715 100644 --- a/test/parallel/test-net-writable.js +++ b/test/parallel/test-net-writable.js @@ -6,8 +6,8 @@ const net = require('net'); const server = net.createServer(common.mustCall(function(s) { server.close(); s.end(); -})).listen(0, 'localhost', common.mustCall(function() { - const socket = net.connect(this.address().port, 'localhost'); +})).listen(0, '127.0.0.1', common.mustCall(function() { + const socket = net.connect(this.address().port, '127.0.0.1'); socket.on('end', common.mustCall(() => { assert.strictEqual(socket.writable, true); socket.write('hello world'); From 75bd95930b85a1b70322461db334d3aadb9fc171 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 17 Mar 2021 00:01:50 +0100 Subject: [PATCH 13/27] Update test-net-pingpong.js --- test/parallel/test-net-pingpong.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index dde946adb84aea..b1fd2290d0f100 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -81,11 +81,11 @@ function pingPongTest(port, host) { } - server.listen(port, '127.0.0.1', common.mustCall(function() { + server.listen(port, host, common.mustCall(function() { if (this.address().port) port = this.address().port; - const client = net.createConnection(port, '127.0.0.1'); + const client = net.createConnection(port, host); client.setEncoding('ascii'); client.on('connect', common.mustCall(function() { @@ -131,3 +131,5 @@ tmpdir.refresh(); pingPongTest(common.PIPE); pingPongTest(0); pingPongTest(0, '127.0.0.1'); +if (common.hasIPv6) + pingPongTest(0, '::1'); From a19f8ec28a815cc321574aeaad0536720aaa5d6c Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Sat, 20 Mar 2021 18:06:40 +0100 Subject: [PATCH 14/27] Update test/parallel/test-net-writable.js Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> --- test/parallel/test-net-writable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-net-writable.js b/test/parallel/test-net-writable.js index 3659869efbb715..dcbb64e272b830 100644 --- a/test/parallel/test-net-writable.js +++ b/test/parallel/test-net-writable.js @@ -6,8 +6,8 @@ const net = require('net'); const server = net.createServer(common.mustCall(function(s) { server.close(); s.end(); -})).listen(0, '127.0.0.1', common.mustCall(function() { - const socket = net.connect(this.address().port, '127.0.0.1'); +})).listen(0, 'localhost', common.mustCall(function() { + const socket = net.connect(this.address().port, 'localhost'); socket.on('end', common.mustCall(() => { assert.strictEqual(socket.writable, true); socket.write('hello world'); From 0232a4a8e2a796db98920539b097aa143db5d8cc Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 09:18:15 +0100 Subject: [PATCH 15/27] Update test-net-writable.js --- test/parallel/test-net-writable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-writable.js b/test/parallel/test-net-writable.js index dcbb64e272b830..bc956297842f0e 100644 --- a/test/parallel/test-net-writable.js +++ b/test/parallel/test-net-writable.js @@ -6,7 +6,7 @@ const net = require('net'); const server = net.createServer(common.mustCall(function(s) { server.close(); s.end(); -})).listen(0, 'localhost', common.mustCall(function() { +})).listen(0, '127.0.0.1', common.mustCall(function() { const socket = net.connect(this.address().port, 'localhost'); socket.on('end', common.mustCall(() => { assert.strictEqual(socket.writable, true); From 2ef88c7905bdb3be3e4006c640c9532e79dd2994 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 11:11:26 +0100 Subject: [PATCH 16/27] Update test-net-writable.js --- test/parallel/test-net-writable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-writable.js b/test/parallel/test-net-writable.js index bc956297842f0e..3659869efbb715 100644 --- a/test/parallel/test-net-writable.js +++ b/test/parallel/test-net-writable.js @@ -7,7 +7,7 @@ const server = net.createServer(common.mustCall(function(s) { server.close(); s.end(); })).listen(0, '127.0.0.1', common.mustCall(function() { - const socket = net.connect(this.address().port, 'localhost'); + const socket = net.connect(this.address().port, '127.0.0.1'); socket.on('end', common.mustCall(() => { assert.strictEqual(socket.writable, true); socket.write('hello world'); From 98b3ffbaf1ec10d99c1f44189ba0a9b4aa0b3531 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 11:11:55 +0100 Subject: [PATCH 17/27] Update test-net-writable.js --- test/parallel/test-net-writable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-writable.js b/test/parallel/test-net-writable.js index 3659869efbb715..6ff8d926909360 100644 --- a/test/parallel/test-net-writable.js +++ b/test/parallel/test-net-writable.js @@ -6,7 +6,7 @@ const net = require('net'); const server = net.createServer(common.mustCall(function(s) { server.close(); s.end(); -})).listen(0, '127.0.0.1', common.mustCall(function() { +})).listen(0, 'localhost', common.mustCall(function() { const socket = net.connect(this.address().port, '127.0.0.1'); socket.on('end', common.mustCall(() => { assert.strictEqual(socket.writable, true); From 7a0e447842eacc0f16772f9bb2513e7b3e804ce4 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 13:43:53 +0100 Subject: [PATCH 18/27] Update test-net-writable.js --- test/parallel/test-net-writable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-net-writable.js b/test/parallel/test-net-writable.js index 6ff8d926909360..1002247889cc51 100644 --- a/test/parallel/test-net-writable.js +++ b/test/parallel/test-net-writable.js @@ -6,8 +6,8 @@ const net = require('net'); const server = net.createServer(common.mustCall(function(s) { server.close(); s.end(); -})).listen(0, 'localhost', common.mustCall(function() { - const socket = net.connect(this.address().port, '127.0.0.1'); +})).listen(0, common.mustCall(function() { + const socket = net.connect(this.address().port); socket.on('end', common.mustCall(() => { assert.strictEqual(socket.writable, true); socket.write('hello world'); From 5037efc558e2b817764bb052d43995d2405e1438 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 16:20:39 +0100 Subject: [PATCH 19/27] Update parallel.status --- test/parallel/parallel.status | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index c69008fde4aabb..cb86f7bd5124cb 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -22,6 +22,8 @@ test-crypto-dh-stateless: SKIP test-crypto-keygen: SKIP [$system==solaris] # Also applies to SmartOS +# https://github.com/nodejs/node/pull/37681 +test/parallel/test-net-writable.js: PASS,FLAKY [$system==freebsd] # https://github.com/nodejs/node/issues/31727 From 787dc692f30ec18c4f01014ea5d2c6a40cf45d76 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 16:28:55 +0100 Subject: [PATCH 20/27] Update test-net-connect-options-port.js --- test/parallel/test-net-connect-options-port.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-connect-options-port.js b/test/parallel/test-net-connect-options-port.js index d0529c208770fb..74e78240abb5ba 100644 --- a/test/parallel/test-net-connect-options-port.js +++ b/test/parallel/test-net-connect-options-port.js @@ -83,7 +83,7 @@ const net = require('net'); } }, expectedConnections)); - server.listen(0, '127.0.0.1', common.mustCall(() => { + server.listen(0, 'localhost', common.mustCall(() => { const port = server.address().port; // Total connections = 3 * 4(canConnect) * 6(doConnect) = 72 @@ -167,25 +167,25 @@ function canConnect(port) { const noop = () => common.mustCall(); // connect(port, cb) and connect(port) - const portArgFunctions = doConnect([port, '127.0.0.1'], noop); + const portArgFunctions = doConnect([port], noop); for (const fn of portArgFunctions) { fn(); } // connect(port, host, cb) and connect(port, host) - const portHostArgFunctions = doConnect([port, '127.0.0.1'], noop); + const portHostArgFunctions = doConnect([port, 'localhost'], noop); for (const fn of portHostArgFunctions) { fn(); } // connect({port}, cb) and connect({port}) - const portOptFunctions = doConnect([{ port, family: 4 }], noop); + const portOptFunctions = doConnect([{ port }], noop); for (const fn of portOptFunctions) { fn(); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptFns = doConnect([{ port, host: '127.0.0.1' }], noop); + const portHostOptFns = doConnect([{ port, host: 'localhost' }], noop); for (const fn of portHostOptFns) { fn(); } @@ -205,13 +205,13 @@ function asyncFailToConnect(port) { } // connect({port}, cb) and connect({port}) - const portOptFunctions = doConnect([{ port, family: 4 }], dont); + const portOptFunctions = doConnect([{ port }], dont); for (const fn of portOptFunctions) { fn().on('error', onError()); } // connect({port, host}, cb) and connect({port, host}) - const portHostOptFns = doConnect([{ port, host: '127.0.0.1' }], dont); + const portHostOptFns = doConnect([{ port, host: 'localhost' }], dont); for (const fn of portHostOptFns) { fn().on('error', onError()); } From 26f7f458a23802cdc9f2b4dd7f55ba3fb90f2c9e Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 16:30:00 +0100 Subject: [PATCH 21/27] Update parallel.status --- test/parallel/parallel.status | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index cb86f7bd5124cb..7eb524d7f95eeb 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -23,7 +23,8 @@ test-crypto-keygen: SKIP [$system==solaris] # Also applies to SmartOS # https://github.com/nodejs/node/pull/37681 -test/parallel/test-net-writable.js: PASS,FLAKY +test/parallel/test-net-writable: PASS,FLAKY +test/parallel/test-net-connect-options-port: PASS,FLAKY [$system==freebsd] # https://github.com/nodejs/node/issues/31727 From 269eda7d4d51905ae18ea1462bce0540493a7427 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 17:10:05 +0100 Subject: [PATCH 22/27] Update test-net-connect-options-port.js --- test/parallel/test-net-connect-options-port.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-connect-options-port.js b/test/parallel/test-net-connect-options-port.js index 74e78240abb5ba..42eaa5cd4f1d68 100644 --- a/test/parallel/test-net-connect-options-port.js +++ b/test/parallel/test-net-connect-options-port.js @@ -83,7 +83,7 @@ const net = require('net'); } }, expectedConnections)); - server.listen(0, 'localhost', common.mustCall(() => { + server.listen(0, common.mustCall(() => { const port = server.address().port; // Total connections = 3 * 4(canConnect) * 6(doConnect) = 72 From 1928b442f0c11b3fad003f3767b1ee424a75b603 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Wed, 24 Mar 2021 17:10:25 +0100 Subject: [PATCH 23/27] Update parallel.status --- test/parallel/parallel.status | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 7eb524d7f95eeb..d41b668eecf4c4 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -23,8 +23,8 @@ test-crypto-keygen: SKIP [$system==solaris] # Also applies to SmartOS # https://github.com/nodejs/node/pull/37681 -test/parallel/test-net-writable: PASS,FLAKY -test/parallel/test-net-connect-options-port: PASS,FLAKY +test-net-writable: PASS,FLAKY +test-net-connect-options-port: PASS,FLAKY [$system==freebsd] # https://github.com/nodejs/node/issues/31727 From 5557b85b6749fc20e003e054e7017eda7d19dc4e Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Thu, 25 Mar 2021 16:39:43 +0100 Subject: [PATCH 24/27] Updated from review --- test/parallel/parallel.status | 1 + test/parallel/test-net-pingpong.js | 2 +- test/sequential/test-net-connect-local-error.js | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index d41b668eecf4c4..26704196518f88 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -25,6 +25,7 @@ test-crypto-keygen: SKIP # https://github.com/nodejs/node/pull/37681 test-net-writable: PASS,FLAKY test-net-connect-options-port: PASS,FLAKY +test-net-pingpong: PASS,FLAKY [$system==freebsd] # https://github.com/nodejs/node/issues/31727 diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index b1fd2290d0f100..7fb6678fe1a897 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -130,6 +130,6 @@ const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); pingPongTest(common.PIPE); pingPongTest(0); -pingPongTest(0, '127.0.0.1'); +pingPongTest(0, 'localhost'); if (common.hasIPv6) pingPongTest(0, '::1'); diff --git a/test/sequential/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js index ecf58fc3b197f8..a1f2ab0c679b44 100644 --- a/test/sequential/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -8,10 +8,11 @@ const net = require('net'); const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; const optionsIPv4 = { + host: common.localhostIPv4, port: common.PORT, localPort: common.PORT + 1, localAddress: common.localhostIPv4, - family: 4 + family: 4, }; const optionsIPv6 = { @@ -19,7 +20,7 @@ const optionsIPv6 = { port: common.PORT + 2, localPort: common.PORT + 3, localAddress: '::1', - family: 6 + family: 6, }; function onError(err, options) { From bccf676b1c7144140bbd61911b46a850beb48295 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Fri, 26 Mar 2021 16:14:40 +0100 Subject: [PATCH 25/27] Update test-net-remote-address-port.js --- test/parallel/test-net-remote-address-port.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index ef6ead635f7534..e096f02ff46220 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -28,7 +28,7 @@ const net = require('net'); let conns_closed = 0; const remoteAddrCandidates = [ common.localhostIPv4 ]; -if (common.hasIPv6) remoteAddrCandidates.push('::ffff:127.0.0.1'); +if (common.hasIPv6) remoteAddrCandidates.push('::1', '::ffff:127.0.0.1'); const remoteFamilyCandidates = ['IPv4']; if (common.hasIPv6) remoteFamilyCandidates.push('IPv6'); From 0c8be88f01ef1b750c3b1e5739101f120e7ea23b Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Fri, 26 Mar 2021 16:15:05 +0100 Subject: [PATCH 26/27] Update test/parallel/test-net-remote-address-port.js Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> --- test/parallel/test-net-remote-address-port.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index e096f02ff46220..cc14d0c951167d 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -48,9 +48,9 @@ const server = net.createServer(common.mustCall(function(socket) { socket.resume(); }, 2)); -server.listen(0, '127.0.0.1', function() { - const client = net.createConnection(this.address().port, '127.0.0.1'); - const client2 = net.createConnection(this.address().port, '127.0.0.1'); +server.listen(0, 'localhost', function() { + const client = net.createConnection(this.address().port, 'localhost'); + const client2 = net.createConnection(this.address().port); client.on('connect', function() { assert.ok(remoteAddrCandidates.includes(client.remoteAddress)); assert.ok(remoteFamilyCandidates.includes(client.remoteFamily)); From 7cae4096fc942f74528a0843c4978f024509cb41 Mon Sep 17 00:00:00 2001 From: treysis <treysis@gmx.net> Date: Fri, 26 Mar 2021 16:17:06 +0100 Subject: [PATCH 27/27] Update test-net-better-error-messages-port.js --- test/sequential/test-net-better-error-messages-port.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-net-better-error-messages-port.js b/test/sequential/test-net-better-error-messages-port.js index 1238633c506a39..c21427ee395139 100644 --- a/test/sequential/test-net-better-error-messages-port.js +++ b/test/sequential/test-net-better-error-messages-port.js @@ -3,12 +3,12 @@ const common = require('../common'); const net = require('net'); const assert = require('assert'); -const c = net.createConnection(common.PORT, common.localhostIPv4); +const c = net.createConnection(common.PORT); c.on('connect', common.mustNotCall()); c.on('error', common.mustCall(function(e) { assert.strictEqual(e.code, 'ECONNREFUSED'); assert.strictEqual(e.port, common.PORT); - assert.strictEqual(e.address, '127.0.0.1'); + assert.match(e.address, /^(127\.0\.0\.1|::1)$/); }));