[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - net/WebSocketHandler.hpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 18 10:06:06 UTC 2020
net/WebSocketHandler.hpp | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
New commits:
commit 3956aa7cba09cada02873b624e05d7c436c98c28
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Sep 17 07:54:00 2020 -0400
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Sep 18 12:05:46 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>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102990
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 77ae3a264..62cd53c0b 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