GeezerVison is showing github.com — dns: add dns.ALL hints flag constant · nodejs/node@e14317a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/dns.md +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -210,6 +210,8 @@ configured. Loopback addresses are not considered. | 210 | 210 | * `dns.V4MAPPED`: If the IPv6 family was specified, but no IPv6 addresses were | 211 | 211 | found, then return IPv4 mapped IPv6 addresses. It is not supported | 212 | 212 | on some operating systems (e.g FreeBSD 10.1). | | 213 | +* `dns.ALL`: If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as | | 214 | +well as IPv4 mapped IPv6 addresses. | 213 | 215 |
| 214 | 216 | ## `dns.lookupService(address, port, callback)` | 215 | 217 | <!-- YAML | |
Collapse file Copy file name to clipboardExpand all lines: lib/dns.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -290,6 +290,7 @@ module.exports = { | 290 | 290 |
| 291 | 291 | // uv_getaddrinfo flags | 292 | 292 | ADDRCONFIG: cares.AI_ADDRCONFIG, | | 293 | + ALL: cares.AI_ALL, | 293 | 294 | V4MAPPED: cares.AI_V4MAPPED, | 294 | 295 |
| 295 | 296 | // ERROR CODES | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/dns/utils.js +3-5Lines changed: 3 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,8 @@ const { | 10 | 10 | ChannelWrap, | 11 | 11 | strerror, | 12 | 12 | AI_ADDRCONFIG, | 13 | | - AI_V4MAPPED | | 13 | + AI_ALL, | | 14 | + AI_V4MAPPED, | 14 | 15 | } = internalBinding('cares_wrap'); | 15 | 16 | const IANA_DNS_PORT = 53; | 16 | 17 | const IPv6RE = /^\[([^[\]]*)\]/; | @@ -136,10 +137,7 @@ function bindDefaultResolver(target, source) { | 136 | 137 | } | 137 | 138 |
| 138 | 139 | function validateHints(hints) { | 139 | | - if (hints !== 0 && | 140 | | - hints !== AI_ADDRCONFIG && | 141 | | - hints !== AI_V4MAPPED && | 142 | | - hints !== (AI_ADDRCONFIG | AI_V4MAPPED)) { | | 140 | + if ((hints & ~(AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED)) !== 0) { | 143 | 141 | throw new ERR_INVALID_OPT_VALUE('hints', hints); | 144 | 142 | } | 145 | 143 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/cares_wrap.cc +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2188,6 +2188,9 @@ void Initialize(Local<Object> target, | 2188 | 2188 | target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), | 2189 | 2189 | "AI_ADDRCONFIG"), | 2190 | 2190 | Integer::New(env->isolate(), AI_ADDRCONFIG)).Check(); | | 2191 | + target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), | | 2192 | + "AI_ALL"), | | 2193 | + Integer::New(env->isolate(), AI_ALL)).Check(); | 2191 | 2194 | target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), | 2192 | 2195 | "AI_V4MAPPED"), | 2193 | 2196 | Integer::New(env->isolate(), AI_V4MAPPED)).Check(); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-dns.js +21-4Lines changed: 21 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -209,14 +209,14 @@ assert.deepStrictEqual(dns.getServers(), []); | 209 | 209 | { | 210 | 210 | /* | 211 | 211 | * Make sure that dns.lookup throws if hints does not represent a valid flag. | 212 | | - * (dns.V4MAPPED | dns.ADDRCONFIG) + 1 is invalid because: | 213 | | - * - it's different from dns.V4MAPPED and dns.ADDRCONFIG. | 214 | | - * - it's different from them bitwise ored. | | 212 | + * (dns.V4MAPPED | dns.ADDRCONFIG | dns.ALL) + 1 is invalid because: | | 213 | + * - it's different from dns.V4MAPPED and dns.ADDRCONFIG and dns.ALL. | | 214 | + * - it's different from any subset of them bitwise ored. | 215 | 215 | * - it's different from 0. | 216 | 216 | * - it's an odd number different than 1, and thus is invalid, because | 217 | 217 | * flags are either === 1 or even. | 218 | 218 | */ | 219 | | - const hints = (dns.V4MAPPED | dns.ADDRCONFIG) + 1; | | 219 | + const hints = (dns.V4MAPPED | dns.ADDRCONFIG | dns.ALL) + 1; | 220 | 220 | const err = { | 221 | 221 | code: 'ERR_INVALID_OPT_VALUE', | 222 | 222 | name: 'TypeError', | @@ -254,11 +254,28 @@ dns.lookup('', { | 254 | 254 | hints: dns.ADDRCONFIG | dns.V4MAPPED | 255 | 255 | }, common.mustCall()); | 256 | 256 |
| | 257 | +dns.lookup('', { | | 258 | + hints: dns.ALL | | 259 | +}, common.mustCall()); | | 260 | + | | 261 | +dns.lookup('', { | | 262 | + hints: dns.V4MAPPED | dns.ALL | | 263 | +}, common.mustCall()); | | 264 | + | | 265 | +dns.lookup('', { | | 266 | + hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL | | 267 | +}, common.mustCall()); | | 268 | + | 257 | 269 | (async function() { | 258 | 270 | await dnsPromises.lookup('', { family: 4, hints: 0 }); | 259 | 271 | await dnsPromises.lookup('', { family: 6, hints: dns.ADDRCONFIG }); | 260 | 272 | await dnsPromises.lookup('', { hints: dns.V4MAPPED }); | 261 | 273 | await dnsPromises.lookup('', { hints: dns.ADDRCONFIG | dns.V4MAPPED }); | | 274 | + await dnsPromises.lookup('', { hints: dns.ALL }); | | 275 | + await dnsPromises.lookup('', { hints: dns.V4MAPPED | dns.ALL }); | | 276 | + await dnsPromises.lookup('', { | | 277 | + hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL | | 278 | + }); | 262 | 279 | })(); | 263 | 280 |
| 264 | 281 | { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-net-connect-options-port.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,7 +59,7 @@ const net = require('net'); | 59 | 59 | // Test invalid hints | 60 | 60 | { | 61 | 61 | // connect({hint}, cb) and connect({hint}) | 62 | | - const hints = (dns.ADDRCONFIG | dns.V4MAPPED) + 42; | | 62 | + const hints = (dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL) + 42; | 63 | 63 | const hintOptBlocks = doConnect([{ hints }], | 64 | 64 | () => common.mustNotCall()); | 65 | 65 | for (const fn of hintOptBlocks) { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-tls-connect-hints-option.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,11 @@ const hints = 512; | 15 | 15 |
| 16 | 16 | assert.notStrictEqual(hints, dns.ADDRCONFIG); | 17 | 17 | assert.notStrictEqual(hints, dns.V4MAPPED); | | 18 | +assert.notStrictEqual(hints, dns.ALL); | 18 | 19 | assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.V4MAPPED); | | 20 | +assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.ALL); | | 21 | +assert.notStrictEqual(hints, dns.V4MAPPED | dns.ALL); | | 22 | +assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL); | 19 | 23 |
| 20 | 24 | tls.connect({ | 21 | 25 | lookup: common.mustCall((host, options) => { | |
|