Server: Capturing DNS exceptions
authorDarren <darren@Darrens-MacBook-Pro.local>
Fri, 17 May 2013 16:16:26 +0000 (17:16 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Fri, 17 May 2013 16:16:26 +0000 (17:16 +0100)
server/weblistener.js

index 80fb2af7e7350a7d4a1f6aa8e25a48641aee7055..651d1f69ff424483f3e12e09c99f098b317bc3c3 100644 (file)
@@ -134,17 +134,23 @@ function authoriseConnection(handshakeData, callback) {
             return callback(null, false);
         }
     }
-        
-    dns.reverse(address, function (err, domains) {
-        if (err || domains.length === 0) {
-            handshakeData.revdns = address;
-        } else {
-            handshakeData.revdns = _.first(domains) || address;
-        }
-        
-        // All is well, authorise the connection
+
+
+    try {
+        dns.reverse(address, function (err, domains) {
+            if (err || domains.length === 0) {
+                handshakeData.revdns = address;
+            } else {
+                handshakeData.revdns = _.first(domains) || address;
+            }
+            
+            // All is well, authorise the connection
+            callback(null, true);
+        });
+    } catch (err) {
+        handshakeData.revdns = address;
         callback(null, true);
-    });
+    }
 }
 
 function newConnection(websocket) {