Merge pull request #3381 from n-thumann/fix_ipv6_handling

Fix handling of IPv6 addresses in getClientIP
This commit is contained in:
Louis Lam
2023-07-14 12:34:59 +08:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -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:/, "");
}
}