mirror of
https://github.com/LukeHagar/crossws.git
synced 2025-12-06 20:37:45 +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) {
|
if (!socket) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const addr =
|
const headers = this.ctx.node.req.headers;
|
||||||
socket.remoteFamily === "IPv6"
|
let addr = headers["x-forwarded-for"] || socket.remoteAddress || "??";
|
||||||
? `[${socket.remoteAddress}]`
|
if (addr.includes(":")) {
|
||||||
: socket.remoteAddress;
|
addr = `[${addr}]`;
|
||||||
return `${addr}:${socket.remotePort}`;
|
}
|
||||||
|
const port = headers["x-forwarded-port"] || socket.remotePort || "??";
|
||||||
|
return `${addr}:${port}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
get url() {
|
get url() {
|
||||||
|
|||||||
Reference in New Issue
Block a user