Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/dgram.md5
-rw-r--r--doc/api/dns.md16
-rw-r--r--doc/api/net.md10
-rw-r--r--doc/api/os.md15
-rw-r--r--doc/api/tls.md5
-rw-r--r--lib/dns.js14
-rw-r--r--lib/net.js4
-rw-r--r--lib/os.js4
-rw-r--r--src/env.h2
-rw-r--r--src/node_os.cc9
-rw-r--r--src/tcp_wrap.cc8
-rw-r--r--test/common/index.js2
-rw-r--r--test/common/udppair.js6
-rw-r--r--test/es-module/test-http-imports.mjs4
-rw-r--r--test/internet/test-dgram-broadcast-multi-process.js2
-rw-r--r--test/internet/test-dgram-multicast-set-interface-lo.js2
-rw-r--r--test/internet/test-dgram-multicast-ssm-multi-process.js2
-rw-r--r--test/internet/test-dgram-multicast-ssmv6-multi-process.js2
-rw-r--r--test/internet/test-dns-lookup.js2
-rw-r--r--test/parallel/parallel.status8
-rw-r--r--test/parallel/test-dgram-address.js4
-rw-r--r--test/parallel/test-dgram-udp6-link-local-address.js2
-rw-r--r--test/parallel/test-net-listen-invalid-port.js2
-rw-r--r--test/parallel/test-net-socket-connect-without-cb.js2
-rw-r--r--test/parallel/test-os.js4
-rw-r--r--test/sequential/test-net-server-address.js4
-rw-r--r--test/sequential/test-net-server-bind.js2
27 files changed, 88 insertions, 54 deletions
diff --git a/doc/api/dgram.md b/doc/api/dgram.md
index f4045428d4d..da3c69ba168 100644
--- a/doc/api/dgram.md
+++ b/doc/api/dgram.md
@@ -114,6 +114,9 @@ exist and calls such as `socket.address()` and `socket.setTTL()` will fail.
<!-- YAML
added: v0.1.99
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/43054
+ description: The `family` property now returns a string instead of a number.
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41431
description: The `family` property now returns a number instead of a string.
@@ -125,7 +128,7 @@ The event handler function is passed two arguments: `msg` and `rinfo`.
* `msg` {Buffer} The message.
* `rinfo` {Object} Remote address information.
* `address` {string} The sender address.
- * `family` {number} The address family (`4` for IPv4 or `6` for IPv6).
+ * `family` {string} The address family (`'IPv4'` or `'IPv6'`).
* `port` {number} The sender port.
* `size` {number} The message size.
diff --git a/doc/api/dns.md b/doc/api/dns.md
index c9e901da677..0d281fdffe0 100644
--- a/doc/api/dns.md
+++ b/doc/api/dns.md
@@ -179,6 +179,11 @@ section if a custom port is used.
<!-- YAML
added: v0.1.90
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/43054
+ description: For compatibility with `node:net`, when passing an option
+ object the `family` option can be the string `'IPv4'` or the
+ string `'IPv6'`.
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41678
description: Passing an invalid callback to the `callback` argument
@@ -197,9 +202,10 @@ changes:
* `hostname` {string}
* `options` {integer | Object}
- * `family` {integer} The record family. Must be `4`, `6`, or `0`. The value
- `0` indicates that IPv4 and IPv6 addresses are both returned. **Default:**
- `0`.
+ * `family` {integer|string} The record family. Must be `4`, `6`, or `0`. For
+ backward compatibility reasons,`'IPv4'` and `'IPv6'` are interpreted as `4`
+ and `6` respectively. The value `0` indicates that IPv4 and IPv6 addresses
+ are both returned. **Default:** `0`.
* `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple
flags may be passed by bitwise `OR`ing their values.
* `all` {boolean} When `true`, the callback returns all resolved addresses in
@@ -219,8 +225,8 @@ changes:
Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
AAAA (IPv6) record. All `option` properties are optional. If `options` is an
-integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
-and IPv6 addresses are both returned if found.
+integer, then it must be `4` or `6` – if `options` is `0` or not provided, then
+IPv4 and IPv6 addresses are both returned if found.
With the `all` option set to `true`, the arguments for `callback` change to
`(err, addresses)`, with `addresses` being an array of objects with the
diff --git a/doc/api/net.md b/doc/api/net.md
index 82bff635c9b..a22b6c036ab 100644
--- a/doc/api/net.md
+++ b/doc/api/net.md
@@ -286,6 +286,9 @@ Emitted when the server has been bound after calling [`server.listen()`][].
<!-- YAML
added: v0.1.90
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/43054
+ description: The `family` property now returns a string instead of a number.
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41431
description: The `family` property now returns a number instead of a string.
@@ -296,7 +299,7 @@ changes:
Returns the bound `address`, the address `family` name, and `port` of the server
as reported by the operating system if listening on an IP socket
(useful to find which port was assigned when getting an OS-assigned address):
-`{ port: 12346, family: 4, address: '127.0.0.1' }`.
+`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
For a server listening on a pipe or Unix domain socket, the name is returned
as a string.
@@ -743,6 +746,9 @@ See also: [`socket.setTimeout()`][].
<!-- YAML
added: v0.1.90
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/43054
+ description: The `family` property now returns a string instead of a number.
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41431
description: The `family` property now returns a number instead of a string.
@@ -752,7 +758,7 @@ changes:
Returns the bound `address`, the address `family` name and `port` of the
socket as reported by the operating system:
-`{ port: 12346, family: 4, address: '127.0.0.1' }`
+`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
### `socket.bufferSize`
diff --git a/doc/api/os.md b/doc/api/os.md
index ad4d082d94d..370504d632e 100644
--- a/doc/api/os.md
+++ b/doc/api/os.md
@@ -225,6 +225,9 @@ always `[0, 0, 0]`.
<!-- YAML
added: v0.6.0
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/43054
+ description: The `family` property now returns a string instead of a number.
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41431
description: The `family` property now returns a number instead of a string.
@@ -242,12 +245,12 @@ The properties available on the assigned network address object include:
* `address` {string} The assigned IPv4 or IPv6 address
* `netmask` {string} The IPv4 or IPv6 network mask
-* `family` {number} Either `4` (for IPv4) or `6` (for IPv6)
+* `family` {string} Either `IPv4` or `IPv6`
* `mac` {string} The MAC address of the network interface
* `internal` {boolean} `true` if the network interface is a loopback or
similar interface that is not remotely accessible; otherwise `false`
* `scopeid` {number} The numeric IPv6 scope ID (only specified when `family`
- is `6`)
+ is `IPv6`)
* `cidr` {string} The assigned IPv4 or IPv6 address with the routing prefix
in CIDR notation. If the `netmask` is invalid, this property is set
to `null`.
@@ -260,7 +263,7 @@ The properties available on the assigned network address object include:
{
address: '127.0.0.1',
netmask: '255.0.0.0',
- family: 4,
+ family: 'IPv4',
mac: '00:00:00:00:00:00',
internal: true,
cidr: '127.0.0.1/8'
@@ -268,7 +271,7 @@ The properties available on the assigned network address object include:
{
address: '::1',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
- family: 6,
+ family: 'IPv6',
mac: '00:00:00:00:00:00',
scopeid: 0,
internal: true,
@@ -279,7 +282,7 @@ The properties available on the assigned network address object include:
{
address: '192.168.1.108',
netmask: '255.255.255.0',
- family: 4,
+ family: 'IPv4',
mac: '01:02:03:0a:0b:0c',
internal: false,
cidr: '192.168.1.108/24'
@@ -287,7 +290,7 @@ The properties available on the assigned network address object include:
{
address: 'fe80::a00:27ff:fe4e:66a1',
netmask: 'ffff:ffff:ffff:ffff::',
- family: 6,
+ family: 'IPv6',
mac: '01:02:03:0a:0b:0c',
scopeid: 1,
internal: false,
diff --git a/doc/api/tls.md b/doc/api/tls.md
index 1621769d779..fd01f4cb9c5 100644
--- a/doc/api/tls.md
+++ b/doc/api/tls.md
@@ -956,6 +956,9 @@ tlsSocket.once('session', (session) => {
<!-- YAML
added: v0.11.4
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/43054
+ description: The `family` property now returns a string instead of a number.
- version: v18.0.0
pr-url: https://github.com/nodejs/node/pull/41431
description: The `family` property now returns a number instead of a string.
@@ -965,7 +968,7 @@ changes:
Returns the bound `address`, the address `family` name, and `port` of the
underlying socket as reported by the operating system:
-`{ port: 12346, family: 4, address: '127.0.0.1' }`.
+`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
### `tlsSocket.authorizationError`
diff --git a/lib/dns.js b/lib/dns.js
index ae908d46333..284032202a2 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -145,8 +145,18 @@ function lookup(hostname, options, callback) {
validateHints(hints);
}
if (options?.family != null) {
- validateOneOf(options.family, 'options.family', validFamilies, true);
- family = options.family;
+ switch (options.family) {
+ case 'IPv4':
+ family = 4;
+ break;
+ case 'IPv6':
+ family = 6;
+ break;
+ default:
+ validateOneOf(options.family, 'options.family', validFamilies, true);
+ family = options.family;
+ break;
+ }
}
if (options?.all != null) {
validateBoolean(options.all, 'options.all');
diff --git a/lib/net.js b/lib/net.js
index 6f07cf6b9e8..2e0b26a1958 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -800,9 +800,7 @@ protoGetter('remoteAddress', function remoteAddress() {
});
protoGetter('remoteFamily', function remoteFamily() {
- const { family } = this._getpeername();
-
- return family ? `IPv${family}` : family;
+ return this._getpeername().family;
});
protoGetter('remotePort', function remotePort() {
diff --git a/lib/os.js b/lib/os.js
index 90920b67b37..81bbe15a9d2 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 === 6) {
+ if (family === 'IPv6') {
split = ':';
range = 16;
groupLength = 16;
@@ -248,7 +248,7 @@ function getCIDR(address, netmask, family) {
* @returns {Record<string, Array<{
* address: string,
* netmask: string,
- * family: 4 | 6,
+ * family: 'IPv4' | 'IPv6',
* mac: string,
* internal: boolean,
* scopeid: number,
diff --git a/src/env.h b/src/env.h
index c188b263470..e59abdd9cb2 100644
--- a/src/env.h
+++ b/src/env.h
@@ -301,6 +301,8 @@ class NoArrayBufferZeroFillScope {
V(input_string, "input") \
V(internal_binding_string, "internalBinding") \
V(internal_string, "internal") \
+ V(ipv4_string, "IPv4") \
+ V(ipv6_string, "IPv6") \
V(isclosing_string, "isClosing") \
V(issuer_string, "issuer") \
V(issuercert_string, "issuerCertificate") \
diff --git a/src/node_os.cc b/src/node_os.cc
index 6e62af00f5f..046a6106ccd 100644
--- a/src/node_os.cc
+++ b/src/node_os.cc
@@ -174,8 +174,7 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
char ip[INET6_ADDRSTRLEN];
char netmask[INET6_ADDRSTRLEN];
std::array<char, 18> mac;
- Local<String> name;
- Local<Integer> family;
+ Local<String> name, family;
int err = uv_interface_addresses(&interfaces, &count);
@@ -215,14 +214,14 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& 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 = Integer::New(env->isolate(), 4);
+ family = env->ipv4_string();
} 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 = Integer::New(env->isolate(), 6);
+ family = env->ipv6_string();
} else {
strncpy(ip, "<unknown sa family>", INET6_ADDRSTRLEN);
- family = Integer::New(env->isolate(), 0);
+ family = env->unknown_string();
}
result.emplace_back(name);
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc
index f3163fc84cd..1f81094d32b 100644
--- a/src/tcp_wrap.cc
+++ b/src/tcp_wrap.cc
@@ -402,9 +402,7 @@ MaybeLocal<Object> AddressToJS(Environment* env,
info->Set(env->context(),
env->address_string(),
OneByteString(env->isolate(), ip)).Check();
- info->Set(env->context(),
- env->family_string(),
- Integer::New(env->isolate(), 6)).Check();
+ info->Set(env->context(), env->family_string(), env->ipv6_string()).Check();
info->Set(env->context(),
env->port_string(),
Integer::New(env->isolate(), port)).Check();
@@ -417,9 +415,7 @@ MaybeLocal<Object> AddressToJS(Environment* env,
info->Set(env->context(),
env->address_string(),
OneByteString(env->isolate(), ip)).Check();
- info->Set(env->context(),
- env->family_string(),
- Integer::New(env->isolate(), 4)).Check();
+ info->Set(env->context(), env->family_string(), env->ipv4_string()).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 57da03daefd..060deef1b80 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -854,7 +854,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 === 6);
+ iFaces[name].some(({ family }) => family === 'IPv6');
});
},
diff --git a/test/common/udppair.js b/test/common/udppair.js
index fccbca042b3..6213f4becfd 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: 4, port: 1337 });
+ Object.assign(obj, { address: '127.0.0.1', family: 'IPv4', port: 1337 });
return 0;
};
@@ -72,8 +72,8 @@ class FakeUDPWrap extends EventEmitter {
let familyInt;
switch (family) {
- case 4: familyInt = 4; break;
- case 6: familyInt = 6; break;
+ case 'IPv4': familyInt = 4; break;
+ case 'IPv6': 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 5139a2e69e0..235d142d355 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 === 6 ? `[${iface.address}]` : iface?.address,
+ hostname: iface?.family === 'IPv6' ? `[${iface?.address}]` : iface?.address,
listenOptions: {
host: iface?.address,
- ipv6Only: iface?.family === 6
+ ipv6Only: iface?.family === 'IPv6'
}
});
}
diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js
index daa19ada43d..5972c5e24e5 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 === 4) {
+ if (!localInterface.internal && localInterface.family === 'IPv4') {
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 0d93ebb1227..11c3d47cff0 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 && `IPv${localInterface.family}` === FAM) {
+ if (!localInterface.internal && 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 a6919ca57c3..324c989a180 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 === 4) {
+ if (!localInterface.internal && localInterface.family === 'IPv4') {
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 a23b1236f46..fd7b8dcd4ce 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 === 6) {
+ if (!localInterface.internal && localInterface.family === 'IPv6') {
sourceAddress = localInterface.address;
break get_sourceAddress;
}
diff --git a/test/internet/test-dns-lookup.js b/test/internet/test-dns-lookup.js
index d4e3d6d1eb7..6e2714ecad0 100644
--- a/test/internet/test-dns-lookup.js
+++ b/test/internet/test-dns-lookup.js
@@ -47,7 +47,7 @@ dns.lookup(addresses.NOT_FOUND, {
assert.throws(
() => dnsPromises.lookup(addresses.NOT_FOUND, {
- family: 'IPv4',
+ family: 'ipv4',
all: 'all'
}),
{ code: 'ERR_INVALID_ARG_VALUE' }
diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status
index 98511b1c6d7..26d1010d254 100644
--- a/test/parallel/parallel.status
+++ b/test/parallel/parallel.status
@@ -31,6 +31,10 @@ test-crypto-dh-stateless: SKIP
test-crypto-keygen: SKIP
[$system==solaris] # Also applies to SmartOS
+# https://github.com/nodejs/node/pull/43054
+test-net-socket-connect-without-cb: SKIP
+test-net-socket-ready-without-cb: SKIP
+test-tcp-wrap-listen: SKIP
[$system==freebsd]
# https://github.com/nodejs/node/issues/31727
@@ -39,6 +43,10 @@ test-fs-stat-bigint: PASS,FLAKY
test-worker-message-port-message-before-close: PASS,FLAKY
[$system==aix]
+# https://github.com/nodejs/node/pull/43054
+test-net-socket-connect-without-cb: SKIP
+test-net-socket-ready-without-cb: SKIP
+test-tcp-wrap-listen: SKIP
[$system==ibmi]
# https://github.com/nodejs/node/pull/30819
diff --git a/test/parallel/test-dgram-address.js b/test/parallel/test-dgram-address.js
index e320f121a3a..2a41755e1c2 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, 4);
+ assert.strictEqual(address.family, 'IPv4');
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, 6);
+ assert.strictEqual(address.family, 'IPv6');
socket.close();
}));
diff --git a/test/parallel/test-dgram-udp6-link-local-address.js b/test/parallel/test-dgram-udp6-link-local-address.js
index c9a0224c84c..5c090acc6b9 100644
--- a/test/parallel/test-dgram-udp6-link-local-address.js
+++ b/test/parallel/test-dgram-udp6-link-local-address.js
@@ -12,7 +12,7 @@ const { isWindows } = common;
function linklocal() {
for (const [ifname, entries] of Object.entries(os.networkInterfaces())) {
for (const { address, family, scopeid } of entries) {
- if (family === 6 && address.startsWith('fe80:')) {
+ if (family === 'IPv6' && address.startsWith('fe80:')) {
return { address, ifname, scopeid };
}
}
diff --git a/test/parallel/test-net-listen-invalid-port.js b/test/parallel/test-net-listen-invalid-port.js
index 9e4dab1d4e5..84487803664 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}:${address.address}:0`;
+ const key = `${address.family.slice(-1)}:${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 a6a8db8b633..274083eb290 100644
--- a/test/parallel/test-net-socket-connect-without-cb.js
+++ b/test/parallel/test-net-socket-connect-without-cb.js
@@ -17,7 +17,7 @@ const server = net.createServer(common.mustCall(function(conn) {
}));
const address = server.address();
- if (!common.hasIPv6 && address.family === 6) {
+ if (!common.hasIPv6 && address.family === 'IPv6') {
// Necessary to pass CI running inside containers.
client.connect(address.port);
} else {
diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js
index 888a29539c9..80c32ea2a99 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: 4,
+ family: 'IPv4',
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: 4,
+ family: 'IPv4',
mac: '00:00:00:00:00:00',
internal: true,
cidr: '127.0.0.1/8'
diff --git a/test/sequential/test-net-server-address.js b/test/sequential/test-net-server-address.js
index 07776470f13..4312ffd5a1f 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 = 4;
+ const family = 'IPv4';
const server = net.createServer();
server.on('error', common.mustNotCall());
@@ -46,7 +46,7 @@ if (!common.hasIPv6) {
return;
}
-const family6 = 6;
+const family6 = 'IPv6';
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 67e9503f4cc..56216d0ed60 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 === 6)
+ if (address.family === 'IPv6')
assert.strictEqual(server._connectionKey, `6::::${address.port}`);
else
assert.strictEqual(server._connectionKey, `4:0.0.0.0:${address.port}`);