|
|
@ -93,11 +93,25 @@ exports.resolve = function (domain, type_, callback_) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
exports.getHostByName = function (domain, callback) { |
|
|
|
channel.getHostByName(domain, dns.AF_INET, callback); |
|
|
|
function familyToSym(family) { |
|
|
|
if (family !== dns.AF_INET && family !== dns.AF_INET6) { |
|
|
|
family = (family === 6) ? dns.AF_INET6 : dns.AF_INET; |
|
|
|
} |
|
|
|
return family; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
exports.getHostByName = function (domain, family/*=4*/, callback) { |
|
|
|
if (typeof family === 'function') { callback = family; family = null; } |
|
|
|
channel.getHostByName(domain, familyToSym(family), callback); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
exports.getHostByAddr = function (address, family/*=4*/, callback) { |
|
|
|
if (typeof family === 'function') { callback = family; family = null; } |
|
|
|
channel.getHostByAddr(address, familyToSym(family), callback); |
|
|
|
}; |
|
|
|
|
|
|
|
var net; |
|
|
|
|
|
|
|
// Easy DNS A/AAAA look up
|
|
|
|
// lookup(domain, [family,] callback)
|
|
|
@ -132,7 +146,7 @@ exports.lookup = function (domain, family, callback) { |
|
|
|
} else { |
|
|
|
if (family) { |
|
|
|
// resolve names for explicit address family
|
|
|
|
var af = (family === 4) ? dns.AF_INET : dns.AF_INET6; |
|
|
|
var af = familyToSym(family); |
|
|
|
channel.getHostByName(domain, af, function (err, domains) { |
|
|
|
if (!err && domains && domains.length) { |
|
|
|
if (family !== dns.isIP(domains[0])) { |
|
|
|