|
@ -142,7 +142,23 @@ exports.lookup = function(domain, family, callback) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var wrap = cares.getHostByName(domain, familyToSym(family), onanswer); |
|
|
var wrap; |
|
|
|
|
|
|
|
|
|
|
|
if (family) { |
|
|
|
|
|
// resolve names for explicit address family
|
|
|
|
|
|
var af = familyToSym(family); |
|
|
|
|
|
wrap = cares.getHostByName(domain, af, onanswer); |
|
|
|
|
|
} else { |
|
|
|
|
|
// first resolve names for v4 and if that fails, try v6
|
|
|
|
|
|
wrap = cares.getHostByName(domain, cares.AF_INET, function(err, domains4) { |
|
|
|
|
|
if (domains4 && domains4.length) { |
|
|
|
|
|
callback(null, domains4[0], 4); |
|
|
|
|
|
} else { |
|
|
|
|
|
cares.getHostByName(domain, cares.AF_INET6, onanswer); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!wrap) { |
|
|
if (!wrap) { |
|
|
throw errnoException(errno, 'getHostByName'); |
|
|
throw errnoException(errno, 'getHostByName'); |
|
|
} |
|
|
} |
|
|