From 5310eae85dbdf92fba30375238a2481f2e34943e Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 16 Sep 2020 02:44:38 +0200 Subject: [PATCH 05/10] Do not let lanlink connections stay open for long without authenticating If there's no information received, close the socket to try again. Thanks Matthias Gerstner for reporting this. --- core/backends/lan/lanlinkprovider.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 1fd3870e..a4942c65 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -374,6 +374,16 @@ void LanLinkProvider::newConnection() connect(socket, &QIODevice::readyRead, this, &LanLinkProvider::dataReceived); + QTimer* timer = new QTimer(socket); + timer->setSingleShot(true); + timer->setInterval(1000); + connect(socket, &QSslSocket::encrypted, + timer, &QObject::deleteLater); + connect(timer, &QTimer::timeout, socket, [socket] { + qCWarning(KDECONNECT_CORE) << "LanLinkProvider/newConnection: Host timed out without sending any identity." << socket->peerAddress(); + socket->disconnectFromHost(); + }); + timer->start(); } } -- 2.28.0