From ff5896e80cfeb5bb1a6fc4341fe7bc9725661800 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 1 Jun 2017 18:56:05 -0600 Subject: [PATCH] Fix proxied check for remoteAddress --- core/servers/login/websocket.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/servers/login/websocket.js b/core/servers/login/websocket.js index 1a9a1ed1..9e638a40 100644 --- a/core/servers/login/websocket.js +++ b/core/servers/login/websocket.js @@ -28,6 +28,8 @@ function WebSocketClient(ws, req, serverType) { get : () => ('secure' === serverType || true === this.proxied) ? true : false, }); + const self = this; + // // This bridge makes accessible various calls that client sub classes // want to access on I/O socket @@ -48,7 +50,7 @@ function WebSocketClient(ws, req, serverType) { get remoteAddress() { // Support X-Forwarded-For and X-Real-IP headers for proxied connections - return (this.proxied && (req.headers['x-forwarded-for'] || req.headers['x-real-ip'])) || req.connection.remoteAddress; + return (self.proxied && (req.headers['x-forwarded-for'] || req.headers['x-real-ip'])) || req.connection.remoteAddress; } }(ws); @@ -81,6 +83,8 @@ function WebSocketClient(ws, req, serverType) { { Log.debug(`Assuming secure connection due to X-Forwarded-Proto of "${req.headers['x-forwarded-proto']}"`); this.proxied = true; + } else { + this.proxied = false; } // start handshake process