feat: display the real IP address of the user (#16)

This commit is contained in:
Dharmaraj 2021-06-10 11:26:41 +05:30 committed by GitHub
parent cec313e379
commit 2e05f706c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -341,13 +341,17 @@ const serialize = (
): SerializedSocket => { ): SerializedSocket => {
const clientId = socket.data?._admin?.clientId; const clientId = socket.data?._admin?.clientId;
const transport = socket.data?._admin?.transport; const transport = socket.data?._admin?.transport;
const address =
socket.handshake.headers["cf-connecting-ip"] ||
socket.handshake.headers["x-forwarded-for"] ||
socket.handshake.address;
return { return {
id: socket.id, id: socket.id,
clientId, clientId,
transport, transport,
nsp, nsp,
handshake: { handshake: {
address: socket.handshake.address, address,
headers: socket.handshake.headers, headers: socket.handshake.headers,
query: socket.handshake.query, query: socket.handshake.query,
issued: socket.handshake.issued, issued: socket.handshake.issued,