-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Add version of dns.lookup that returns all results #736
Comments
This seems like a pretty simple addition. I'd be fine with working on it, if others find it useful. I think the window is currently open for a minor version bump too. |
This seems like a perfectly reasonable addition to me. It doesn't even need a new function; dns.lookup('google.com', { all: true }, function(err, addrs) { /* ... */ }); // strawman The callback gets the address family as its third argument now. For the |
I'll start working on this according to @bnoordhuis's proposal, if that's ok with you, @cjihrig. |
@silverwind sure. I was thinking you might just want to change this line to point to another function. And the callback would change from |
My first approach would've been to modify |
I figured it would be simpler, with less chance of breaking existing code, to just point to a new function. The two functions will have very little overlap except checking for an error. |
True, I'll add an second function then, definitely safer. |
Any opinions if the address field in the object should be called |
FWIW, I don't have a strong opinion. I just thought |
We call it |
I'll put this up shortly for a PR, just have to test on OS X, as apparently my Windows machine isn't able to |
Thanks! Landed in eb30009de65a9432b59ae77a425b623df28dbd27 with a tweaked commit message. EDIT: Someone performed a force push after I landed this. So the mentioned commit was overwritten. The actual commit is now 633a990 |
The
dns
module provides two sets of methods: theresolve
family, which directly resolves using the DNS protocol, and thelookup
function, which uses the system resolver (throughgetaddrinfo
) and returns at most one address.It's often preferable to use the system resolver, since it can use things like mDNS. However, using the
dns.lookup
API makes it impossible to receive multiple IP addresses in response to a DNS query (See #708 for motivating example).Proposal: Add a new function
dns.lookupAll
that behaves likedns.lookup
, but returns all addresses given bygetaddrinfo
.The text was updated successfully, but these errors were encountered: