mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-24 15:09:10 +00:00
(svn r20964) -Add: disconnecting remote admins that fail to authenticate
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ protected:
|
||||
|
||||
NetworkRecvStatus SendProtocol();
|
||||
public:
|
||||
uint32 realtime_connect; ///< Time of connection.
|
||||
NetworkAddress address; ///< Address of the admin.
|
||||
|
||||
ServerNetworkAdminSocketHandler(SOCKET s);
|
||||
|
Reference in New Issue
Block a user