Skip to content
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

verbatim flag for dns resolution does not change order #17802

Closed
asbachb opened this issue Dec 21, 2017 · 4 comments
Closed

verbatim flag for dns resolution does not change order #17802

asbachb opened this issue Dec 21, 2017 · 4 comments
Labels
dns Issues and PRs related to the dns subsystem. question Issues that look for answers.

Comments

@asbachb
Copy link

asbachb commented Dec 21, 2017

I currently have some issues with dual stack ipv6 resolution. The nodejs dns module returns ipv4 address instead of expected ipv6.

I saw there was a PR which introduced a verbatim flag: #14731

Based on the test (https://github.com/nodejs/node/pull/14731/files#diff-91621d3f4af56103203147a5cc370565) I tried to do some test code to validate if it's doing what I expect: Order the ipv6 before the ipv4 which was not the case:

const domain = 'google.com'

const cares = process.binding('cares_wrap');
const req1 = new cares.GetAddrInfoReqWrap();

dns(false);
dns(true);

function dns(verbatim) {
  const req = new cares.GetAddrInfoReqWrap();
  cares.getaddrinfo(req, domain, 0, /* hints */ 0, /* verbatim */ verbatim);

  req.oncomplete = function(err, domains) {
    console.log('%s = ', domain, domains);
  };
}

output:

google.com =  [ '172.217.23.142', '2a00:1450:4001:81e::200e' ]
google.com =  [ '172.217.23.142', '2a00:1450:4001:81e::200e' ]
@cjihrig
Copy link
Contributor

cjihrig commented Dec 21, 2017

My understanding was that verbatim just means that the DNS results are not sorted. That doesn't guarantee that IPv6 will come first.

Side question: Why are you using process.binding() instead of dns.lookup()?

@asbachb
Copy link
Author

asbachb commented Dec 21, 2017

I also had some windows test system which results in:

google.com =  [ '2a00:1450:4001:806::200e', '216.58.205.238' ]
google.com =  [ '2a00:1450:4001:806::200e', '216.58.205.238' ]

So I don't get when the verbatim flag is doing anything.

@cjihrig, Since dns.lookup didn't returned the expected result I dived a little bit deeper unto dns.js and saw that in my use case only the first result of getaddrinfo is used: https://github.com/nodejs/node/blob/master/lib/dns.js#L95-L104
So I wrote a test case based on process.binding().

@bnoordhuis bnoordhuis added dns Issues and PRs related to the dns subsystem. question Issues that look for answers. labels Dec 21, 2017
@bnoordhuis
Copy link
Member

So I don't get when the verbatim flag is doing anything.

verbatim does exactly what it says - when true, it returns the results as it receives them from the resolver. (I'm basically restating what Colin already said...)

If you only want IPv6 results, query for AAAA records. I'll close this out.

@asbachb
Copy link
Author

asbachb commented Dec 21, 2017

Just to complete this one. I did the mistake to run this on the wrong machine. On a host with correct ipv6 configuration the test code results to:

google.com =  [ '216.58.204.142', '2a00:1450:4007:812::200e' ]
google.com =  [ '2a00:1450:4007:812::200e', '216.58.204.142' ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dns Issues and PRs related to the dns subsystem. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

3 participants