From b4bcb7637b146782cdf898b09c2c719c41899b71 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 20 Aug 2014 12:09:38 -0500 Subject: [PATCH] Reject sockets with no IP --- lib/io/ioserver.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/io/ioserver.js b/lib/io/ioserver.js index 72ef6ff8..a00e7eec 100644 --- a/lib/io/ioserver.js +++ b/lib/io/ioserver.js @@ -127,6 +127,13 @@ function addTypecheckedFunctions(sock) { */ function handleConnection(sock) { var ip = sock.request.connection.remoteAddress; + if (!ip) { + socket.emit("kick", { + reason: "Your IP address could not be determined from the socket connection. See https://github.com/Automattic/socket.io/issues/1387#issuecomment-48425088 for details" + }); + return; + } + if (net.isIPv6(ip)) { ip = util.expandIPv6(ip); }