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 <mgerstner@suse.de> for reporting this.
This commit is contained in:
Aleix Pol 2020-09-16 02:44:38 +02:00 committed by Albert Vaca Cintora
parent b496e66899
commit 5310eae85d

View file

@ -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();
}
}