Skip to content

Instantly share code, notes, and snippets.

@commadelimited
Last active December 16, 2015 03:40
Show Gist options
  • Save commadelimited/5a564b1fa1bec2b44540 to your computer and use it in GitHub Desktop.
Save commadelimited/5a564b1fa1bec2b44540 to your computer and use it in GitHub Desktop.
Node.js dns.resolve "bug"?

I'm pulling company data from a file server, simon.int (dataDomain). While connected to our network via ethernet cable, or our internal wireless network I can access the file server via both browser, and via Node.js dns.resolve. If I'm outside our network I can't connect via either browser or Node's dns.resolve method (as expected). The problem arises when I connect to our internal network via VPN. I can open simon.int in a browser, I can ping it, etc. yet dns.resolve returns an error when trying to connect to it.

I feel that this is a bug, but I can't find documentation of any sort of expectation of how it should work. I'm trying to determine whether I should report it as a bug, or if my expectation of it is incorrect. I ended up getting around it by making a jQuery AJAX HEAD request just to see if the server was available or not (works great).

I'd love input on this subject, or a pointer in the right direction.

A fellow developer suggested that perhaps it amounted to the user that Node was running as vs "me" accessing simon.int via ping or the browser.

FYI my version of Node:

$ node --version
v0.10.26
publicMethods.checkConnection = function(success, failure, bypass) {
/*
Checks to make sure application has an active connection
to the domain hosting the data file
*/
var dataDomain = 'simon.int';
$.ajax('http://' + dataDomain, {type: 'HEAD'})
.done(function(d){
success();
})
.fail(function(e){
if (publicMethods.checkExistingDataFile()) {
bypass();
} else {
failure();
}
});
// the code below is the desired implementation but for some reason
// Node.js' dns.resolve method fails when connecting to simon.int
// Is it our implementation or a bug in Node? Either way, good old jQuery
// saves the day. Would be nice to revert to this method at some point
// in the future.
// var dns = require("dns");
// dns.resolve(dataDomain, function(error, addr){
// if (error) {
// if (publicMethods.checkExistingDataFile()) {
// bypass();
// } else {
// failure();
// }
// } else {
// success();
// }
// });
};
@jorendorff
Copy link

I suspect this is a bug.

C-Ares has to query Windows to ask “What DNS server should I use?” which most likely ends up here: https://github.com/bagder/c-ares/blob/master/ares_init.c#L914

Maybe it's not correctly interpreting the result when VPN is enabled, and connecting to the wrong DNS server as a result. Wireshark would tell the story, I bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment