dns_uv: add localhost hack for windows
authorRyan Dahl <ry@tinyclouds.org>
Wed, 24 Aug 2011 20:42:20 +0000 (13:42 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Wed, 24 Aug 2011 20:43:05 +0000 (13:43 -0700)
lib/dns_uv.js

index eccbfd5..cc6a1b5 100644 (file)
@@ -108,6 +108,15 @@ exports.lookup = function(domain, family, callback) {
     return {};
   }
 
+  // Hack required for Windows because Win7 removed the
+  // localhost entry from c:\WINDOWS\system32\drivers\etc\hosts
+  // See http://daniel.haxx.se/blog/2011/02/21/localhost-hack-on-windows/
+  // TODO Remove this once c-ares handles this problem.
+  if (process.platform == 'win32' && domain == 'localhost') {
+    callback(null, '127.0.0.1', 4);
+    return {};
+  }
+
   var matchedFamily = net.isIP(domain);
   if (matchedFamily) {
     callback(null, domain, matchedFamily);