Uh oh!
There was an error while loading. Please reload this page.
dns: make dns.setServers support customized port - #13723
Conversation
Make `dns.setServers` parameter may be strings contain IP and port which split by `:`. eg. ``` dns.setServers([ "103.238.225.181:666" ]); ``` And `dns.getServers` will return IP with port if that server is not use default port. Refs: nodejs#7903
dns.setServers support customized portdns.setServers support customized portXadillaX
commented
Jun 16, 2017
@addaleax I think we can remove in progress label now. |
silverwind
commented
Jun 16, 2017
Maybe it's better to have the port as a separate argument so the user doesn't have to fiddle with the |
E.g.: dns.setServers([{address: '1.2.3.4',port: 5353},{address: '::1234:5678',port: 5353},'2.3.4.5']);So the method could both take a object or a string. It also has the benefit that we could extend these objects with future per-server options if necessary. |
@silverwind You mean let the function support |
refack
left a comment
There was a problem hiding this comment.
Got a little carried away with style suggestion... 🙄
| Returns an array of IP address strings that are being used for name | ||
| resolution. | ||
| Returns an array of IP address and port strings that are being used for name |
There was a problem hiding this comment.
🚲 🎪 Suggestion:
Returns an array of IP address strings, formatted according to [rfc3986][],
that are currently configured for DNS resolution. A string will include a port section
if a custom port is used.
...
[rfc3986]: https://tools.ietf.org/html/rfc3986#section-3.2.2
| @@ -484,10 +496,20 @@ added: v0.11.3 | |||
| --> | |||
| - `servers` {string[]} | |||
There was a problem hiding this comment.
- `servers` {string[]} array of [rfc3986][] formatted addresses
| Sets the IP addresses of the servers to be used when resolving. The `servers` | ||
| argument is an array of IPv4 or IPv6 addresses. | ||
| Sets the IP addresses and port of the servers to be used when resolving. The |
There was a problem hiding this comment.
Sets the IP address and port of servers to be used when performing DNS
resolution. If the port is the IANA default DNS port (53) it can be omitted.
| if (!val[1] || val[1] === 53) return val[0]; | ||
| const ipVersion = isIP(val[0]); | ||
| return ipVersion === 6 ? `[${val[0]}]:${val[1]}` : `${val[0]}:${val[1]}`; |
There was a problem hiding this comment.
Personal preference nit:
consthost=6 ? `[${val[0]}]` : val[0];return${host}:${val[1]};| if (ipVersion !== 0) | ||
| return newSet.push([ipVersion, match[1]]); | ||
| if (ipVersion !== 0) { | ||
| const portMatch = serv.match(addrSplitRE) || []; |
There was a problem hiding this comment.
personal style nit:
constaddrSplitRE=/(^.+?)(?::(\d+))?$/;constport=parseInt(serv.replace(addrSplitRE,'$2'))||53;returnnewSet.push([ipVersion,match[1],port);| } | ||
| } | ||
| const s = serv.split(addrSplitRE)[0]; |
There was a problem hiding this comment.
const[,s,p]=serv.match(addrSplitRE);refack
commented
Jun 16, 2017
🤔 If I understand correctly |
XadillaX
commented
Jun 16, 2017
@refack Yes you understood right. Refer here https://nodejs.org/docs/v8.0.0/api/dns.html#dns_dns_setservers_servers.
And the |
Hmm, right the docs even mention "If a port is specified on the address, it will be removed.", so I guess we're stuck with the syntax. And no, I wouldn't support three cases. Strictly speaking, this should be semver-major, but if CITGM turns out okay (which I expect), than minor is okay. |
refack
commented
Jun 16, 2017
XadillaX
commented
Jun 18, 2017
I think after this PR is landed, we can start the test for |
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/880/ @addaleax @nodejs/ctc PTAL at semver level |
| return cares.getServers(); | ||
| const ret = cares.getServers(); | ||
| return ret.map((val) => { | ||
| if (!val[1] || val[1] === 53) return val[0]; |
There was a problem hiding this comment.
I just noticed this, IMHO we should format IPv6 with [], so need to move the const host up:
e.g.
returnret.map(([host,port])=>{if(isIP(host)===6)host=`[${host}]`;return(!port||port===53) host : `${host}:${port}`;}But that will make this semver-major (since till now IPv6 would be represented without [])
Need to think about semver-level, and IPv6 string format
XadillaX
commented
Jun 19, 2017
@refack how about adding a parameter to indicate whether using customized port or not |
refack
commented
Jun 19, 2017
CITGM is clean. |
| ```js | ||
| [ | ||
| '4.4.4.4', | ||
| '[2001:4860:4860::8888]', |
There was a problem hiding this comment.
This still needs to be changed, since currently the output will be without the []
There was a problem hiding this comment.
>dns.setServers(['192.168.1.1','2001:4860:4860::8888'])undefined>dns.getServers()['192.168.1.1','2001:4860:4860::8888']| return cares.getServers(); | ||
| const ret = cares.getServers(); | ||
| return ret.map((val) => { | ||
| if (!val[1] || val[1] === 53) return val[0]; |
XadillaX
commented
Jun 19, 2017
Land this as SEMVER-MINOR? And what formatting for SEMVER-MAJOR? |
refack
commented
Jun 20, 2017
Landed in 330349f |
refack
commented
Jun 20, 2017
Extra sanity on |
allow `dns.setServers` parameter to contain port e.g. ``` dns.setServers([ '103.238.225.181:666' ]); ``` And `dns.getServers` will return IP with port if not the default port. PR-URL: #13723 Refs: #7903 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
allow `dns.setServers` parameter to contain port e.g. ``` dns.setServers([ '103.238.225.181:666' ]); ``` And `dns.getServers` will return IP with port if not the default port. PR-URL: #13723 Refs: #7903 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
allow `dns.setServers` parameter to contain port e.g. ``` dns.setServers([ '103.238.225.181:666' ]); ``` And `dns.getServers` will return IP with port if not the default port. PR-URL: #13723 Refs: #7903 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
allow `dns.setServers` parameter to contain port e.g. ``` dns.setServers([ '103.238.225.181:666' ]); ``` And `dns.getServers` will return IP with port if not the default port. PR-URL: #13723 Refs: #7903 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`23d41f3118`](2abaa86ba8)] [#13466](#13466) * **DNS** * The server used for DNS queries can now use a custom port. [[`2bb6614904`](8506acc1b5)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`30bc9dc20f`](30bc9dc20f)] [#13137](#13137) * **V8** * The V8 engine has been upgraded to version 5.9, which has a significantly changed performance profile. [#13515](#13515) PR-URL: #13744
allow `dns.setServers` parameter to contain port e.g. ``` dns.setServers([ '103.238.225.181:666' ]); ``` And `dns.getServers` will return IP with port if not the default port. PR-URL: #13723 Refs: #7903 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`820b011ed6`](820b011ed6)] [#13466](#13466) * **Cluster** * Users now have more fine-grained control over the inspector port used by individual cluster workers. Previously, cluster workers would simply increment from the master's debug port. [[`dfc46e262a`](dfc46e262a)] [#14140](#14140) * **DNS** * The server used for DNS queries can now use a custom port. [[`ebe7bb29aa`](ebe7bb29aa)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`6e30e2558e`](6e30e2558e)] [#13137](#13137) * **npm** * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes with the `npx` binary, which is also shipped with Node. [[`dc3f6b9ac1`](dc3f6b9ac1)] [#14235](#14235) * `npm` Changelogs: - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4) - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0) - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0) - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0) PR-URL: #13744
Big thanks to @addaleax who prepared the vast majority of this release. Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`820b011ed6`](nodejs@820b011ed6)] [nodejs#13466](nodejs#13466) * **Cluster** * Users now have more fine-grained control over the inspector port used by individual cluster workers. Previously, cluster workers would simply increment from the master's debug port. [[`dfc46e262a`](nodejs@dfc46e262a)] [nodejs#14140](nodejs#14140) * **DNS** * The server used for DNS queries can now use a custom port. [[`ebe7bb29aa`](nodejs@ebe7bb29aa)] [nodejs#13723](nodejs#13723) * Support for `dns.resolveAny()` has been added. [[`6e30e2558e`](nodejs@6e30e2558e)] [nodejs#13137](nodejs#13137) * **npm** * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes with the `npx` binary, which is also shipped with Node. [[`dc3f6b9ac1`](nodejs@dc3f6b9ac1)] [nodejs#14235](nodejs#14235) * `npm` Changelogs: - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4) - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0) - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0) - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0) PR-URL: nodejs#13744
Big thanks to @addaleax who prepared the vast majority of this release. Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`820b011ed6`](820b011ed6)] [#13466](#13466) * **Cluster** * Users now have more fine-grained control over the inspector port used by individual cluster workers. Previously, cluster workers would simply increment from the master's debug port. [[`dfc46e262a`](dfc46e262a)] [#14140](#14140) * **DNS** * The server used for DNS queries can now use a custom port. [[`ebe7bb29aa`](ebe7bb29aa)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`6e30e2558e`](6e30e2558e)] [#13137](#13137) * **npm** * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes with the `npx` binary, which is also shipped with Node. [[`dc3f6b9ac1`](dc3f6b9ac1)] [#14235](#14235) * `npm` Changelogs: - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4) - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0) - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0) - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0) PR-URL: #13744
Big thanks to @addaleax who prepared the vast majority of this release. Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`820b011ed6`](820b011ed6)] [#13466](#13466) * **Cluster** * Users now have more fine-grained control over the inspector port used by individual cluster workers. Previously, cluster workers would simply increment from the master's debug port. [[`dfc46e262a`](dfc46e262a)] [#14140](#14140) * **DNS** * The server used for DNS queries can now use a custom port. [[`ebe7bb29aa`](ebe7bb29aa)] [#13723](#13723) * Support for `dns.resolveAny()` has been added. [[`6e30e2558e`](6e30e2558e)] [#13137](#13137) * **npm** * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes with the `npx` binary, which is also shipped with Node. [[`dc3f6b9ac1`](dc3f6b9ac1)] [#14235](#14235) * `npm` Changelogs: - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4) - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0) - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0) - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0) PR-URL: #13744
gibfahn
commented
Jan 15, 2018
Release team decided not to land on v6.x, if you disagree let us know. |
Make
dns.setServersparameter may be strings contain IP and port whichsplit by
:.eg.
And
dns.getServerswill return IP with port if that server is not usedefault port.
Refs: #7903
Checklist
make -j4 test(UNIX)Affected core subsystem(s)
dns