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

Use native nodejs dns API #11

Open
foaadnami opened this issue Jan 14, 2021 · 6 comments
Open

Use native nodejs dns API #11

foaadnami opened this issue Jan 14, 2021 · 6 comments

Comments

@foaadnami
Copy link

Hi Mark
Not sure if this is even feasible but it appears like the dns library being used is perhaps outdated and not maintained
Wondering if there is merit in using nodejs native DNS api https://nodejs.org/api/dns.html

Btw, thanks for the "releases" move!

@markSmurphy
Copy link
Owner

The native DNS api doesn't provide enough customisation of the DNS question. The library I used allows me to specify and remote DNS resolver while also turning off DNS caching and EDNS0.
native-dns-multisocket request options
This combination ensures I resolve the IP address that would be returned if I were located in that region.

I noticed native-dns-multisocket hasn't been updated for quite a while, but nether has DNS so maybe there's been no need.

If you know of an alternative package I'd happy to look into it.

Maybe I'll request native support via nodejs/node

@foaadnami
Copy link
Author

Native DNS API wraps a C library called c-ares which appears to be well maintained
You may specifiy a remote DNS resolver using dns.setServers(servers)
I dont think the native API caches but thats perhaps a good thing for a tool like this ?
Native API doesnt seem to support EDNS0 although c-ares seems to do

@markSmurphy
Copy link
Owner

I did try to go native initially, and I've been trying to remember why I ended up looking around for a package. So I tried again to refamiliarise myself; it turns out the dns.setServers only affects dns.resolve and not dns.lookup(). dns.resolve() doesn't return the full Answer. So `dns.Resolve('example.com', 'CNAME') only returns the CNAME that example.com resovles to (if it does), and dns.Resolve('example.com', 'A') only returns the A record(s).

So and hostname which is just an A record would require a failed CNAME query just to check if there is one, and a hostname which uses CNAMES would require a lookup per CNAME record and a final one for the A record.

Not impossible to iterate through all the records, but not optimal either. So I wanted a single call that would return the Answer to full recursive lookup.

If you know of a native way of returning the full DNS answer I'd be interested.

@foaadnami
Copy link
Author

I see the problem. I suggested something via nodejs/node#36973

Please feel free to support/extend!

@foaadnami
Copy link
Author

One option I played with, albeit radical, is to send the DNS question as a UDP datagram.
This project will abstract the consturction and presentation of the DNS packet
https://github.com/mafintosh/dns-packet

@markSmurphy
Copy link
Owner

Thanks @foaadnami, I'll take a look. It's interesting for support of DNS over HTTPS too (which was on my To Do list).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants