GeezerVison is showing github.com — dns: default to verbatim=true in dns.lookup() · nodejs/node@1b2749e
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 +5-3Lines changed: 5 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -170,6 +170,9 @@ section if a custom port is used. | 170 | 170 | <!-- YAML | 171 | 171 | added: v0.1.90 | 172 | 172 | changes: | | 173 | + - version: REPLACEME | | 174 | + pr-url: https://github.com/nodejs/node/pull/39987 | | 175 | + description: The `verbatim` options defaults to `true` now. | 173 | 176 | - version: v8.5.0 | 174 | 177 | pr-url: https://github.com/nodejs/node/pull/14731 | 175 | 178 | description: The `verbatim` option is supported now. | @@ -190,10 +193,9 @@ changes: | 190 | 193 | * `verbatim` {boolean} When `true`, the callback receives IPv4 and IPv6 | 191 | 194 | addresses in the order the DNS resolver returned them. When `false`, | 192 | 195 | IPv4 addresses are placed before IPv6 addresses. | 193 | | - **Default:** currently `false` (addresses are reordered) but this is | 194 | | - expected to change in the not too distant future. Default value is | | 196 | + **Default:** `true` (addresses are reordered). Default value is | 195 | 197 | configurable using [`dns.setDefaultResultOrder()`][] or | 196 | | - [`--dns-result-order`][]. New code should use `{ verbatim: true }`. | | 198 | + [`--dns-result-order`][]. | 197 | 199 | * `callback` {Function} | 198 | 200 | * `err` {Error} | 199 | 201 | * `address` {string} A string representation of an IPv4 or IPv6 address. | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/dns/utils.js +2-8Lines changed: 2 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -193,16 +193,10 @@ function emitInvalidHostnameWarning(hostname) { | 193 | 193 | ); | 194 | 194 | } | 195 | 195 |
| 196 | | -let dnsOrder = getOptionValue('--dns-result-order') || 'ipv4first'; | | 196 | +let dnsOrder = getOptionValue('--dns-result-order') || 'verbatim'; | 197 | 197 |
| 198 | 198 | function getDefaultVerbatim() { | 199 | | - switch (dnsOrder) { | 200 | | - case 'verbatim': | 201 | | - return true; | 202 | | - case 'ipv4first': | 203 | | - default: | 204 | | - return false; | 205 | | - } | | 199 | + return dnsOrder !== 'ipv4first'; | 206 | 200 | } | 207 | 201 |
| 208 | 202 | function setDefaultResultOrder(value) { | |
Collapse file Copy file name to clipboardExpand all lines: test/common/inspector-helper.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -392,7 +392,7 @@ class NodeInstance extends EventEmitter { | 392 | 392 | console.log('[test]', `Testing ${path}`); | 393 | 393 | const headers = hostHeaderValue ? { 'Host': hostHeaderValue } : null; | 394 | 394 | return this.portPromise.then((port) => new Promise((resolve, reject) => { | 395 | | - const req = http.get({ host, port, path, headers }, (res) => { | | 395 | + const req = http.get({ host, port, family: 4, path, headers }, (res) => { | 396 | 396 | let response = ''; | 397 | 397 | res.setEncoding('utf8'); | 398 | 398 | res | @@ -418,6 +418,7 @@ class NodeInstance extends EventEmitter { | 418 | 418 | const port = await this.portPromise; | 419 | 419 | return http.get({ | 420 | 420 | port, | | 421 | + family: 4, | 421 | 422 | path: parseURL(devtoolsUrl).path, | 422 | 423 | headers: { | 423 | 424 | 'Connection': 'Upgrade', | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-cluster-message.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,7 @@ if (cluster.isWorker) { | 60 | 60 | maybeReply(); | 61 | 61 | }); | 62 | 62 |
| 63 | | - server.listen(0, '127.0.0.1'); | | 63 | + server.listen(0); | 64 | 64 | } else if (cluster.isPrimary) { | 65 | 65 |
| 66 | 66 | const checks = { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-http-localaddress.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,7 @@ const server = http.createServer((req, res) => { | 42 | 42 | server.listen(0, '127.0.0.1', () => { | 43 | 43 | const options = { host: 'localhost', | 44 | 44 | port: server.address().port, | | 45 | + family: 4, | 45 | 46 | path: '/', | 46 | 47 | method: 'GET', | 47 | 48 | localAddress: '127.0.0.2' }; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-http-upgrade-client.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ const server = net.createServer(function(c) { | 49 | 49 | }); | 50 | 50 | }); | 51 | 51 |
| 52 | | -server.listen(0, '127.0.0.1', common.mustCall(function() { | | 52 | +server.listen(0, common.mustCall(function() { | 53 | 53 | const port = this.address().port; | 54 | 54 | const headers = [ | 55 | 55 | { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-http2-connect-options.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ const server = http2.createServer((req, res) => { | 22 | 22 | }); | 23 | 23 |
| 24 | 24 | server.listen(0, '127.0.0.1', common.mustCall(() => { | 25 | | - const options = { localAddress: '127.0.0.2' }; | | 25 | + const options = { localAddress: '127.0.0.2', family: 4 }; | 26 | 26 |
| 27 | 27 | const client = http2.connect( | 28 | 28 | 'http://localhost:' + server.address().port, | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-https-localaddress.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,6 +52,7 @@ server.listen(0, '127.0.0.1', function() { | 52 | 52 | const options = { | 53 | 53 | host: 'localhost', | 54 | 54 | port: this.address().port, | | 55 | + family: 4, | 55 | 56 | path: '/', | 56 | 57 | method: 'GET', | 57 | 58 | localAddress: '127.0.0.2', | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-net-connect-options-port.js +24-12Lines changed: 24 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -83,7 +83,7 @@ const net = require('net'); | 83 | 83 | } | 84 | 84 | }, expectedConnections)); | 85 | 85 |
| 86 | | - server.listen(0, 'localhost', common.mustCall(() => { | | 86 | + server.listen(0, common.localhostIPv4, common.mustCall(() => { | 87 | 87 | const port = server.address().port; | 88 | 88 |
| 89 | 89 | // Total connections = 3 * 4(canConnect) * 6(doConnect) = 72 | @@ -133,28 +133,35 @@ function doConnect(args, getCb) { | 133 | 133 | } | 134 | 134 |
| 135 | 135 | function syncFailToConnect(port, assertErr, optOnly) { | | 136 | + const family = 4; | 136 | 137 | if (!optOnly) { | 137 | 138 | // connect(port, cb) and connect(port) | 138 | | - const portArgFunctions = doConnect([port], () => common.mustNotCall()); | | 139 | + const portArgFunctions = doConnect([{ port, family }], | | 140 | + () => common.mustNotCall()); | 139 | 141 | for (const fn of portArgFunctions) { | 140 | 142 | assert.throws(fn, assertErr, `${fn.name}(${port})`); | 141 | 143 | } | 142 | 144 |
| 143 | 145 | // connect(port, host, cb) and connect(port, host) | 144 | | - const portHostArgFunctions = doConnect([port, 'localhost'], | | 146 | + const portHostArgFunctions = doConnect([{ port, | | 147 | + host: 'localhost', | | 148 | + family }], | 145 | 149 | () => common.mustNotCall()); | 146 | 150 | for (const fn of portHostArgFunctions) { | 147 | 151 | assert.throws(fn, assertErr, `${fn.name}(${port}, 'localhost')`); | 148 | 152 | } | 149 | 153 | } | 150 | 154 | // connect({port}, cb) and connect({port}) | 151 | | - const portOptFunctions = doConnect([{ port }], () => common.mustNotCall()); | | 155 | + const portOptFunctions = doConnect([{ port, family }], | | 156 | + () => common.mustNotCall()); | 152 | 157 | for (const fn of portOptFunctions) { | 153 | 158 | assert.throws(fn, assertErr, `${fn.name}({port: ${port}})`); | 154 | 159 | } | 155 | 160 |
| 156 | 161 | // connect({port, host}, cb) and connect({port, host}) | 157 | | - const portHostOptFunctions = doConnect([{ port: port, host: 'localhost' }], | | 162 | + const portHostOptFunctions = doConnect([{ port: port, | | 163 | + host: 'localhost', | | 164 | + family: family }], | 158 | 165 | () => common.mustNotCall()); | 159 | 166 | for (const fn of portHostOptFunctions) { | 160 | 167 | assert.throws(fn, | @@ -165,27 +172,30 @@ function syncFailToConnect(port, assertErr, optOnly) { | 165 | 172 |
| 166 | 173 | function canConnect(port) { | 167 | 174 | const noop = () => common.mustCall(); | | 175 | + const family = 4; | 168 | 176 |
| 169 | 177 | // connect(port, cb) and connect(port) | 170 | | - const portArgFunctions = doConnect([port], noop); | | 178 | + const portArgFunctions = doConnect([{ port, family }], noop); | 171 | 179 | for (const fn of portArgFunctions) { | 172 | 180 | fn(); | 173 | 181 | } | 174 | 182 |
| 175 | 183 | // connect(port, host, cb) and connect(port, host) | 176 | | - const portHostArgFunctions = doConnect([port, 'localhost'], noop); | | 184 | + const portHostArgFunctions = doConnect([{ port, host: 'localhost', family }], | | 185 | + noop); | 177 | 186 | for (const fn of portHostArgFunctions) { | 178 | 187 | fn(); | 179 | 188 | } | 180 | 189 |
| 181 | 190 | // connect({port}, cb) and connect({port}) | 182 | | - const portOptFunctions = doConnect([{ port }], noop); | | 191 | + const portOptFunctions = doConnect([{ port, family }], noop); | 183 | 192 | for (const fn of portOptFunctions) { | 184 | 193 | fn(); | 185 | 194 | } | 186 | 195 |
| 187 | 196 | // connect({port, host}, cb) and connect({port, host}) | 188 | | - const portHostOptFns = doConnect([{ port, host: 'localhost' }], noop); | | 197 | + const portHostOptFns = doConnect([{ port, host: 'localhost', family }], | | 198 | + noop); | 189 | 199 | for (const fn of portHostOptFns) { | 190 | 200 | fn(); | 191 | 201 | } | @@ -198,20 +208,22 @@ function asyncFailToConnect(port) { | 198 | 208 | }); | 199 | 209 |
| 200 | 210 | const dont = () => common.mustNotCall(); | | 211 | + const family = 4; | 201 | 212 | // connect(port, cb) and connect(port) | 202 | | - const portArgFunctions = doConnect([port], dont); | | 213 | + const portArgFunctions = doConnect([{ port, family }], dont); | 203 | 214 | for (const fn of portArgFunctions) { | 204 | 215 | fn().on('error', onError()); | 205 | 216 | } | 206 | 217 |
| 207 | 218 | // connect({port}, cb) and connect({port}) | 208 | | - const portOptFunctions = doConnect([{ port }], dont); | | 219 | + const portOptFunctions = doConnect([{ port, family }], dont); | 209 | 220 | for (const fn of portOptFunctions) { | 210 | 221 | fn().on('error', onError()); | 211 | 222 | } | 212 | 223 |
| 213 | 224 | // connect({port, host}, cb) and connect({port, host}) | 214 | | - const portHostOptFns = doConnect([{ port, host: 'localhost' }], dont); | | 225 | + const portHostOptFns = doConnect([{ port, host: 'localhost', family }], | | 226 | + dont); | 215 | 227 | for (const fn of portHostOptFns) { | 216 | 228 | fn().on('error', onError()); | 217 | 229 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-net-dns-lookup.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,12 +29,12 @@ const server = net.createServer(function(client) { | 29 | 29 | server.close(); | 30 | 30 | }); | 31 | 31 |
| 32 | | -server.listen(0, '127.0.0.1', common.mustCall(function() { | | 32 | +server.listen(0, common.mustCall(function() { | 33 | 33 | net.connect(this.address().port, 'localhost') | 34 | 34 | .on('lookup', common.mustCall(function(err, ip, type, host) { | 35 | 35 | assert.strictEqual(err, null); | 36 | | - assert.strictEqual(ip, '127.0.0.1'); | 37 | | - assert.strictEqual(type, 4); | | 36 | + assert.match(ip, /^(127\.0\.0\.1|::1)$/); | | 37 | + assert.match(type.toString(), /^(4|6)$/); | 38 | 38 | assert.strictEqual(host, 'localhost'); | 39 | 39 | })); | 40 | 40 | })); |
|