fix ip logging issues
All checks were successful
Code quality checks / biome (push) Successful in 13s
All checks were successful
Code quality checks / biome (push) Successful in 13s
This commit is contained in:
parent
1ce735f9ae
commit
a4c53c4bbb
1 changed files with 7 additions and 7 deletions
|
@ -221,15 +221,15 @@ class ServerHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers: Headers = response.headers;
|
const headers = request.headers;
|
||||||
let ip: string | null = server.requestIP(request)?.address || null;
|
let ip = server.requestIP(request)?.address;
|
||||||
|
|
||||||
if (!ip) {
|
if (!ip || ip.startsWith("172.") || ip === "127.0.0.1") {
|
||||||
ip =
|
ip =
|
||||||
headers.get("CF-Connecting-IP") ||
|
headers.get("CF-Connecting-IP")?.trim() ||
|
||||||
headers.get("X-Real-IP") ||
|
headers.get("X-Real-IP")?.trim() ||
|
||||||
headers.get("X-Forwarded-For") ||
|
headers.get("X-Forwarded-For")?.split(",")[0].trim() ||
|
||||||
null;
|
"unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.custom(
|
logger.custom(
|
||||||
|
|
Loading…
Add table
Reference in a new issue