-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dns: allow --dns-verbatim to change default dns verbatim
Allow the "--dns-verbatim" option to change the default value of verbatim in `dns.lookup()`. This is useful when running Node.js in ipv6-only environments to avoid possible ENETUNREACH errors.
- Loading branch information
Showing
8 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Flags: --expose-internals --dns-verbatim=0 | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { internalBinding } = require('internal/test/binding'); | ||
const cares = internalBinding('cares_wrap'); | ||
|
||
// Test that --dns-verbatim=0 works as expected. | ||
|
||
const originalGetaddrinfo = cares.getaddrinfo; | ||
const calls = []; | ||
cares.getaddrinfo = (...args) => { | ||
calls.push(args); | ||
originalGetaddrinfo(...args); | ||
}; | ||
|
||
const dns = require('dns'); | ||
const dnsPromises = dns.promises; | ||
|
||
let verbatim; | ||
|
||
dns.lookup('example.org', common.mustCall(_err => { | ||
assert.strictEqual(calls.length, 1); | ||
verbatim = calls[0][4]; | ||
assert.strictEqual(verbatim, false); | ||
|
||
dnsPromises.lookup('example.org').then(() => { | ||
assert.strictEqual(calls.length, 2); | ||
verbatim = calls[1][4]; | ||
assert.strictEqual(verbatim, false); | ||
}).catch(common.mustNotCall); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Flags: --expose-internals --dns-verbatim=1 | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { internalBinding } = require('internal/test/binding'); | ||
const cares = internalBinding('cares_wrap'); | ||
|
||
// Test that --dns-verbatim=1 works as expected. | ||
|
||
const originalGetaddrinfo = cares.getaddrinfo; | ||
const calls = []; | ||
cares.getaddrinfo = (...args) => { | ||
calls.push(args); | ||
originalGetaddrinfo(...args); | ||
}; | ||
|
||
const dns = require('dns'); | ||
const dnsPromises = dns.promises; | ||
|
||
let verbatim; | ||
|
||
dns.lookup('example.org', common.mustCall(_err => { | ||
assert.strictEqual(calls.length, 1); | ||
verbatim = calls[0][4]; | ||
assert.strictEqual(verbatim, true); | ||
|
||
dnsPromises.lookup('example.org').then(() => { | ||
assert.strictEqual(calls.length, 2); | ||
verbatim = calls[1][4]; | ||
assert.strictEqual(verbatim, true); | ||
}).catch(common.mustNotCall); | ||
})); |