-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature. Set DNS server port for DNS client #7903
Comments
We could add support for port numbers. Can you explain your use case though? I've never seen a DNS server on a non-standard port, not even in testing setups. |
It's mainly for an e2e test suite to be run on a production server that already is serving DNS. I didn't want to have to spin up another server or shutdown the existing DNS server. Maybe to reduce impact, we could keep the existing behavior and have an options flag to use the ares_set_server_ports() function? |
I've added the 'feature request' label. Pull requests welcome but I won't vouch they'll get accepted. It seems like a rather esoteric feature when you can't even configure /etc/resolv.conf to use a non-standard port. |
System resolvers rarely allow non-standard ports - rightfully so - but application resolvers often do allow them for various reasons. I wouldn't consider Node.js to be a system level resolver and thus supporting non-standard ports might not be so "esoteric feature". In addition to network domains, DNS can be used for other purposes. For example as a P2P service discovery protocol, where use of custom ports is desired. In this case, port is not used to differentiate the technical protocol, but the type of content served. Right now, Node.js can not be used to implement clients for these kinds of service discovery implementations; or at least not by using it's built-in resolver. |
Not against it, but also not really thrilled about a likely required sync-style method like I'd generally recommend dns-socket which can do pretty much everything tools like |
To be honest, the entire DNS module is a bit ripe for refactoring. There are challenges with |
Yeah, |
I remember seeing some discussion / PRs for transitioning to pure JS DNS resolver. What is the status of that? |
@mscdex can comment more specifically but it stalled out due to an inability to get the necessary performance. |
@jasnell Yep. |
@mscdex Just curious, what type of performance degradation? DNS isn't exactly a high frequency, high bandwidth protocol by it's nature. I'd expect native c-ares to offer better latency and more queries per second, but does minor performance degradation even matter for a any real world DNS usage scenario? |
@mscdex Benchmark results you linked are proving your point, 1000 queries in 44ms for c-ares and 130ms for JS resolver. However, 1000 queries/responses from single client to single DNS server within 44ms timeframe is very far from typical usage. But still slower - no arguing with that. I looked briefly at other languages DNS libraries. Most seem to offer just a wrapper for accessing the system resolver. Why Node.js has to ship with it's own application level resolver; and more importantly why not just leave this job for thin libuv abstraction? |
In a word: performance. System resolvers typically don't have an asynchronous or non-blocking interface so you're forced to start 1,000 threads if you want to do 1,000 concurrent lookups. |
@imyller The system resolver API isn't very flexible and is pretty limited. It's there to basically resolve hostnames to A or AAAA records (or vice versa) and nothing else. Also you're typically restricted to how the system resolver works, so for example you can't easily bypass system-configured DNS modules and just communicate with a DNS server from node. The glibc resolver has more flags nowadays but IIRC there is no (good) way to pass those at runtime. Having a "userland" resolver like c-ares allows us to make more kinds of DNS queries and better control over TTL and other things. However, c-ares is far from perfect and lacks features that modern system resolvers have (e.g. DNSSEC for those that care about that). |
Good points. I see that it's not trivial to improve Node.js DNS features while getting the performance required. |
Interesting non-blocking resolver project: https://github.com/wahern/dns Seems to be MIT licensed. Good features. Pluggable cache interface etc. |
https://www.consul.io/docs/agent/dns.html |
+1 for custom port I run two different DNS resolvers on my production box. One of them runs with normal settings and is for the system and generic apps, the other is for an app that requires custom settings and very short cache retention. For now I'm going to use Edit: switched to native-dns as I can't get dns-socket to work somehow. |
I also want to run the dnsmasq service locally on a non-standard port, and then query against it with my nodejs app (since my node app runs on port 53).. I want to leverage the dnsmasq caching etc.. |
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
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: nodejs#13723 Refs: nodejs#7903 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Fixed in #13723 |
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
the Docs on the DNS client say that the dns.setServers(servers) method will strip out any custom ports provided. "If a port specified on the address it will be removed."
I'm curious if there is a specific reason for not wanting to support it, or is it planned to be supported?
The text was updated successfully, but these errors were encountered: