From b0b1712137eec3b40654f2df049e82c15bc67b44 Mon Sep 17 00:00:00 2001 From: yorts52 Date: Tue, 10 Nov 2015 18:51:23 +0800 Subject: [PATCH] format --- filter/addExtStream.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/filter/addExtStream.js b/filter/addExtStream.js index 6489696..649746a 100644 --- a/filter/addExtStream.js +++ b/filter/addExtStream.js @@ -8,15 +8,20 @@ module.exports = function(nextStream) { function getClientIp(req) { try { - var xff = (req.headers['X-Forwarded-For'] || req.headers['x-forwarded-for'] || '').split(',')[0].trim(); + var xff = ( + req.headers['X-Forwarded-For'] || + req.headers['x-forwarded-for'] || + '' + ).split(',')[0].trim(); - return xff || + return xff || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress; } catch (ex) { } + return "0.0.0.0"; }