-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
dns: add new DNS resolver and set it as default #1843
Conversation
Some things to note:
Now for some questions:
/cc @nodejs/collaborators |
Does this fix #894? |
if (!running) { | ||
next(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this to test/common.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno, I just copied it from one of the other existing test files.
@ChALkeR It definitely doesn't crash when calling |
} | ||
|
||
if (typeof resolver === 'function') | ||
resolver(hostname, callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old implementation did return a resolver instance (https://github.com/nodejs/io.js/blob/8059393934c2ed0e3e7a179f619b803291804344/lib/dns.js#L271) here. Not sure if it's worth to do so, as apparently this return value was never documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, a request object. There is no such thing to return anymore and I hate to just return some fake object just for the sake of returning something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree, but it's a tiny change of undocumented functionality. I'd suggest putting a semver-minor
because of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it may already be a semver-major
because it's replacing a lot of machinery. At least I thought that was the case for the replacement of the url
module and the http parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it may as well be a major, because there ought to be more differences.
Noticed another difference: Responses without an answer section triggered an edit: here's such an response:
|
@silverwind I was doing that initially, but IIRC some tests failed when I did that? |
@mscdex maybe those tests are flawed? Remember which ones? I can definitely see the difference, but it might be hard to reproduce on your side, as I think it's an oddity of my dnsmasq configuration that I don't get an NXDOMAIN. |
@silverwind Do you know which test that is in particular? |
Here's what I like to see:
|
@silverwind TTL support is not a problem, we'd just need to figure out the best way to return that information. I'm curious though about the arbitrary RRTYPE use cases. What did you have in mind? |
Well, there's a whole lot of RRTYPEs one can't query for with the current methods, and as new ones get added all the time, it might be too much work to keep up with these. I once wanted to query the SPF RRTYPE (now deprecated in favor of TXT), and I think it should be at least be possible to access the various DNSSEC records so one could implement DNSSEC in userland. It's a necessary low-level API imho. |
I'd say arbitrary rtypes is a nice to have but not critical. The
|
@silverwind The problem though is that to use something like DNSSEC, core would have to be able to know about DNSSEC, because there are special interactions (EDNS0) that can occur between RRs and the normal DNS header (e.g. the RCODE being combined with a value in the RR itself to represent the real, extended RCODE). This problem exists both for sending and receiving abitrary RRs (like DNSSEC). |
Back on the But we should clearly communicate this change in the release notes, as I think it may be pretty common for a user to just check for |
Regarding TTL, I could see changing the signature of
Possible options:
Regarding the breaking changes, I'm more leaning towards keeping old error codes and |
A couple of other differences between this resolver and c-ares:
|
Does this mean that lookup isn't calling the native routines, you just parse some of the static entries out of hosts, and the like? This is pretty different than now, isn't it? The native resolvers are often pluggable, you'll get results from mDNS, sun white pages, NIS, etc. My understanding was lookup existed specifically to be the same as the native resolver, because it used the native resolver. Also, that with pure c-ares/resolution-by-DNS, that users were reporting bugs against node when it didn't return the same results as all the other applications running on their systems. |
@sam-github That's correct, my goal was to avoid having to go to the thread pool. |
|
Was it ever on the table to remove DNS from core? I know, I know it would break things, but stay with me, maybe there is a way around that. Here is an idea:
This way, core still has the DNS capability it needs (getaddrinfo basically, if I'm not mistaken), and users have a bunch of options for their DNS needs on NPM:
So, c-ares could be released on NPN, and Node could deprecate it (by printing a deprecation warning), then eventually remove it. The deprecation warning for dns.lookup and dns.lookupService would point users at net.getaddrinfo / net.getnameinfo. And those are my 2 cents! |
@silverwind How about if we encounter nss modules other than |
FWIW I'm -1 on removing dns client functionality from core as I see it as being equally important as http for example. |
This fixes code consistency, formatting, and linting issues. It also arranges the tests alphabetically.
By the way, would it be hard to support DNS classes other than
|
@silverwind Probably not, but I'm not sure how common non-Internet requests are these days? |
Pretty uncommon, but the Anyways, I think we should support a signature of More info on those two classes: https://miek.nl/posts/2009/Jul/31/dns-classes/ |
Oh, and feel free to ignore my feature requests, these are probably better done after this has landed with the current functionality in place. |
@silverwind even more reason to have this land soon. @mscdex could you rebase? I'd like to get a CI run going (tried but got conflicts). |
@jbergstroem It might be awhile, I'm working on several different implementations locally while trying to squeeze out as much performance as possible, so my working directory is a little messy at the moment. |
FWIW, +1 The existing c-ares DNS error messages are...obtuse and I'd welcome having to change 100 instances of my programs that check for specific DNS errors in exchange for having real DNS errors. |
I'm not sure if this will pan out as planned.... I can't seem to get latency close enough to the existing dns mechanism. I'm not sure what exactly is to blame as the For example, performing 1000 simple IPv4 Also IIRC I don't think even removing the |
@mscdex any plans to try and get this in for v6? |
@thealphanerd No. As previously noted I'm not sure it will be possible to get the latency close enough to the existing resolver(s). Having a fair amount of additional latency is probably not something most people are willing to sacrifice when it comes to something like dns resolution. |
7da4fd4
to
c7066fb
Compare
@mscdex any chance to ship it behind a flag in some v6 minor so people can play with it? Are you still interested in this PR? |
@benjamingr IMHO if we can't get performance to at least be approximately the same as using c-ares, then it's probably not worth making available. To me, dns is one of those things where speed is most important. I'm interested in it as much as I am interested in the pure js http parser, but if performance isn't there right now, it's not worth integrating yet. |
@mscdex are you still working on this? |
Tend to agree here. Even behind a flag if the performance isn't there it's not worth getting in. @mscdex ... this is something that I'd ultimately like to see happen tho... is it something you're still actively pursuing at all or just have it on the back burner? |
@jasnell It's more or less on the back burner for now. I'm still not sure if it will be possible to match the speed from js land, since even using bare UDPWrap does not help (enough). It could entirely be I'm missing something obvious, but I don't know. |
@mscdex ... given the stalled status, the merge conflicts, and the uncertainty about this moving forward, I'm going to go ahead and close. Obviously we can reopen if we decide to move forward with this direction. |
This adds a new pure JavaScript resolver as the default DNS resolver and makes the old (c-ares) resolver behind a
--use-old-dns
flag.