From 6992feb2e75a460e4304347999a9b806e1e7bc8b Mon Sep 17 00:00:00 2001 From: a6a2f5842 Date: Mon, 12 May 2025 14:39:20 +0200 Subject: [PATCH] I added remoteAddress to connection --- src/Websocket/Handler.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Websocket/Handler.php b/src/Websocket/Handler.php index 5671602..faea3e2 100644 --- a/src/Websocket/Handler.php +++ b/src/Websocket/Handler.php @@ -45,6 +45,15 @@ class Handler implements MessageComponentInterface return $connection->close(); } + // Set IP to connection + $connection->remoteAddress = trim( + explode( + ',', + $connection->httpRequest->getHeaderLine('X-Forwarded-For') + )[0] ?? $connection->remoteAddress + ); + Log::channel('websocket')->info('WS onOpen IP: ' . $connection->remoteAddress); + $this->verifyAppKey($connection); $this->verifyOrigin($connection); $this->limitConcurrentConnections($connection);