Browse Source

De-indent dns.lookup

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
5e11b8a937
  1. 18
      lib/dns.js

18
lib/dns.js

@ -108,6 +108,7 @@ exports.getHostByAddr = function (address, family/*=4*/, callback) {
// Easy DNS A/AAAA look up
// lookup(domain, [family,] callback)
exports.lookup = function (domain, family, callback) {
// parse arguments
if (arguments.length === 2) {
callback = family;
family = undefined;
@ -121,21 +122,27 @@ exports.lookup = function (domain, family, callback) {
throw new Error('invalid argument: "family" must be 4 or 6');
}
}
if (!domain) {
callback(null, null, family === 6 ? 6 : 4);
return;
}
var matchedFamily = net.isIP(domain);
if (matchedFamily) {
callback(null, domain, matchedFamily);
} else {
return;
}
if (/\w\.local\.?$/.test(domain)) {
// ANNOYING: In the case of mDNS domains use NSS in the thread pool.
// I wish c-ares had better support.
process.binding('net').getaddrinfo(domain, 4, function (err, domains4) {
callback(err, domains4[0], 4);
});
} else {
return;
}
if (family) {
// resolve names for explicit address family
var af = familyToSym(family);
@ -150,7 +157,9 @@ exports.lookup = function (domain, family, callback) {
callback(err, []);
}
});
} else {
return
}
// first resolve names for v4 and if that fails, try v6
channel.getHostByName(domain, dns.AF_INET, function (err, domains4) {
if (domains4 && domains4.length) {
@ -166,9 +175,6 @@ exports.lookup = function (domain, family, callback) {
});
}
});
}
}
}
};

Loading…
Cancel
Save