Guard against missing x-forwarded-for on socket connect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Luke Berndt
2026-11-09 18:05:18 -05:00
parent d49326c606
commit c0492ebf53

View File

@@ -261,7 +261,7 @@ function parseHeader(header) {
io.sockets.on('connection', function (client) {
const header_ipAddress = parseHeader(client.handshake.headers["forwarded"] || "");
const cf_ipAddress = client.handshake.headers["cf-connecting-ip"];
const x_ipAddress = client.handshake.headers["x-forwarded-for"].split(",")[0];
const x_ipAddress = client.handshake.headers["x-forwarded-for"]?.split(",")[0];
const ipAddress = cf_ipAddress || x_ipAddress || header_ipAddress;
clients[client.id] = { socket: client, active: false };
clients[client.id].timestamp = new Date();