Skip to content

Commit 3932f7a

Browse files
bnoordhuistreysis
authored andcommitted
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: nodejs#31566 Refs: nodejs#6307 Refs: nodejs#20710 Reissue of nodejs#31567 Reissue of nodejs#37681 Reissue of nodejs#37931
1 parent f26c2ce commit 3932f7a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

doc/api/dns.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ section if a custom port is used.
170170
<!-- YAML
171171
added: v0.1.90
172172
changes:
173+
- version: REPLACEME
174+
pr-url: https://github.com/nodejs/node/pull/37681
175+
description: The `verbatim` options defaults to `true` now.
173176
- version: v8.5.0
174177
pr-url: https://github.com/nodejs/node/pull/14731
175178
description: The `verbatim` option is supported now.
@@ -190,10 +193,9 @@ changes:
190193
* `verbatim` {boolean} When `true`, the callback receives IPv4 and IPv6
191194
addresses in the order the DNS resolver returned them. When `false`,
192195
IPv4 addresses are placed before IPv6 addresses.
193-
**Default:** currently `false` (addresses are reordered) but this is
194-
expected to change in the not too distant future. Default value is
196+
**Default:** `true` (addresses are reordered). Default value is
195197
configurable using [`dns.setDefaultResultOrder()`][] or
196-
[`--dns-result-order`][]. New code should use `{ verbatim: true }`.
198+
[`--dns-result-order`][].
197199
* `callback` {Function}
198200
* `err` {Error}
199201
* `address` {string} A string representation of an IPv4 or IPv6 address.

lib/internal/dns/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function emitInvalidHostnameWarning(hostname) {
193193
);
194194
}
195195

196-
let dnsOrder = getOptionValue('--dns-result-order') || 'ipv4first';
196+
let dnsOrder = getOptionValue('--dns-result-order') || 'true';
197197

198198
function getDefaultVerbatim() {
199199
switch (dnsOrder) {

test/sequential/test-net-better-error-messages-port.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ c.on('connect', common.mustNotCall());
1010
c.on('error', common.mustCall(function(e) {
1111
assert.strictEqual(e.code, 'ECONNREFUSED');
1212
assert.strictEqual(e.port, common.PORT);
13-
assert.strictEqual(e.address, '127.0.0.1');
13+
assert.match(e.address, /^(127\.0\.0\.1|::1)$/);
1414
}));

0 commit comments

Comments
 (0)