-
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: add setLocalAddress to Resolver
Fixes: #34818 PR-URL: #34824 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
- Loading branch information
1 parent
f41c28c
commit ed79c98
Showing
5 changed files
with
137 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
const dns = require('dns'); | ||
const resolver = new dns.Resolver(); | ||
const promiseResolver = new dns.promises.Resolver(); | ||
|
||
// Verifies that setLocalAddress succeeds with IPv4 and IPv6 addresses | ||
{ | ||
resolver.setLocalAddress('127.0.0.1'); | ||
resolver.setLocalAddress('::1'); | ||
resolver.setLocalAddress('127.0.0.1', '::1'); | ||
promiseResolver.setLocalAddress('127.0.0.1', '::1'); | ||
} | ||
|
||
// Verify that setLocalAddress throws if called with an invalid address | ||
{ | ||
assert.throws(() => { | ||
resolver.setLocalAddress('127.0.0.1', '127.0.0.1'); | ||
}, Error); | ||
assert.throws(() => { | ||
resolver.setLocalAddress('::1', '::1'); | ||
}, Error); | ||
assert.throws(() => { | ||
resolver.setLocalAddress('bad'); | ||
}, Error); | ||
assert.throws(() => { | ||
resolver.setLocalAddress(123); | ||
}, Error); | ||
assert.throws(() => { | ||
resolver.setLocalAddress(); | ||
}, Error); | ||
assert.throws(() => { | ||
promiseResolver.setLocalAddress(); | ||
}, Error); | ||
} |