Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 709bf1c

Browse filesBrowse files
bteaMoLow
authored andcommitted
dns: expose getDefaultResultOrder
PR-URL: #46973 Fixes: #46919 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
1 parent 4e0d19e commit 709bf1c
Copy full SHA for 709bf1c

File tree

Expand file treeCollapse file tree

5 files changed

+53
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+53
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/dns.md‎

Copy file name to clipboardExpand all lines: doc/api/dns.md
+20Lines changed: 20 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,18 @@ priority than [`--dns-result-order`][]. When using [worker threads][],
792792
[`dns.setDefaultResultOrder()`][] from the main thread won't affect the default
793793
dns orders in workers.
794794

795+
## `dns.getDefaultResultOrder()`
796+
797+
<!-- YAML
798+
added: REPLACEME
799+
-->
800+
801+
Get the default value for `verbatim` in [`dns.lookup()`][] and
802+
[`dnsPromises.lookup()`][]. The value could be:
803+
804+
* `ipv4first`: for `verbatim` defaulting to `false`.
805+
* `verbatim`: for `verbatim` defaulting to `true`.
806+
795807
## `dns.setServers(servers)`
796808

797809
<!-- YAML
@@ -1351,6 +1363,14 @@ higher priority than [`--dns-result-order`][]. When using [worker threads][],
13511363
[`dnsPromises.setDefaultResultOrder()`][] from the main thread won't affect the
13521364
default dns orders in workers.
13531365

1366+
### `dnsPromises.getDefaultResultOrder()`
1367+
1368+
<!-- YAML
1369+
added: REPLACEME
1370+
-->
1371+
1372+
Get the value of `dnsOrder`.
1373+
13541374
### `dnsPromises.setServers(servers)`
13551375

13561376
<!-- YAML
Collapse file

‎lib/dns.js‎

Copy file name to clipboardExpand all lines: lib/dns.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const {
3838
validateHints,
3939
emitInvalidHostnameWarning,
4040
getDefaultVerbatim,
41+
getDefaultResultOrder,
4142
setDefaultResultOrder,
4243
errorCodes: dnsErrorCodes,
4344
} = require('internal/dns/utils');
@@ -305,6 +306,7 @@ module.exports = {
305306
lookupService,
306307

307308
Resolver,
309+
getDefaultResultOrder,
308310
setDefaultResultOrder,
309311
setServers: defaultResolverSetServers,
310312

Collapse file

‎lib/internal/dns/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/dns/promises.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
emitInvalidHostnameWarning,
1515
getDefaultVerbatim,
1616
errorCodes: dnsErrorCodes,
17+
getDefaultResultOrder,
1718
setDefaultResultOrder,
1819
setDefaultResolver,
1920
} = require('internal/dns/utils');
@@ -335,6 +336,7 @@ module.exports = {
335336
lookup,
336337
lookupService,
337338
Resolver,
339+
getDefaultResultOrder,
338340
setDefaultResultOrder,
339341
setServers: defaultResolverSetServers,
340342

Collapse file

‎lib/internal/dns/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/dns/utils.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ function setDefaultResultOrder(value) {
283283
dnsOrder = value;
284284
}
285285

286+
function getDefaultResultOrder() {
287+
return dnsOrder;
288+
}
289+
286290
function createResolverClass(resolver) {
287291
const resolveMap = ObjectCreate(null);
288292

@@ -345,6 +349,7 @@ module.exports = {
345349
validateTries,
346350
emitInvalidHostnameWarning,
347351
getDefaultVerbatim,
352+
getDefaultResultOrder,
348353
setDefaultResultOrder,
349354
errorCodes,
350355
createResolverClass,
Collapse file
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
const assert = require('assert');
6+
const dns = require('dns');
7+
8+
dns.setDefaultResultOrder('ipv4first');
9+
let dnsOrder = dns.getDefaultResultOrder();
10+
assert.ok(dnsOrder === 'ipv4first');
11+
dns.setDefaultResultOrder('verbatim');
12+
dnsOrder = dns.getDefaultResultOrder();
13+
assert.ok(dnsOrder === 'verbatim');
14+
15+
{
16+
(async function() {
17+
const result = await dns.promises.lookup('localhost');
18+
const result1 = await dns.promises.lookup('localhost', { verbatim: true });
19+
assert.ok(result !== undefined);
20+
assert.ok(result1 !== undefined);
21+
assert.ok(result.address === result1.address);
22+
assert.ok(result.family === result1.family);
23+
})().then(common.mustCall());
24+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.