From 61ae6b6e4098483517c6dc2f840498d28c98d749 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 17 Oct 2010 17:33:46 +0000 Subject: (svn r20964) -Add: disconnecting remote admins that fail to authenticate --- src/network/network_admin.cpp | 9 +++++++++ src/network/network_admin.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2