From 0693b5db6598d90ccaadf27e760a3be4449277de Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 30 Dec 2024 13:24:09 -0800 Subject: [PATCH] fix ip processing bug: ip was sometimes an array --- src/server/Archive.ts | 3 --- src/server/Server.ts | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/server/Archive.ts b/src/server/Archive.ts index 8c85ed15e..094b033c6 100644 --- a/src/server/Archive.ts +++ b/src/server/Archive.ts @@ -166,15 +166,12 @@ function anonymizeIPv6(ipv6: string): string | null { } function anonymizeIP(ip: string): string | null { - console.log(`anonymize got ip: ${ip}`) const ipv4Result = anonymizeIPv4(ip); if (ipv4Result) { - console.log(`got ipv4 result: ${ipv4Result}`) return ipv4Result; } const ipv6 = anonymizeIPv6(ip); - console.log(`got ipv6: ${ipv6}`) return ipv6 } diff --git a/src/server/Server.ts b/src/server/Server.ts index 046794a0a..f5a51f23c 100644 --- a/src/server/Server.ts +++ b/src/server/Server.ts @@ -131,10 +131,12 @@ wss.on('connection', (ws, req) => { }) if (clientMsg.type == "join") { const forwarded = req.headers['x-forwarded-for'] - const ip = Array.isArray(forwarded) + let ip = Array.isArray(forwarded) ? forwarded[0] // Get the first IP if it's an array : forwarded || req.socket.remoteAddress; - console.log(`dev: ip address: ${ip}`) + if (Array.isArray(ip)) { + ip = ip[0] + } gm.addClient( new Client( clientMsg.clientID,