diff --git a/index.js b/index.js index ac751b1..38e6afd 100644 --- a/index.js +++ b/index.js @@ -59,8 +59,9 @@ global.wsConnections = []; var roomList = []; // IEM WebSocket app.ws('/iem', (ws, req) => { - req.ip = process.env.REALIP ? req.headers[process.env.REALIP.toLowerCase()] : req.ip; - console.log(`connection from ${req.ip}`); + console.log(req.headers) + const clientIp = process.env.REALIP ? req.headers[process.env.REALIP.toLowerCase()] : req.ip; + console.log(`connection from ${clientIp}`); const hostname = process.env.HOST_OVERRIDE || os.hostname(); ws.send(JSON.stringify({ @@ -86,7 +87,7 @@ app.ws('/iem', (ws, req) => { })); sock = wsConnections.push({ ws, req, subs: [] }); ws.on('close', () => { - console.log(`disconnected from ${req.ip}`); + console.log(`disconnected from ${clientIp}`); wsConnections = wsConnections.filter((conn) => conn.ws !== ws); }); try { @@ -102,7 +103,7 @@ app.ws('/iem', (ws, req) => { "error": "Invalid JSON format." } })); - console.log(`${colors.red("[ERROR]")} Invalid JSON format from ${req.ip}: ${msg}`); + console.log(`${colors.red("[ERROR]")} Invalid JSON format from ${clientIp}: ${msg}`); return; } if (!data.type) return ws.send(JSON.stringify({