From d42ac23c55d36b5307e039024fdbe8708f8ed888 Mon Sep 17 00:00:00 2001 From: Maxime Poulin Date: Sat, 30 Jul 2016 20:54:09 -0400 Subject: [PATCH] Fix webirc and 4-in-6 addresses --- src/server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server.js b/src/server.js index c542c020..67d7d847 100644 --- a/src/server.js +++ b/src/server.js @@ -70,11 +70,15 @@ module.exports = function() { }; function getClientIp(req) { + var ip; + if (!Helper.config.reverseProxy) { - return req.connection.remoteAddress; + ip = req.connection.remoteAddress; } else { - return req.headers["x-forwarded-for"] || req.connection.remoteAddress; + ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress; } + + return ip.replace(/^::ffff:/, ""); } function allRequests(req, res, next) {