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

Question: does dns.resolveMx support unicode domains? #11218

Closed
WesTyler opened this issue Feb 7, 2017 · 2 comments
Closed

Question: does dns.resolveMx support unicode domains? #11218

WesTyler opened this issue Feb 7, 2017 · 2 comments
Labels
dns Issues and PRs related to the dns subsystem. question Issues that look for answers.

Comments

@WesTyler
Copy link
Contributor

WesTyler commented Feb 7, 2017

  • Version: v6.9.0
  • Platform: 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
  • Subsystem: DNS

According to this article, the domain 域通联达。在线 should return a valid MX record. But calling dns.resolveMX returns an error:

dns.resolveMx('域通联达。在线', (err, record) => {console.log(err); console.log(record);})
QueryReqWrap {
  bindingName: 'queryMx',
  callback: { [Function: asyncCallback] immediately: true },
  hostname: '域通联达。在线',
  oncomplete: [Function: onresolve],
  domain:
   Domain {
     domain: null,
     _events: { error: [Function] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> { Error: queryMx ENOTFOUND 域通联达。在线
    at errnoException (dns.js:28:10)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:216:19)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'queryMx',
  hostname: '域通联达。在线' }
undefined

If this is not an issue within the dns api but with that specific domain, can you point me to an international domain for which the .resolveMX call is working?

@bnoordhuis
Copy link
Member

You need two additional steps. This should work:

const dns = require('dns');
const punycode = require('punycode');

const domain = '域通联达。在线';

dns.resolveMx(punycode.toASCII(domain.replace(//, '.')), (err, res) => {
  if (err) throw err;
  console.log(res);
});

However, this particular domain doesn't appear to have MX records. It does have an A record though; dns.resolve(...) prints a result.

@WesTyler
Copy link
Contributor Author

WesTyler commented Feb 7, 2017

Ah, ok. I was hoping punycoding wouldn't be necessary. Thanks very much, that's what I was needing to know!

@WesTyler WesTyler closed this as completed Feb 7, 2017
@Fishrock123 Fishrock123 added dns Issues and PRs related to the dns subsystem. question Issues that look for answers. labels Feb 7, 2017
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