Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix dns_uv.lookup order
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 26, 2011
1 parent 5e765fe commit 16b3f2c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/dns_uv.js
Expand Up @@ -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) {
throw errnoException(errno, 'getHostByName');
}
Expand Down

1 comment on commit 16b3f2c

@Knighton910
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.