fix(node): respect x-forwarded for client id

This commit is contained in:
Pooya Parsa
2024-02-25 21:38:44 +01:00
parent 7722716966
commit 3f8bd0c8ee

View File

@@ -119,11 +119,13 @@ class NodePeer extends Peer<{
if (!socket) {
return undefined;
}
const addr =
socket.remoteFamily === "IPv6"
? `[${socket.remoteAddress}]`
: socket.remoteAddress;
return `${addr}:${socket.remotePort}`;
const headers = this.ctx.node.req.headers;
let addr = headers["x-forwarded-for"] || socket.remoteAddress || "??";
if (addr.includes(":")) {
addr = `[${addr}]`;
}
const port = headers["x-forwarded-port"] || socket.remotePort || "??";
return `${addr}:${port}`;
}
get url() {