[Libreoffice-commits] online.git: net/WebSocketHandler.hpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 17 13:37:39 UTC 2020
net/WebSocketHandler.hpp | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
New commits:
commit 4c954973273624f80d92cf6190ea064bac41bdb9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Sep 17 07:54:00 2020 -0400
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Sep 17 15:37:21 2020 +0200
wsd: allow pings from clients
Per the rfc (https://tools.ietf.org/html/rfc6455#section-5.5.2):
"An endpoint MAY send a Ping frame any time after the connection
is established and before the connection is closed."
And "Upon receipt of a Ping frame, an endpoint MUST send a Pong
frame in response, unless it already received a Close frame."
Here we allow for pings to come from clients and we respond
to them by pongs, as required by rfc 6455.
Change-Id: I8e285f095526e4b67373ecb3ae1efc9c8717d756
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102948
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 7fb38c86d..7a9ec902c 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -287,33 +287,25 @@ public:
switch (code)
{
case WSOpCode::Pong:
- if (_isClient)
- {
- LOG_ERR('#' << socket->getFD() << ": Servers should not send pongs, only clients");
- shutdown(StatusCodes::POLICY_VIOLATION);
- return true;
- }
- else
{
+ if (_isClient)
+ LOG_WRN('#' << socket->getFD() << ": Servers should not send pongs, only clients");
+
_pingTimeUs = std::chrono::duration_cast<std::chrono::microseconds>
(std::chrono::steady_clock::now() - _lastPingSentTime).count();
LOG_TRC('#' << socket->getFD() << ": Pong received: " << _pingTimeUs << " microseconds");
}
break;
case WSOpCode::Ping:
- if (_isClient)
{
- auto now = std::chrono::steady_clock::now();
+ if (!_isClient)
+ LOG_ERR('#' << socket->getFD() << ": Clients should not send pings, only servers");
+
+ const auto now = std::chrono::steady_clock::now();
_pingTimeUs = std::chrono::duration_cast<std::chrono::microseconds>
(now - _lastPingSentTime).count();
sendPong(now, &ctrlPayload[0], payloadLen, socket);
}
- else
- {
- LOG_ERR('#' << socket->getFD() << ": Clients should not send pings, only servers");
- shutdown(StatusCodes::POLICY_VIOLATION);
- return true;
- }
break;
case WSOpCode::Close:
{
More information about the Libreoffice-commits
mailing list