diff options
author | rubidium <rubidium@openttd.org> | 2010-10-17 17:33:46 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-10-17 17:33:46 +0000 |
commit | 61ae6b6e4098483517c6dc2f840498d28c98d749 (patch) | |
tree | 21af0beb99b4d417ef590b19ad871ad1f5052370 | |
parent | 33ed4ddbfbdcd269c7234ea6093acc21e7a63e7c (diff) | |
download | openttd-61ae6b6e4098483517c6dc2f840498d28c98d749.tar.xz |
(svn r20964) -Add: disconnecting remote admins that fail to authenticate
-rw-r--r-- | src/network/network_admin.cpp | 9 | ||||
-rw-r--r-- | src/network/network_admin.h | 1 |
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); |