From be4811087f5c70e1107e31d656cd5e325bd42a88 Mon Sep 17 00:00:00 2001 From: Darren Date: Fri, 17 May 2013 17:16:26 +0100 Subject: [PATCH] Server: Capturing DNS exceptions --- server/weblistener.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/server/weblistener.js b/server/weblistener.js index 80fb2af..651d1f6 100644 --- a/server/weblistener.js +++ b/server/weblistener.js @@ -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) { -- 2.25.1