From cdf6922bddaf5a99759b2d751b7177556b30b442 Mon Sep 17 00:00:00 2001 From: nthumann Date: Fri, 7 Jul 2023 23:38:10 +0200 Subject: [PATCH] Fix handling of IPv6 addresses in getClientIP --- server/uptime-kuma-server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index b45a749b9..728b8f158 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -249,9 +249,9 @@ class UptimeKumaServer { return (typeof forwardedFor === "string" ? forwardedFor.split(",")[0].trim() : null) || socket.client.conn.request.headers["x-real-ip"] - || clientIP.replace(/^.*:/, ""); + || clientIP.replace(/^::ffff:/, ""); } else { - return clientIP.replace(/^.*:/, ""); + return clientIP.replace(/^::ffff:/, ""); } }