summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_admin.cpp9
-rw-r--r--src/network/network_admin.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index 90da9ac6a..b03f9422e 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -34,6 +34,9 @@ byte _network_admins_connected = 0;
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket");
INSTANTIATE_POOL_METHODS(NetworkAdminSocket)
+/** The timeout for authorisation of the client. */
+static const int ADMIN_AUTHORISATION_TIMEOUT = 10000;
+
/**
* Create a new socket for the server side of the admin network.
* @param s The socket to connect with.
@@ -42,6 +45,7 @@ ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler(SOCKET s) : Net
{
_network_admins_connected++;
this->status = ADMIN_STATUS_INACTIVE;
+ this->realtime_connect = _realtime_tick;
}
/**
@@ -67,6 +71,11 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
{
ServerNetworkAdminSocketHandler *as;
FOR_ALL_ADMIN_SOCKETS(as) {
+ if (as->status == ADMIN_STATUS_INACTIVE && as->realtime_connect + ADMIN_AUTHORISATION_TIMEOUT < _realtime_tick) {
+ DEBUG(net, 1, "[admin] Admin did not send its authorisation within %d seconds", ADMIN_AUTHORISATION_TIMEOUT / 1000);
+ as->CloseConnection(true);
+ continue;
+ }
if (as->writable) {
as->Send_Packets();
}
diff --git a/src/network/network_admin.h b/src/network/network_admin.h
index ffa37ed44..1e0a3f2b6 100644
--- a/src/network/network_admin.h
+++ b/src/network/network_admin.h
@@ -30,6 +30,7 @@ protected:
NetworkRecvStatus SendProtocol();
public:
+ uint32 realtime_connect; ///< Time of connection.
NetworkAddress address; ///< Address of the admin.
ServerNetworkAdminSocketHandler(SOCKET s);