OpenTTD Source 20250503-master-gf4f05dea33
network_admin.cpp File Reference

Server part of the admin network protocol. More...

#include "../stdafx.h"
#include "../strings_func.h"
#include "../timer/timer_game_calendar.h"
#include "core/network_game_info.h"
#include "network_admin.h"
#include "network_base.h"
#include "network_server.h"
#include "../command_func.h"
#include "../company_base.h"
#include "../console_func.h"
#include "../core/pool_func.hpp"
#include "../map_func.h"
#include "../rev.h"
#include "../game/game.hpp"
#include "table/strings.h"
#include "../safeguards.h"

Go to the source code of this file.

Functions

static NetworkAuthenticationDefaultPasswordProvider _admin_password_provider (_settings_client.network.admin_password)
 Provides the password validation for the game's password.
 
static NetworkAuthenticationDefaultAuthorizedKeyHandler _admin_authorized_key_handler (_settings_client.network.admin_authorized_keys)
 Provides the authorized key handling for the game authentication.
 
static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT (10)
 The timeout for authorisation of the client.
 
void NetworkAdminClientInfo (const NetworkClientSocket *cs, bool new_client)
 Notify the admin network of a new client (if they did opt in for the respective update).
 
void NetworkAdminClientUpdate (const NetworkClientInfo *ci)
 Notify the admin network of a client update (if they did opt in for the respective update).
 
void NetworkAdminClientQuit (ClientID client_id)
 Notify the admin network that a client quit (if they have opt in for the respective update).
 
void NetworkAdminClientError (ClientID client_id, NetworkErrorCode error_code)
 Notify the admin network of a client error (if they have opt in for the respective update).
 
void NetworkAdminCompanyNew (const Company *company)
 Notify the admin network of a new company.
 
void NetworkAdminCompanyUpdate (const Company *company)
 Notify the admin network of company updates.
 
void NetworkAdminCompanyRemove (CompanyID company_id, AdminCompanyRemoveReason bcrr)
 Notify the admin network of a company to be removed (including the reason why).
 
void NetworkAdminChat (NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data, bool from_admin)
 Send chat to the admin network (if they did opt in for the respective update).
 
void NetworkServerSendAdminRcon (AdminID admin_index, TextColour colour_code, std::string_view string)
 Pass the rcon reply to the admin.
 
void NetworkAdminConsole (std::string_view origin, std::string_view string)
 Send console to the admin network (if they did opt in for the respective update).
 
void NetworkAdminGameScript (std::string_view json)
 Send GameScript JSON to the admin network (if they did opt in for the respective update).
 
void NetworkAdminCmdLogging (const NetworkClientSocket *owner, const CommandPacket &cp)
 Distribute CommandPacket details over the admin network for logging purposes.
 
void NetworkAdminUpdate (AdminUpdateFrequency freq)
 Send (push) updates to the admin network as they have registered for these updates.
 

Variables

AdminID _redirect_console_to_admin = AdminID::Invalid()
 Redirection of the (remote) console to the admin.
 
NetworkAdminSocketPool _networkadminsocket_pool ("NetworkAdminSocket")
 The pool with sockets/clients.
 
static const AdminUpdateFrequencies _admin_update_type_frequencies []
 Frequencies, which may be registered for a certain update type.
 

Detailed Description

Server part of the admin network protocol.

Definition in file network_admin.cpp.

Function Documentation

◆ NetworkAdminChat()

void NetworkAdminChat ( NetworkAction  action,
DestType  desttype,
ClientID  client_id,
std::string_view  msg,
int64_t  data,
bool  from_admin 
)

Send chat to the admin network (if they did opt in for the respective update).

Definition at line 983 of file network_admin.cpp.

References ADMIN_UPDATE_CHAT, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by NetworkServerSendChat().

◆ NetworkAdminClientError()

void NetworkAdminClientError ( ClientID  client_id,
NetworkErrorCode  error_code 
)

Notify the admin network of a client error (if they have opt in for the respective update).

Parameters
client_idthe client that made the error.
error_codethe error that was caused.

Definition at line 924 of file network_admin.cpp.

References ADMIN_UPDATE_CLIENT_INFO, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by ServerNetworkGameSocketHandler::CloseConnection(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), and ServerNetworkGameSocketHandler::SendError().

◆ NetworkAdminClientInfo()

void NetworkAdminClientInfo ( const NetworkClientSocket *  cs,
bool  new_client 
)

Notify the admin network of a new client (if they did opt in for the respective update).

Parameters
csthe client info.
new_clientif this is a new client, send the respective packet too.

Definition at line 881 of file network_admin.cpp.

References ADMIN_UPDATE_CLIENT_INFO, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK().

◆ NetworkAdminClientQuit()

void NetworkAdminClientQuit ( ClientID  client_id)

Notify the admin network that a client quit (if they have opt in for the respective update).

Parameters
client_idof the client that quit.

Definition at line 910 of file network_admin.cpp.

References ADMIN_UPDATE_CLIENT_INFO, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT().

◆ NetworkAdminClientUpdate()

void NetworkAdminClientUpdate ( const NetworkClientInfo ci)

Notify the admin network of a client update (if they did opt in for the respective update).

Parameters
cithe client info.

Definition at line 897 of file network_admin.cpp.

References ADMIN_UPDATE_CLIENT_INFO, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by NetworkUpdateClientInfo().

◆ NetworkAdminCmdLogging()

void NetworkAdminCmdLogging ( const NetworkClientSocket *  owner,
const CommandPacket cp 
)

Distribute CommandPacket details over the admin network for logging purposes.

Parameters
ownerThe owner of the CommandPacket (who sent us the CommandPacket).
cpThe CommandPacket to be distributed.

Definition at line 1037 of file network_admin.cpp.

References _network_own_client_id, ADMIN_UPDATE_CMD_LOGGING, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by DistributeQueue().

◆ NetworkAdminCompanyNew()

void NetworkAdminCompanyNew ( const Company company)

Notify the admin network of a new company.

Parameters
companythe company of which details will be sent into the admin network.

Definition at line 937 of file network_admin.cpp.

References ADMIN_UPDATE_COMPANY_INFO, Automatic, Debug, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by CmdCompanyCtrl().

◆ NetworkAdminCompanyRemove()

void NetworkAdminCompanyRemove ( CompanyID  company_id,
AdminCompanyRemoveReason  bcrr 
)

Notify the admin network of a company to be removed (including the reason why).

Parameters
company_idID of the company that got removed.
bcrrthe reason why the company got removed (e.g. bankruptcy).

Definition at line 972 of file network_admin.cpp.

References ServerNetworkAdminSocketHandler::IterateActive().

Referenced by CompanyAdminRemove().

◆ NetworkAdminCompanyUpdate()

void NetworkAdminCompanyUpdate ( const Company company)

Notify the admin network of company updates.

Parameters
companycompany of which updates are going to be sent into the admin network.

Definition at line 956 of file network_admin.cpp.

References ADMIN_UPDATE_COMPANY_INFO, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by CompanyAdminUpdate().

◆ NetworkAdminConsole()

void NetworkAdminConsole ( std::string_view  origin,
std::string_view  string 
)

Send console to the admin network (if they did opt in for the respective update).

Parameters
originthe origin of the message.
stringthe message as printed on the console.

Definition at line 1010 of file network_admin.cpp.

References ADMIN_UPDATE_CONSOLE, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by DebugSendRemoteMessages(), and IConsolePrint().

◆ NetworkAdminGameScript()

void NetworkAdminGameScript ( std::string_view  json)

Send GameScript JSON to the admin network (if they did opt in for the respective update).

Parameters
jsonThe JSON data as received from the GameScript.

Definition at line 1023 of file network_admin.cpp.

References ADMIN_UPDATE_GAMESCRIPT, Automatic, and ServerNetworkAdminSocketHandler::IterateActive().

◆ NetworkAdminUpdate()

void NetworkAdminUpdate ( AdminUpdateFrequency  freq)

Send (push) updates to the admin network as they have registered for these updates.

Parameters
freqthe frequency to be processed.

Definition at line 1062 of file network_admin.cpp.

References ADMIN_UPDATE_COMPANY_ECONOMY, ADMIN_UPDATE_COMPANY_STATS, ADMIN_UPDATE_DATE, ADMIN_UPDATE_END, and ServerNetworkAdminSocketHandler::IterateActive().

◆ NetworkServerSendAdminRcon()

void NetworkServerSendAdminRcon ( AdminID  admin_index,
TextColour  colour_code,
std::string_view  string 
)

Pass the rcon reply to the admin.

Parameters
admin_indexThe admin to give the reply.
colour_codeThe colour of the string.
stringThe string to show.

Definition at line 1000 of file network_admin.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_networkadminsocket_pool >::Get().

Referenced by IConsolePrint().

Variable Documentation

◆ _admin_update_type_frequencies

const AdminUpdateFrequencies _admin_update_type_frequencies[]
static
Initial value:

Frequencies, which may be registered for a certain update type.

Definition at line 48 of file network_admin.cpp.

Referenced by ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY(), and ServerNetworkAdminSocketHandler::SendProtocol().

◆ _redirect_console_to_admin

AdminID _redirect_console_to_admin = AdminID::Invalid()

Redirection of the (remote) console to the admin.

Definition at line 34 of file network_admin.cpp.

Referenced by IConsolePrint(), and ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON().