mirror of
https://github.com/LukeHagar/crossws.git
synced 2025-12-06 12:27:46 +00:00
fix(node): respect x-forwarded for client id
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user