From 8489927b67ae8a8f328290f66a042a68d02d170f Mon Sep 17 00:00:00 2001 From: Matteo Mekhail <67237370+matteoiscrying@users.noreply.github.com> Date: Mon, 23 Feb 2026 13:12:42 +1100 Subject: [PATCH] normalize socket IP format --- server.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 0e74f45..70f0440 100644 --- a/server.ts +++ b/server.ts @@ -132,11 +132,13 @@ function getClientIp(req: Request, server: Bun.Server): string { const xff = req.headers.get("x-forwarded-for"); if (xff) { const rightmost = xff.split(",").at(-1)?.trim(); - if (rightmost) return rightmost; + if (rightmost && !isPrivateIp(rightmost)) { + return rightmost.startsWith("::ffff:") ? rightmost.slice(7) : rightmost; + } } } - return socketIp; + return socketIp.startsWith("::ffff:") ? socketIp.slice(7) : socketIp; } function isRateLimited(key: string, limit: number, windowMs: number): boolean {