GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dns: add dns.ALL hints flag constant · nodejs/node@e14317a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • dns.md
  • lib
    • dns.js
    • internal/dns
      • utils.js
  • src
    • cares_wrap.cc
  • test/parallel
    • test-dns.js
    • test-net-connect-options-port.js
    • test-tls-connect-hints-option.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/dns.md‎

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 numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ configured. Loopback addresses are not considered.
210210
* `dns.V4MAPPED`: If the IPv6 family was specified, but no IPv6 addresses were
211211
found, then return IPv4 mapped IPv6 addresses. It is not supported
212212
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.
213215

214216
## `dns.lookupService(address, port, callback)`
215217
<!-- YAML
Collapse file

‎lib/dns.js‎

Copy file name to clipboardExpand all lines: lib/dns.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ module.exports = {
290290

291291
// uv_getaddrinfo flags
292292
ADDRCONFIG: cares.AI_ADDRCONFIG,
293+
ALL: cares.AI_ALL,
293294
V4MAPPED: cares.AI_V4MAPPED,
294295

295296
// ERROR CODES
Collapse file

‎lib/internal/dns/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/dns/utils.js
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const {
1010
ChannelWrap,
1111
strerror,
1212
AI_ADDRCONFIG,
13-
AI_V4MAPPED
13+
AI_ALL,
14+
AI_V4MAPPED,
1415
} = internalBinding('cares_wrap');
1516
const IANA_DNS_PORT = 53;
1617
const IPv6RE = /^\[([^[\]]*)\]/;
@@ -136,10 +137,7 @@ function bindDefaultResolver(target, source) {
136137
}
137138

138139
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) {
143141
throw new ERR_INVALID_OPT_VALUE('hints', hints);
144142
}
145143
}
Collapse file

‎src/cares_wrap.cc‎

Copy file name to clipboardExpand all lines: src/cares_wrap.cc
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,9 @@ void Initialize(Local<Object> target,
21882188
target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(),
21892189
"AI_ADDRCONFIG"),
21902190
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();
21912194
target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(),
21922195
"AI_V4MAPPED"),
21932196
Integer::New(env->isolate(), AI_V4MAPPED)).Check();
Collapse file

‎test/parallel/test-dns.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dns.js
+21-4Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ assert.deepStrictEqual(dns.getServers(), []);
209209
{
210210
/*
211211
* 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.
215215
* - it's different from 0.
216216
* - it's an odd number different than 1, and thus is invalid, because
217217
* flags are either === 1 or even.
218218
*/
219-
const hints = (dns.V4MAPPED | dns.ADDRCONFIG) + 1;
219+
const hints = (dns.V4MAPPED | dns.ADDRCONFIG | dns.ALL) + 1;
220220
const err = {
221221
code: 'ERR_INVALID_OPT_VALUE',
222222
name: 'TypeError',
@@ -254,11 +254,28 @@ dns.lookup('', {
254254
hints: dns.ADDRCONFIG | dns.V4MAPPED
255255
}, common.mustCall());
256256

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+
257269
(async function() {
258270
await dnsPromises.lookup('', { family: 4, hints: 0 });
259271
await dnsPromises.lookup('', { family: 6, hints: dns.ADDRCONFIG });
260272
await dnsPromises.lookup('', { hints: dns.V4MAPPED });
261273
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+
});
262279
})();
263280

264281
{
Collapse file

‎test/parallel/test-net-connect-options-port.js‎

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 numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const net = require('net');
5959
// Test invalid hints
6060
{
6161
// connect({hint}, cb) and connect({hint})
62-
const hints = (dns.ADDRCONFIG | dns.V4MAPPED) + 42;
62+
const hints = (dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL) + 42;
6363
const hintOptBlocks = doConnect([{ hints }],
6464
() => common.mustNotCall());
6565
for (const fn of hintOptBlocks) {
Collapse file

‎test/parallel/test-tls-connect-hints-option.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-connect-hints-option.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ const hints = 512;
1515

1616
assert.notStrictEqual(hints, dns.ADDRCONFIG);
1717
assert.notStrictEqual(hints, dns.V4MAPPED);
18+
assert.notStrictEqual(hints, dns.ALL);
1819
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);
1923

2024
tls.connect({
2125
lookup: common.mustCall((host, options) => {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.