mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-08 08:28:48 +08:00
Fix getClientIP
Co-authored-by: Mateusz Hajder <6783135+mhajder@users.noreply.github.com>
This commit is contained in:
@@ -131,14 +131,18 @@ class UptimeKumaServer {
|
||||
}
|
||||
|
||||
async getClientIP(socket) {
|
||||
const clientIP = socket.client.conn.remoteAddress.replace(/^.*:/, "");
|
||||
let clientIP = socket.client.conn.remoteAddress;
|
||||
|
||||
if (clientIP === undefined) {
|
||||
clientIP = "";
|
||||
}
|
||||
|
||||
if (await Settings.get("trustProxy")) {
|
||||
return socket.client.conn.request.headers["x-forwarded-for"]
|
||||
|| socket.client.conn.request.headers["x-real-ip"]
|
||||
|| clientIP;
|
||||
|| clientIP.replace(/^.*:/, "");
|
||||
} else {
|
||||
return clientIP;
|
||||
return clientIP.replace(/^.*:/, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user