Add REALIP env var

This commit is contained in:
Christopher Cookman 2025-05-08 01:19:31 -06:00
parent bca8efef23
commit 4249815c55

View file

@ -59,6 +59,7 @@ global.wsConnections = [];
var roomList = []; var roomList = [];
// IEM WebSocket // IEM WebSocket
app.ws('/iem', (ws, req) => { 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(`connection from ${req.ip}`);
const hostname = process.env.HOST_OVERRIDE || os.hostname(); const hostname = process.env.HOST_OVERRIDE || os.hostname();
@ -101,6 +102,7 @@ app.ws('/iem', (ws, req) => {
"error": "Invalid JSON format." "error": "Invalid JSON format."
} }
})); }));
console.log(`${colors.red("[ERROR]")} Invalid JSON format from ${req.ip}: ${msg}`);
return; return;
} }
if (!data.type) return ws.send(JSON.stringify({ if (!data.type) return ws.send(JSON.stringify({