summaryrefslogtreecommitdiff
path: root/lib/dns.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-06-29 21:20:32 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-06-29 22:15:28 -0700
commit0a8bd34b6993156da074ff89863f12e404e36ede (patch)
tree0da5b10e3cd756d12979dcaa93c7118e47a07baf /lib/dns.js
parent02ed0ec93bc8f6bcd7f1d629dca64ba1f335ea05 (diff)
downloadnodejs-0a8bd34b6993156da074ff89863f12e404e36ede.tar.gz
nodejs-0a8bd34b6993156da074ff89863f12e404e36ede.tar.bz2
nodejs-0a8bd34b6993156da074ff89863f12e404e36ede.zip
Resolve .local domains with getaddrinfo()
C-Ares doesn't go through the Name Service Switch (NSS) and thus can't resolve certain classes of names. Generally this doesn't matter and the whole idea of NSS is rather annoying. Nevertheless until C-Ares gets better support, adding this hack to go through getaddrinfo() for .local domain look up. This reverts commit 9926dacd14c39276299712ced4a83fb043f27162.
Diffstat (limited to 'lib/dns.js')
-rw-r--r--lib/dns.js36
1 files changed, 23 insertions, 13 deletions
diff --git a/lib/dns.js b/lib/dns.js
index e57b9b4bf..52aa03427 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -97,6 +97,8 @@ exports.getHostByName = function (domain, callback) {
channel.getHostByName(domain, dns.AF_INET, callback);
};
+var net;
+
// Easy DNS A/AAAA look up
exports.lookup = function (domain, callback) {
var addressType = dns.isIP(domain);
@@ -105,19 +107,27 @@ exports.lookup = function (domain, callback) {
callback(null, domain, addressType);
});
} else {
- channel.getHostByName(domain, dns.AF_INET, function (err, domains4) {
- if (domains4 && domains4.length) {
- callback(null, domains4[0], 4);
- } else {
- channel.getHostByName(domain, dns.AF_INET6, function (err, domains6) {
- if (domains6 && domains6.length) {
- callback(null, domains6[0], 6);
- } else {
- callback(err, []);
- }
- });
- }
- });
+ 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 {
+ channel.getHostByName(domain, dns.AF_INET, function (err, domains4) {
+ if (domains4 && domains4.length) {
+ callback(null, domains4[0], 4);
+ } else {
+ channel.getHostByName(domain, dns.AF_INET6, function (err, domains6) {
+ if (domains6 && domains6.length) {
+ callback(null, domains6[0], 6);
+ } else {
+ callback(err, []);
+ }
+ });
+ }
+ });
+ }
}
};