From 2e05f706c62792f9d497910bdabb44d12292c806 Mon Sep 17 00:00:00 2001 From: Dharmaraj <63334359+DharmarajX24@users.noreply.github.com> Date: Thu, 10 Jun 2021 11:26:41 +0530 Subject: [PATCH] feat: display the real IP address of the user (#16) --- lib/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index 57987b7..24e792c 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -341,13 +341,17 @@ const serialize = ( ): SerializedSocket => { const clientId = socket.data?._admin?.clientId; const transport = socket.data?._admin?.transport; + const address = + socket.handshake.headers["cf-connecting-ip"] || + socket.handshake.headers["x-forwarded-for"] || + socket.handshake.address; return { id: socket.id, clientId, transport, nsp, handshake: { - address: socket.handshake.address, + address, headers: socket.handshake.headers, query: socket.handshake.query, issued: socket.handshake.issued,