Skip to content

Commit 070ff18

Browse files
committed
fixup! fixup! net: make server.address() return a string for family
1 parent 5e12824 commit 070ff18

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

doc/api/dns.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ changes:
183183
pr-url: https://github.com/nodejs/node/pull/43054
184184
description: For compatibility with `node:net`, when passing an option
185185
object the `family` option can be the string `'IPv4'` or the
186-
string `'IPv6'`, in which case its value will be ignored.
186+
string `'IPv6'`.
187187
- version: v18.0.0
188188
pr-url: https://github.com/nodejs/node/pull/41678
189189
description: Passing an invalid callback to the `callback` argument
@@ -202,10 +202,10 @@ changes:
202202

203203
* `hostname` {string}
204204
* `options` {integer | Object}
205-
* `family` {integer} The record family. Must be `4`, `6`, or `0`. For backward
206-
compatibility reasons,`'IPv4'` and `'IPv6'` are interpreted as `0`. The
207-
value `0` indicates that IPv4 and IPv6 addresses are both returned.
208-
**Default:** `0`.
205+
* `family` {integer|string} The record family. Must be `4`, `6`, or `0`. For
206+
backward compatibility reasons,`'IPv4'` and `'IPv6'` are interpreted as `4`
207+
and `6` respectively. The value `0` indicates that IPv4 and IPv6 addresses
208+
are both returned. **Default:** `0`.
209209
* `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple
210210
flags may be passed by bitwise `OR`ing their values.
211211
* `all` {boolean} When `true`, the callback returns all resolved addresses in

lib/dns.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ function lookup(hostname, options, callback) {
142142
if (options?.family != null) {
143143
switch (options.family) {
144144
case 'IPv4':
145+
family = 4;
146+
break;
145147
case 'IPv6':
146-
family = 0;
148+
family = 6;
147149
break;
148150
default:
149151
validateOneOf(options.family, 'options.family', validFamilies, true);

0 commit comments

Comments
 (0)