|
@@ -67,24 +67,29 @@ ServerNetworkAdminSocketHandler::ServerN
|
|
|
this->status = ADMIN_STATUS_INACTIVE;
|
|
|
this->connect_time = std::chrono::steady_clock::now();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Clear everything related to this admin.
|
|
|
*/
|
|
|
ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
|
|
|
{
|
|
|
_network_admins_connected--;
|
|
|
Debug(net, 3, "[admin] '{}' ({}) has disconnected", this->admin_name, this->admin_version);
|
|
|
if (_redirect_console_to_admin == this->index) _redirect_console_to_admin = INVALID_ADMIN_ID;
|
|
|
|
|
|
if (this->update_frequency[ADMIN_UPDATE_CONSOLE] & ADMIN_FREQUENCY_AUTOMATIC) {
|
|
|
this->update_frequency[ADMIN_UPDATE_CONSOLE] = (AdminUpdateFrequency)0;
|
|
|
DebugReconsiderSendRemoteMessages();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Whether a connection is allowed or not at this moment.
|
|
|
* @return Whether the connection is allowed.
|
|
|
*/
|
|
|
/* static */ bool ServerNetworkAdminSocketHandler::AllowConnection()
|
|
|
{
|
|
|
bool accept = !_settings_client.network.admin_password.empty() && _network_admins_connected < MAX_ADMINS;
|
|
|
/* We can't go over the MAX_ADMINS limit here. However, if we accept
|
|
|
* the connection, there has to be space in the pool. */
|
|
|
static_assert(NetworkAdminSocketPool::MAX_SIZE == MAX_ADMINS);
|
|
@@ -679,24 +684,26 @@ NetworkRecvStatus ServerNetworkAdminSock
|
|
|
|
|
|
AdminUpdateType type = (AdminUpdateType)p->Recv_uint16();
|
|
|
AdminUpdateFrequency freq = (AdminUpdateFrequency)p->Recv_uint16();
|
|
|
|
|
|
if (type >= ADMIN_UPDATE_END || (_admin_update_type_frequencies[type] & freq) != freq) {
|
|
|
/* The server does not know of this UpdateType. */
|
|
|
Debug(net, 1, "[admin] Not supported update frequency {} ({}) from '{}' ({})", type, freq, this->admin_name, this->admin_version);
|
|
|
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
|
|
|
}
|
|
|
|
|
|
this->update_frequency[type] = freq;
|
|
|
|
|
|
if (type == ADMIN_UPDATE_CONSOLE) DebugReconsiderSendRemoteMessages();
|
|
|
|
|
|
return NETWORK_RECV_STATUS_OKAY;
|
|
|
}
|
|
|
|
|
|
NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p)
|
|
|
{
|
|
|
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
|
|
|
|
|
|
AdminUpdateType type = (AdminUpdateType)p->Recv_uint8();
|
|
|
uint32 d1 = p->Recv_uint32();
|
|
|
|
|
|
switch (type) {
|
|
|
case ADMIN_UPDATE_DATE:
|