Introduce inactive timeout for tunnel proxy clients
parent
b21759b3bf
commit
ecf58505d1
|
|
@ -289,13 +289,13 @@ void Engine::onTimerTick()
|
|||
|
||||
QVariantMap serverStatistics = createServerStatistic();
|
||||
m_monitorServer->updateClients(serverStatistics);
|
||||
|
||||
m_logEngine->logStatistics(serverStatistics.value("proxyStatistic").toMap().value("tunnelCount").toInt(),
|
||||
serverStatistics.value("proxyStatistic").toMap().value("clientCount").toInt(),
|
||||
serverStatistics.value("proxyStatistic").toMap().value("troughput").toInt());
|
||||
|
||||
m_currentTimeCounter = 0;
|
||||
|
||||
|
||||
if (m_tunnelProxyServer) {
|
||||
m_tunnelProxyServer->tick();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "tunnelproxyclient.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "server/transportinterface.h"
|
||||
#include "../engine.h"
|
||||
#include "../common/slipdataprocessor.h"
|
||||
|
||||
namespace remoteproxy {
|
||||
|
|
@ -8,7 +9,15 @@ namespace remoteproxy {
|
|||
TunnelProxyClient::TunnelProxyClient(TransportInterface *interface, const QUuid &clientId, const QHostAddress &address, QObject *parent) :
|
||||
TransportClient(interface, clientId, address, parent)
|
||||
{
|
||||
|
||||
// Note: a client is not inactive any more once registered successfully as client or server.
|
||||
// This makes sure we have not any inactive sockets connected to the proxy blocking resources.
|
||||
// The tunnelproxy server will call makeClientActive once registered successfuly to stop this timer.
|
||||
m_inactiveTimer.setInterval(Engine::instance()->configuration()->inactiveTimeout());
|
||||
connect(&m_inactiveTimer, &QTimer::timeout, this, [this](){
|
||||
m_interface->killClientConnection(m_clientId, "Tunnelproxy timeout occurred. The socket was inactive.");
|
||||
});
|
||||
m_inactiveTimer.setSingleShot(true);
|
||||
m_inactiveTimer.start();
|
||||
}
|
||||
|
||||
TunnelProxyClient::Type TunnelProxyClient::type() const
|
||||
|
|
@ -69,6 +78,11 @@ QList<QByteArray> TunnelProxyClient::processData(const QByteArray &data)
|
|||
return packets;
|
||||
}
|
||||
|
||||
void TunnelProxyClient::makeClientActive()
|
||||
{
|
||||
m_inactiveTimer.stop();
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, TunnelProxyClient *tunnelProxyClient)
|
||||
{
|
||||
debug.nospace() << "TunnelProxyClient(";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define TUNNELPROXYCLIENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include "server/transportclient.h"
|
||||
|
||||
|
|
@ -26,10 +27,13 @@ public:
|
|||
// Json server methods
|
||||
QList<QByteArray> processData(const QByteArray &data) override;
|
||||
|
||||
void makeClientActive();
|
||||
|
||||
signals:
|
||||
void typeChanged(Type type);
|
||||
|
||||
private:
|
||||
QTimer m_inactiveTimer;
|
||||
Type m_type = TypeNone;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -98,6 +98,10 @@ TunnelProxyServer::TunnelProxyError TunnelProxyServer::registerServer(const QUui
|
|||
return TunnelProxyServer::TunnelProxyErrorAlreadyRegistered;
|
||||
}
|
||||
|
||||
// This client has been registered successfully.
|
||||
// Make sure it does not get disconnected any more because due to inactivity.
|
||||
tunnelProxyClient->makeClientActive();
|
||||
|
||||
tunnelProxyClient->setType(TunnelProxyClient::TypeServer);
|
||||
tunnelProxyClient->setUuid(serverUuid);
|
||||
tunnelProxyClient->setName(serverName);
|
||||
|
|
@ -140,6 +144,10 @@ TunnelProxyServer::TunnelProxyError TunnelProxyServer::registerClient(const QUui
|
|||
return TunnelProxyServer::TunnelProxyErrorServerNotFound;
|
||||
}
|
||||
|
||||
// This client has been registered successfully.
|
||||
// Make sure it does not get disconnected any more because due to inactivity.
|
||||
tunnelProxyClient->makeClientActive();
|
||||
|
||||
// Not registered yet, we have a connected server for the requested server uuid
|
||||
tunnelProxyClient->setType(TunnelProxyClient::TypeClient);
|
||||
tunnelProxyClient->setUuid(clientUuid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue