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

Add possibility to set DNS server #1

Closed
throrin19 opened this issue Mar 31, 2016 · 2 comments
Closed

Add possibility to set DNS server #1

throrin19 opened this issue Mar 31, 2016 · 2 comments
Assignees

Comments

@throrin19
Copy link

Hi, It's possible to set the dns server used to resolve the SRV request ?

@JonGretar
Copy link
Owner

At the time I think that the dns servers in use by dns.resolve*() are set in a global state. So in theory you could do something like this:

var dns = require('dns');
dns.setServers(['10.10.1.200', '10.10.1.199']);
var request = require('srv-request');
    ...rest of your code...

Be mindful that calling dns.setServers() while a dns request is in progress will crash your code so don't be setting this except at startup. And it will also direct other dns.resolve*() of your app or required modules to that server not only those in use by srv-request. But dns.lookup() uses the systems getaddrinfo(3) so it will not be changed.

I'm not set up to test this right now but please try it and let me know if it did the trick. Otherwise we might have to wait for PR nodejs/node#1843 to be approved.

@JonGretar JonGretar self-assigned this Apr 1, 2016
@throrin19
Copy link
Author

I test this and it works fine with this solution

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