diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 507ef307e60f92..f0711531809868 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2943,6 +2943,9 @@ deprecated and should no longer be used. -Type: Runtime +Type: End-of-Life Using a non-nullish non-integer value for `family` option, a non-nullish non-number value for `hints` option, a non-nullish non-boolean value for `all` option, or a non-nullish non-boolean value for `verbatim` option in -[`dns.lookup()`][] and [`dnsPromises.lookup()`][] is deprecated. +[`dns.lookup()`][] and [`dnsPromises.lookup()`][] throws an +`ERR_INVALID_ARG_TYPE` error. ### DEP0154: RSA-PSS generate key pair options diff --git a/lib/dns.js b/lib/dns.js index 14937769d1d4d9..af5416c62478cc 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -42,7 +42,6 @@ const { Resolver, validateHints, emitInvalidHostnameWarning, - emitTypeCoercionDeprecationWarning, getDefaultVerbatim, setDefaultResultOrder, } = require('internal/dns/utils'); @@ -52,10 +51,12 @@ const { ERR_MISSING_ARGS, } = errors.codes; const { + validateBoolean, validateFunction, + validateNumber, + validateOneOf, validatePort, validateString, - validateOneOf, } = require('internal/validators'); const { @@ -107,9 +108,10 @@ function onlookupall(err, addresses) { // Easy DNS A/AAAA look up // lookup(hostname, [options,] callback) +const validFamilies = [0, 4, 6]; function lookup(hostname, options, callback) { let hints = 0; - let family = -1; + let family = 0; let all = false; let verbatim = getDefaultVerbatim(); @@ -121,39 +123,36 @@ function lookup(hostname, options, callback) { if (typeof options === 'function') { callback = options; family = 0; + } else if (typeof options === 'number') { + validateFunction(callback, 'callback'); + + validateOneOf(options, 'family', validFamilies, true); + family = options; + } else if (options !== undefined && typeof options !== 'object') { + validateFunction(arguments.length === 2 ? options : callback, 'callback'); + throw new ERR_INVALID_ARG_TYPE('options', ['integer', 'object'], options); } else { validateFunction(callback, 'callback'); - if (options !== null && typeof options === 'object') { - if (options.hints != null && typeof options.hints !== 'number') { - emitTypeCoercionDeprecationWarning(); - } + if (options?.hints != null) { + validateNumber(options.hints, 'options.hints'); hints = options.hints >>> 0; - if (options.family != null && typeof options.family !== 'number') { - emitTypeCoercionDeprecationWarning(); - } - family = options.family >>> 0; - if (options.all != null && typeof options.all !== 'boolean') { - emitTypeCoercionDeprecationWarning(); - } - all = options.all === true; - if (typeof options.verbatim === 'boolean') { - verbatim = options.verbatim === true; - } else if (options.verbatim != null) { - emitTypeCoercionDeprecationWarning(); - } - validateHints(hints); - } else { - if (options != null && typeof options !== 'number') { - emitTypeCoercionDeprecationWarning(); - } - family = options >>> 0; + } + if (options?.family != null) { + validateOneOf(options.family, 'options.family', validFamilies, true); + family = options.family; + } + if (options?.all != null) { + validateBoolean(options.all, 'options.all'); + all = options.all; + } + if (options?.verbatim != null) { + validateBoolean(options.verbatim, 'options.verbatim'); + verbatim = options.verbatim; } } - validateOneOf(family, 'family', [0, 4, 6]); - if (!hostname) { emitInvalidHostnameWarning(hostname); if (all) { diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 68fcb29745e92d..9625e9e7b9b6ea 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -15,7 +15,6 @@ const { validateTimeout, validateTries, emitInvalidHostnameWarning, - emitTypeCoercionDeprecationWarning, getDefaultVerbatim, } = require('internal/dns/utils'); const { codes, dnsException } = require('internal/errors'); @@ -30,13 +29,16 @@ const { QueryReqWrap } = internalBinding('cares_wrap'); const { + ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_MISSING_ARGS, } = codes; const { + validateBoolean, + validateNumber, + validateOneOf, validatePort, validateString, - validateOneOf, } = require('internal/validators'); const kPerfHooksDnsLookupContext = Symbol('kPerfHooksDnsLookupContext'); @@ -120,9 +122,10 @@ function createLookupPromise(family, hostname, all, hints, verbatim) { }); } +const validFamilies = [0, 4, 6]; function lookup(hostname, options) { let hints = 0; - let family = -1; + let family = 0; let all = false; let verbatim = getDefaultVerbatim(); @@ -131,35 +134,31 @@ function lookup(hostname, options) { validateString(hostname, 'hostname'); } - if (options !== null && typeof options === 'object') { - if (options.hints != null && typeof options.hints !== 'number') { - emitTypeCoercionDeprecationWarning(); + if (typeof options === 'number') { + validateOneOf(options, 'family', validFamilies, true); + family = options; + } else if (options !== undefined && typeof options !== 'object') { + throw new ERR_INVALID_ARG_TYPE('options', ['integer', 'object'], options); + } else { + if (options?.hints != null) { + validateNumber(options.hints, 'options.hints'); + hints = options.hints >>> 0; + validateHints(hints); } - hints = options.hints >>> 0; - if (options.family != null && typeof options.family !== 'number') { - emitTypeCoercionDeprecationWarning(); + if (options?.family != null) { + validateOneOf(options.family, 'options.family', validFamilies, true); + family = options.family; } - family = options.family >>> 0; - if (options.all != null && typeof options.all !== 'boolean') { - emitTypeCoercionDeprecationWarning(); + if (options?.all != null) { + validateBoolean(options.all, 'options.all'); + all = options.all; } - all = options.all === true; - if (typeof options.verbatim === 'boolean') { - verbatim = options.verbatim === true; - } else if (options.verbatim != null) { - emitTypeCoercionDeprecationWarning(); + if (options?.verbatim != null) { + validateBoolean(options.verbatim, 'options.verbatim'); + verbatim = options.verbatim; } - - validateHints(hints); - } else { - if (options != null && typeof options !== 'number') { - emitTypeCoercionDeprecationWarning(); - } - family = options >>> 0; } - validateOneOf(family, 'family', [0, 4, 6], true); - return createLookupPromise(family, hostname, all, hints, verbatim); } diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 58d3eaafcaa6c9..62606e6f7f0aaf 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -190,18 +190,6 @@ function emitInvalidHostnameWarning(hostname) { } } -let typeCoercionWarningEmitted = false; -function emitTypeCoercionDeprecationWarning() { - if (!typeCoercionWarningEmitted) { - process.emitWarning( - 'Type coercion of dns.lookup options is deprecated', - 'DeprecationWarning', - 'DEP0153' - ); - typeCoercionWarningEmitted = true; - } -} - let dnsOrder = getOptionValue('--dns-result-order') || 'verbatim'; function getDefaultVerbatim() { @@ -222,7 +210,6 @@ module.exports = { validateTries, Resolver, emitInvalidHostnameWarning, - emitTypeCoercionDeprecationWarning, getDefaultVerbatim, setDefaultResultOrder, }; diff --git a/lib/net.js b/lib/net.js index d05fa64e78aa76..1c98cf4820178f 100644 --- a/lib/net.js +++ b/lib/net.js @@ -760,7 +760,7 @@ protoGetter('remoteAddress', function remoteAddress() { }); protoGetter('remoteFamily', function remoteFamily() { - return this._getpeername().family; + return `IPv${this._getpeername().family}`; }); protoGetter('remotePort', function remotePort() { diff --git a/lib/os.js b/lib/os.js index c1c4bfa694a06b..862d6bb4a2bec9 100644 --- a/lib/os.js +++ b/lib/os.js @@ -216,7 +216,7 @@ function getCIDR(address, netmask, family) { let groupLength = 8; let hasZeros = false; - if (family === 'IPv6') { + if (family === 6) { split = ':'; range = 16; groupLength = 16; @@ -248,7 +248,7 @@ function getCIDR(address, netmask, family) { * @returns {Record& args) { char ip[INET6_ADDRSTRLEN]; char netmask[INET6_ADDRSTRLEN]; std::array mac; - Local name, family; + Local name; + Local family; int err = uv_interface_addresses(&interfaces, &count); @@ -214,14 +215,14 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { if (interfaces[i].address.address4.sin_family == AF_INET) { uv_ip4_name(&interfaces[i].address.address4, ip, sizeof(ip)); uv_ip4_name(&interfaces[i].netmask.netmask4, netmask, sizeof(netmask)); - family = env->ipv4_string(); + family = Integer::New(env->isolate(), 4); } else if (interfaces[i].address.address4.sin_family == AF_INET6) { uv_ip6_name(&interfaces[i].address.address6, ip, sizeof(ip)); uv_ip6_name(&interfaces[i].netmask.netmask6, netmask, sizeof(netmask)); - family = env->ipv6_string(); + family = Integer::New(env->isolate(), 6); } else { strncpy(ip, "", INET6_ADDRSTRLEN); - family = env->unknown_string(); + family = Integer::New(env->isolate(), 0); } result.emplace_back(name); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 538f0355491c4a..747d3e028c23cc 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -380,7 +380,7 @@ MaybeLocal AddressToJS(Environment* env, OneByteString(env->isolate(), ip)).Check(); info->Set(env->context(), env->family_string(), - env->ipv6_string()).Check(); + Integer::New(env->isolate(), 6)).Check(); info->Set(env->context(), env->port_string(), Integer::New(env->isolate(), port)).Check(); @@ -395,7 +395,7 @@ MaybeLocal AddressToJS(Environment* env, OneByteString(env->isolate(), ip)).Check(); info->Set(env->context(), env->family_string(), - env->ipv4_string()).Check(); + Integer::New(env->isolate(), 4)).Check(); info->Set(env->context(), env->port_string(), Integer::New(env->isolate(), port)).Check(); diff --git a/test/common/index.js b/test/common/index.js index 8aee35758374c1..29e17615cc21ef 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -845,7 +845,7 @@ const common = { const re = isWindows ? /Loopback Pseudo-Interface/ : /lo/; return Object.keys(iFaces).some((name) => { return re.test(name) && - iFaces[name].some(({ family }) => family === 'IPv6'); + iFaces[name].some(({ family }) => family === 6); }); }, diff --git a/test/common/udppair.js b/test/common/udppair.js index 6213f4becfd6aa..fccbca042b3a5e 100644 --- a/test/common/udppair.js +++ b/test/common/udppair.js @@ -16,7 +16,7 @@ class FakeUDPWrap extends EventEmitter { this._handle.onwrite = (wrap, buffers, addr) => this._write(wrap, buffers, addr); this._handle.getsockname = (obj) => { - Object.assign(obj, { address: '127.0.0.1', family: 'IPv4', port: 1337 }); + Object.assign(obj, { address: '127.0.0.1', family: 4, port: 1337 }); return 0; }; @@ -72,8 +72,8 @@ class FakeUDPWrap extends EventEmitter { let familyInt; switch (family) { - case 'IPv4': familyInt = 4; break; - case 'IPv6': familyInt = 6; break; + case 4: familyInt = 4; break; + case 6: familyInt = 6; break; default: throw new Error('bad family'); } diff --git a/test/es-module/test-http-imports.mjs b/test/es-module/test-http-imports.mjs index b07d1103236190..5b1f2dbc578e35 100644 --- a/test/es-module/test-http-imports.mjs +++ b/test/es-module/test-http-imports.mjs @@ -39,10 +39,10 @@ const internalInterfaces = Object.values(os.networkInterfaces()).flat().filter( ); for (const iface of internalInterfaces) { testListeningOptions.push({ - hostname: iface?.family === 'IPv6' ? `[${iface?.address}]` : iface?.address, + hostname: iface?.family === 6 ? `[${iface.address}]` : iface?.address, listenOptions: { host: iface?.address, - ipv6Only: iface?.family === 'IPv6' + ipv6Only: iface?.family === 6 } }); } diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index 5972c5e24e537c..daa19ada43d0da 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -47,7 +47,7 @@ get_bindAddress: for (const name in networkInterfaces) { const interfaces = networkInterfaces[name]; for (let i = 0; i < interfaces.length; i++) { const localInterface = interfaces[i]; - if (!localInterface.internal && localInterface.family === 'IPv4') { + if (!localInterface.internal && localInterface.family === 4) { bindAddress = localInterface.address; break get_bindAddress; } diff --git a/test/internet/test-dgram-multicast-set-interface-lo.js b/test/internet/test-dgram-multicast-set-interface-lo.js index 11c3d47cff0637..0d93ebb1227530 100644 --- a/test/internet/test-dgram-multicast-set-interface-lo.js +++ b/test/internet/test-dgram-multicast-set-interface-lo.js @@ -49,7 +49,7 @@ const TMPL = (tail) => `${NOW} - ${tail}`; const interfaceAddress = ((networkInterfaces) => { for (const name in networkInterfaces) { for (const localInterface of networkInterfaces[name]) { - if (!localInterface.internal && localInterface.family === FAM) { + if (!localInterface.internal && `IPv${localInterface.family}` === FAM) { let interfaceAddress = localInterface.address; // On Windows, IPv6 would need: `%${localInterface.scopeid}` if (FAM === 'IPv6') diff --git a/test/internet/test-dgram-multicast-ssm-multi-process.js b/test/internet/test-dgram-multicast-ssm-multi-process.js index 324c989a180fa0..a6919ca57c3300 100644 --- a/test/internet/test-dgram-multicast-ssm-multi-process.js +++ b/test/internet/test-dgram-multicast-ssm-multi-process.js @@ -28,7 +28,7 @@ get_sourceAddress: for (const name in networkInterfaces) { const interfaces = networkInterfaces[name]; for (let i = 0; i < interfaces.length; i++) { const localInterface = interfaces[i]; - if (!localInterface.internal && localInterface.family === 'IPv4') { + if (!localInterface.internal && localInterface.family === 4) { sourceAddress = localInterface.address; break get_sourceAddress; } diff --git a/test/internet/test-dgram-multicast-ssmv6-multi-process.js b/test/internet/test-dgram-multicast-ssmv6-multi-process.js index fd7b8dcd4ce011..a23b1236f4656e 100644 --- a/test/internet/test-dgram-multicast-ssmv6-multi-process.js +++ b/test/internet/test-dgram-multicast-ssmv6-multi-process.js @@ -28,7 +28,7 @@ get_sourceAddress: for (const name in networkInterfaces) { const interfaces = networkInterfaces[name]; for (let i = 0; i < interfaces.length; i++) { const localInterface = interfaces[i]; - if (!localInterface.internal && localInterface.family === 'IPv6') { + if (!localInterface.internal && localInterface.family === 6) { sourceAddress = localInterface.address; break get_sourceAddress; } diff --git a/test/internet/test-dns-ipv4.js b/test/internet/test-dns-ipv4.js index a84f7e644fc9cf..b673e2f920d0d4 100644 --- a/test/internet/test-dns-ipv4.js +++ b/test/internet/test-dns-ipv4.js @@ -1,3 +1,5 @@ +// Flags: --dns-result-order=ipv4first + 'use strict'; const common = require('../common'); const { addresses } = require('../common/internet'); diff --git a/test/internet/test-dns-lookup.js b/test/internet/test-dns-lookup.js index 6efa946f9d7522..d4e3d6d1eb762b 100644 --- a/test/internet/test-dns-lookup.js +++ b/test/internet/test-dns-lookup.js @@ -45,17 +45,10 @@ dns.lookup(addresses.NOT_FOUND, { assert.strictEqual(error.hostname, addresses.NOT_FOUND); })); -common.expectWarning('DeprecationWarning', - 'Type coercion of dns.lookup options is deprecated', - 'DEP0153'); - -assert.rejects( - dnsPromises.lookup(addresses.NOT_FOUND, { +assert.throws( + () => dnsPromises.lookup(addresses.NOT_FOUND, { family: 'IPv4', all: 'all' }), - { - code: 'ENOTFOUND', - message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}` - } + { code: 'ERR_INVALID_ARG_VALUE' } ); diff --git a/test/parallel/test-dgram-address.js b/test/parallel/test-dgram-address.js index 2a41755e1c2ea6..e320f121a3a831 100644 --- a/test/parallel/test-dgram-address.js +++ b/test/parallel/test-dgram-address.js @@ -35,7 +35,7 @@ const dgram = require('dgram'); assert.strictEqual(typeof address.port, 'number'); assert.ok(isFinite(address.port)); assert.ok(address.port > 0); - assert.strictEqual(address.family, 'IPv4'); + assert.strictEqual(address.family, 4); socket.close(); })); @@ -59,7 +59,7 @@ if (common.hasIPv6) { assert.strictEqual(typeof address.port, 'number'); assert.ok(isFinite(address.port)); assert.ok(address.port > 0); - assert.strictEqual(address.family, 'IPv6'); + assert.strictEqual(address.family, 6); socket.close(); })); diff --git a/test/parallel/test-dns-lookup-promises-options-deprecated.js b/test/parallel/test-dns-lookup-promises-options-deprecated.js index 6f3b9314b9db13..2761b616620cca 100644 --- a/test/parallel/test-dns-lookup-promises-options-deprecated.js +++ b/test/parallel/test-dns-lookup-promises-options-deprecated.js @@ -15,18 +15,21 @@ common.expectWarning({ 'internal/test/binding': [ 'These APIs are for internal testing only. Do not use them.', ], - 'DeprecationWarning': { - DEP0153: 'Type coercion of dns.lookup options is deprecated' - } }); assert.throws(() => { dnsPromises.lookup('127.0.0.1', { hints: '-1' }); }, { - code: 'ERR_INVALID_ARG_VALUE', + code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); -dnsPromises.lookup('127.0.0.1', { family: '6' }); -dnsPromises.lookup('127.0.0.1', { all: 'true' }); -dnsPromises.lookup('127.0.0.1', { verbatim: 'true' }); -dnsPromises.lookup('127.0.0.1', '6'); +assert.throws(() => dnsPromises.lookup('127.0.0.1', { hints: -1 }), + { code: 'ERR_INVALID_ARG_VALUE' }); +assert.throws(() => dnsPromises.lookup('127.0.0.1', { family: '6' }), + { code: 'ERR_INVALID_ARG_VALUE' }); +assert.throws(() => dnsPromises.lookup('127.0.0.1', { all: 'true' }), + { code: 'ERR_INVALID_ARG_TYPE' }); +assert.throws(() => dnsPromises.lookup('127.0.0.1', { verbatim: 'true' }), + { code: 'ERR_INVALID_ARG_TYPE' }); +assert.throws(() => dnsPromises.lookup('127.0.0.1', '6'), + { code: 'ERR_INVALID_ARG_TYPE' }); diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js index 461e705a5e3cb6..a847a91d655196 100644 --- a/test/parallel/test-dns-lookup.js +++ b/test/parallel/test-dns-lookup.js @@ -69,14 +69,15 @@ assert.throws(() => { } { + const family = 20; const err = { code: 'ERR_INVALID_ARG_VALUE', name: 'TypeError', - message: "The argument 'family' must be one of: 0, 4, 6. Received 20" + message: `The property 'options.family' must be one of: 0, 4, 6. Received ${family}` }; const options = { hints: 0, - family: 20, + family, all: false }; @@ -86,6 +87,52 @@ assert.throws(() => { }, err); } +[1, 0n, 1n, '', '0', Symbol(), true, false, {}, [], () => {}] + .forEach((family) => { + const err = { code: 'ERR_INVALID_ARG_VALUE' }; + const options = { family }; + assert.throws(() => { dnsPromises.lookup(false, options); }, err); + assert.throws(() => { + dns.lookup(false, options, common.mustNotCall()); + }, err); + }); +[0n, 1n, '', '0', Symbol(), true, false].forEach((family) => { + const err = { code: 'ERR_INVALID_ARG_TYPE' }; + assert.throws(() => { dnsPromises.lookup(false, family); }, err); + assert.throws(() => { + dns.lookup(false, family, common.mustNotCall()); + }, err); +}); +assert.throws(() => dnsPromises.lookup(false, () => {}), + { code: 'ERR_INVALID_ARG_TYPE' }); + +[0n, 1n, '', '0', Symbol(), true, false, {}, [], () => {}].forEach((hints) => { + const err = { code: 'ERR_INVALID_ARG_TYPE' }; + const options = { hints }; + assert.throws(() => { dnsPromises.lookup(false, options); }, err); + assert.throws(() => { + dns.lookup(false, options, common.mustNotCall()); + }, err); +}); + +[0, 1, 0n, 1n, '', '0', Symbol(), {}, [], () => {}].forEach((all) => { + const err = { code: 'ERR_INVALID_ARG_TYPE' }; + const options = { all }; + assert.throws(() => { dnsPromises.lookup(false, options); }, err); + assert.throws(() => { + dns.lookup(false, options, common.mustNotCall()); + }, err); +}); + +[0, 1, 0n, 1n, '', '0', Symbol(), {}, [], () => {}].forEach((verbatim) => { + const err = { code: 'ERR_INVALID_ARG_TYPE' }; + const options = { verbatim }; + assert.throws(() => { dnsPromises.lookup(false, options); }, err); + assert.throws(() => { + dns.lookup(false, options, common.mustNotCall()); + }, err); +}); + (async function() { let res; diff --git a/test/parallel/test-net-listen-invalid-port.js b/test/parallel/test-net-listen-invalid-port.js index 844878036646dd..9e4dab1d4e5970 100644 --- a/test/parallel/test-net-listen-invalid-port.js +++ b/test/parallel/test-net-listen-invalid-port.js @@ -12,7 +12,7 @@ const invalidPort = -1 >>> 0; net.Server().listen(0, function() { const address = this.address(); - const key = `${address.family.slice(-1)}:${address.address}:0`; + const key = `${address.family}:${address.address}:0`; assert.strictEqual(this._connectionKey, key); this.close(); diff --git a/test/parallel/test-net-socket-connect-without-cb.js b/test/parallel/test-net-socket-connect-without-cb.js index 468b29a3a486d7..a6a8db8b633159 100644 --- a/test/parallel/test-net-socket-connect-without-cb.js +++ b/test/parallel/test-net-socket-connect-without-cb.js @@ -16,5 +16,11 @@ const server = net.createServer(common.mustCall(function(conn) { client.end(); })); - client.connect(server.address()); + const address = server.address(); + if (!common.hasIPv6 && address.family === 6) { + // Necessary to pass CI running inside containers. + client.connect(address.port); + } else { + client.connect(address); + } })); diff --git a/test/parallel/test-net-socket-ready-without-cb.js b/test/parallel/test-net-socket-ready-without-cb.js index 1ad5db4760dc1e..29da68e173c193 100644 --- a/test/parallel/test-net-socket-ready-without-cb.js +++ b/test/parallel/test-net-socket-ready-without-cb.js @@ -9,7 +9,7 @@ const net = require('net'); const server = net.createServer(common.mustCall(function(conn) { conn.end(); server.close(); -})).listen(0, common.mustCall(function() { +})).listen(0, 'localhost', common.mustCall(function() { const client = new net.Socket(); client.on('ready', common.mustCall(function() { diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index 80c32ea2a996c0..888a29539c9d18 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -138,7 +138,7 @@ switch (platform) { const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', - family: 'IPv4', + family: 4, mac: '00:00:00:00:00:00', internal: true, cidr: '127.0.0.1/8' @@ -154,7 +154,7 @@ switch (platform) { const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', - family: 'IPv4', + family: 4, mac: '00:00:00:00:00:00', internal: true, cidr: '127.0.0.1/8' diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index 0cac545e81d785..a19aed15071613 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -18,9 +18,9 @@ const r = (common.hasIPv6 ? server.bind6('::', 0) : server.bind('0.0.0.0', 0)); assert.strictEqual(r, 0); -let port = {}; + +const port = {}; server.getsockname(port); -port = port.port; server.listen(128); diff --git a/test/sequential/test-net-server-address.js b/test/sequential/test-net-server-address.js index 4312ffd5a1fe78..07776470f13a46 100644 --- a/test/sequential/test-net-server-address.js +++ b/test/sequential/test-net-server-address.js @@ -26,7 +26,7 @@ const net = require('net'); // Test on IPv4 Server { - const family = 'IPv4'; + const family = 4; const server = net.createServer(); server.on('error', common.mustNotCall()); @@ -46,7 +46,7 @@ if (!common.hasIPv6) { return; } -const family6 = 'IPv6'; +const family6 = 6; const anycast6 = '::'; // Test on IPv6 Server diff --git a/test/sequential/test-net-server-bind.js b/test/sequential/test-net-server-bind.js index 56216d0ed60619..67e9503f4cc3cc 100644 --- a/test/sequential/test-net-server-bind.js +++ b/test/sequential/test-net-server-bind.js @@ -24,7 +24,7 @@ const net = require('net'); const address = server.address(); assert.strictEqual(address.port, common.PORT); - if (address.family === 'IPv6') + if (address.family === 6) assert.strictEqual(server._connectionKey, `6::::${address.port}`); else assert.strictEqual(server._connectionKey, `4:0.0.0.0:${address.port}`);