mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 13:31:25 +00:00
Gateway: harden trusted proxy X-Forwarded-For parsing (#22429)
This commit is contained in:
@@ -147,7 +147,11 @@ function stripOptionalPort(ip: string): string {
|
||||
}
|
||||
|
||||
export function parseForwardedForClientIp(forwardedFor?: string): string | undefined {
|
||||
const raw = forwardedFor?.split(",")[0]?.trim();
|
||||
const entries = forwardedFor
|
||||
?.split(",")
|
||||
.map((entry) => entry.trim())
|
||||
.filter((entry) => entry.length > 0);
|
||||
const raw = entries?.at(-1);
|
||||
if (!raw) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user