OpenTTD Source: src/network/core/tcp_admin.cpp Source File

OpenTTD Source 15.0-RC2

tcp_admin.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
12#include "../../stdafx.h"
13
14#include "../network_internal.h"
15#include "tcp_admin.h"
16#include "../../debug.h"
17
18#include "../../safeguards.h"
19
20/* Make sure that these enums match. */
21static_assert((int)CRR_MANUAL == (int)ADMIN_CRR_MANUAL);
22static_assert((int)CRR_AUTOCLEAN == (int)ADMIN_CRR_AUTOCLEAN);
23static_assert((int)CRR_BANKRUPT == (int)ADMIN_CRR_BANKRUPT);
24static_assert((int)CRR_END == (int)ADMIN_CRR_END);
25
26 NetworkRecvStatus NetworkAdminSocketHandler::CloseConnection(bool)
27{
28 delete this;
29 return NETWORK_RECV_STATUS_CLIENT_QUIT;
30}
31
37 NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet &p)
38{
39 PacketAdminType type = (PacketAdminType)p.Recv_uint8();
40
41 if (this->HasClientQuit()) {
42 Debug(net, 0, "[tcp/admin] Received invalid packet from '{}' ({})", this->admin_name, this->admin_version);
43 this->CloseConnection();
44 return NETWORK_RECV_STATUS_MALFORMED_PACKET;
45 }
46
47 switch (type) {
48 case ADMIN_PACKET_ADMIN_JOIN: return this->Receive_ADMIN_JOIN(p);
49 case ADMIN_PACKET_ADMIN_QUIT: return this->Receive_ADMIN_QUIT(p);
50 case ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY: return this->Receive_ADMIN_UPDATE_FREQUENCY(p);
51 case ADMIN_PACKET_ADMIN_POLL: return this->Receive_ADMIN_POLL(p);
52 case ADMIN_PACKET_ADMIN_CHAT: return this->Receive_ADMIN_CHAT(p);
53 case ADMIN_PACKET_ADMIN_EXTERNAL_CHAT: return this->Receive_ADMIN_EXTERNAL_CHAT(p);
54 case ADMIN_PACKET_ADMIN_RCON: return this->Receive_ADMIN_RCON(p);
55 case ADMIN_PACKET_ADMIN_GAMESCRIPT: return this->Receive_ADMIN_GAMESCRIPT(p);
56 case ADMIN_PACKET_ADMIN_PING: return this->Receive_ADMIN_PING(p);
57 case ADMIN_PACKET_ADMIN_JOIN_SECURE: return this->Receive_ADMIN_JOIN_SECURE(p);
58 case ADMIN_PACKET_ADMIN_AUTH_RESPONSE: return this->Receive_ADMIN_AUTH_RESPONSE(p);
59
60 case ADMIN_PACKET_SERVER_FULL: return this->Receive_SERVER_FULL(p);
61 case ADMIN_PACKET_SERVER_BANNED: return this->Receive_SERVER_BANNED(p);
62 case ADMIN_PACKET_SERVER_ERROR: return this->Receive_SERVER_ERROR(p);
63 case ADMIN_PACKET_SERVER_PROTOCOL: return this->Receive_SERVER_PROTOCOL(p);
64 case ADMIN_PACKET_SERVER_WELCOME: return this->Receive_SERVER_WELCOME(p);
65 case ADMIN_PACKET_SERVER_NEWGAME: return this->Receive_SERVER_NEWGAME(p);
66 case ADMIN_PACKET_SERVER_SHUTDOWN: return this->Receive_SERVER_SHUTDOWN(p);
67
68 case ADMIN_PACKET_SERVER_DATE: return this->Receive_SERVER_DATE(p);
69 case ADMIN_PACKET_SERVER_CLIENT_JOIN: return this->Receive_SERVER_CLIENT_JOIN(p);
70 case ADMIN_PACKET_SERVER_CLIENT_INFO: return this->Receive_SERVER_CLIENT_INFO(p);
71 case ADMIN_PACKET_SERVER_CLIENT_UPDATE: return this->Receive_SERVER_CLIENT_UPDATE(p);
72 case ADMIN_PACKET_SERVER_CLIENT_QUIT: return this->Receive_SERVER_CLIENT_QUIT(p);
73 case ADMIN_PACKET_SERVER_CLIENT_ERROR: return this->Receive_SERVER_CLIENT_ERROR(p);
74 case ADMIN_PACKET_SERVER_COMPANY_NEW: return this->Receive_SERVER_COMPANY_NEW(p);
75 case ADMIN_PACKET_SERVER_COMPANY_INFO: return this->Receive_SERVER_COMPANY_INFO(p);
76 case ADMIN_PACKET_SERVER_COMPANY_UPDATE: return this->Receive_SERVER_COMPANY_UPDATE(p);
77 case ADMIN_PACKET_SERVER_COMPANY_REMOVE: return this->Receive_SERVER_COMPANY_REMOVE(p);
78 case ADMIN_PACKET_SERVER_COMPANY_ECONOMY: return this->Receive_SERVER_COMPANY_ECONOMY(p);
79 case ADMIN_PACKET_SERVER_COMPANY_STATS: return this->Receive_SERVER_COMPANY_STATS(p);
80 case ADMIN_PACKET_SERVER_CHAT: return this->Receive_SERVER_CHAT(p);
81 case ADMIN_PACKET_SERVER_RCON: return this->Receive_SERVER_RCON(p);
82 case ADMIN_PACKET_SERVER_CONSOLE: return this->Receive_SERVER_CONSOLE(p);
83 case ADMIN_PACKET_SERVER_CMD_NAMES: return this->Receive_SERVER_CMD_NAMES(p);
84 case ADMIN_PACKET_SERVER_CMD_LOGGING: return this->Receive_SERVER_CMD_LOGGING(p);
85 case ADMIN_PACKET_SERVER_RCON_END: return this->Receive_SERVER_RCON_END(p);
86 case ADMIN_PACKET_SERVER_PONG: return this->Receive_SERVER_PONG(p);
87 case ADMIN_PACKET_SERVER_AUTH_REQUEST: return this->Receive_SERVER_AUTH_REQUEST(p);
88 case ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION: return this->Receive_SERVER_ENABLE_ENCRYPTION(p);
89
90 default:
91 Debug(net, 0, "[tcp/admin] Received invalid packet type {} from '{}' ({})", type, this->admin_name, this->admin_version);
92 this->CloseConnection();
93 return NETWORK_RECV_STATUS_MALFORMED_PACKET;
94 }
95}
96
104 NetworkRecvStatus NetworkAdminSocketHandler::ReceivePackets()
105{
106 std::unique_ptr<Packet> p;
107 while ((p = this->ReceivePacket()) != nullptr) {
108 NetworkRecvStatus res = this->HandlePacket(*p);
109 if (res != NETWORK_RECV_STATUS_OKAY) return res;
110 }
111
112 return NETWORK_RECV_STATUS_OKAY;
113}
114
120 NetworkRecvStatus NetworkAdminSocketHandler::ReceiveInvalidPacket(PacketAdminType type)
121{
122 Debug(net, 0, "[tcp/admin] Received illegal packet type {} from admin {} ({})", type, this->admin_name, this->admin_version);
123 return NETWORK_RECV_STATUS_MALFORMED_PACKET;
124}
125
126 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_JOIN(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_JOIN); }
127 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_QUIT(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_QUIT); }
128 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY); }
129 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_POLL); }
130 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_CHAT); }
131 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_EXTERNAL_CHAT); }
132 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_RCON); }
133 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_GAMESCRIPT); }
134 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_PING(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_PING); }
135 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_JOIN_SECURE); }
136 NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_AUTH_RESPONSE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_AUTH_RESPONSE); }
137
138 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_FULL(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_FULL); }
139 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_BANNED(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_BANNED); }
140 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_ERROR(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_ERROR); }
141 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PROTOCOL(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_PROTOCOL); }
142 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_WELCOME(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_WELCOME); }
143 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_NEWGAME(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_NEWGAME); }
144 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_SHUTDOWN(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_SHUTDOWN); }
145
146 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_DATE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_DATE); }
147 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_JOIN(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_JOIN); }
148 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_INFO(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_INFO); }
149 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_UPDATE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_UPDATE); }
150 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_QUIT(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_QUIT); }
151 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_ERROR(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_ERROR); }
152 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_NEW(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_NEW); }
153 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_INFO(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_INFO); }
154 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_UPDATE); }
155 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_REMOVE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_REMOVE); }
156 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_ECONOMY(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_ECONOMY); }
157 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_STATS(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_STATS); }
158 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CHAT(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CHAT); }
159 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON); }
160 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CONSOLE); }
161 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_NAMES); }
162 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); }
163 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON_END); }
164 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PONG(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_PONG); }
165 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_AUTH_REQUEST(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_AUTH_REQUEST); }
166 NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_ENABLE_ENCRYPTION(Packet &) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION); }
NetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT
virtual NetworkRecvStatus Receive_ADMIN_EXTERNAL_CHAT(Packet &p)
Send chat from the external source: string Name of the source this message came from.
Definition tcp_admin.cpp:131
NetworkAdminSocketHandler::Receive_ADMIN_RCON
virtual NetworkRecvStatus Receive_ADMIN_RCON(Packet &p)
Execute a command on the servers console: string Command to be executed.
Definition tcp_admin.cpp:132
NetworkAdminSocketHandler::Receive_SERVER_AUTH_REQUEST
virtual NetworkRecvStatus Receive_SERVER_AUTH_REQUEST(Packet &p)
Server requests authentication challenge from the admin.
Definition tcp_admin.cpp:165
NetworkAdminSocketHandler::Receive_SERVER_CLIENT_ERROR
virtual NetworkRecvStatus Receive_SERVER_CLIENT_ERROR(Packet &p)
Notification about a client error (and thus the clients disconnection).
Definition tcp_admin.cpp:151
NetworkAdminSocketHandler::Receive_SERVER_WELCOME
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet &p)
Welcome a connected admin to the game: string Name of the Server.
Definition tcp_admin.cpp:142
NetworkAdminSocketHandler::Receive_SERVER_COMPANY_ECONOMY
virtual NetworkRecvStatus Receive_SERVER_COMPANY_ECONOMY(Packet &p)
Economy update of a specific company: uint8_t ID of the company.
Definition tcp_admin.cpp:156
NetworkAdminSocketHandler::Receive_SERVER_COMPANY_STATS
virtual NetworkRecvStatus Receive_SERVER_COMPANY_STATS(Packet &p)
Company statistics on stations and vehicles: uint8_t ID of the company.
Definition tcp_admin.cpp:157
NetworkAdminSocketHandler::Receive_SERVER_COMPANY_NEW
virtual NetworkRecvStatus Receive_SERVER_COMPANY_NEW(Packet &p)
Notification of a new company: uint8_t ID of the new company.
Definition tcp_admin.cpp:152
NetworkAdminSocketHandler::Receive_SERVER_DATE
virtual NetworkRecvStatus Receive_SERVER_DATE(Packet &p)
Send the current date of the game: uint32_t Current game date.
Definition tcp_admin.cpp:146
NetworkAdminSocketHandler::Receive_SERVER_COMPANY_UPDATE
virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet &p)
Company information of a specific company: uint8_t ID of the company.
Definition tcp_admin.cpp:154
NetworkAdminSocketHandler::Receive_SERVER_RCON
virtual NetworkRecvStatus Receive_SERVER_RCON(Packet &p)
Result of an rcon command: uint16_t Colour as it would be used on the server or a client.
Definition tcp_admin.cpp:159
NetworkAdminSocketHandler::HandlePacket
NetworkRecvStatus HandlePacket(Packet &p)
Handle the given packet, i.e.
Definition tcp_admin.cpp:37
NetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT
virtual NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet &p)
Send a JSON string to the current active GameScript.
Definition tcp_admin.cpp:133
NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING
virtual NetworkRecvStatus Receive_SERVER_CMD_LOGGING(Packet &p)
Send incoming command packets to the admin network.
Definition tcp_admin.cpp:162
NetworkAdminSocketHandler::Receive_SERVER_SHUTDOWN
virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet &p)
Notification about the server shutting down.
Definition tcp_admin.cpp:144
NetworkAdminSocketHandler::Receive_SERVER_ERROR
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet &p)
An error was caused by this admin connection (connection gets closed).
Definition tcp_admin.cpp:140
NetworkAdminSocketHandler::CloseConnection
NetworkRecvStatus CloseConnection(bool error=true) override
This will put this socket handler in a close state.
Definition tcp_admin.cpp:26
NetworkAdminSocketHandler::Receive_SERVER_COMPANY_REMOVE
virtual NetworkRecvStatus Receive_SERVER_COMPANY_REMOVE(Packet &p)
Notification about a removed company (e.g.
Definition tcp_admin.cpp:155
NetworkAdminSocketHandler::Receive_SERVER_CLIENT_UPDATE
virtual NetworkRecvStatus Receive_SERVER_CLIENT_UPDATE(Packet &p)
Client update details on a specific client (e.g.
Definition tcp_admin.cpp:149
NetworkAdminSocketHandler::Receive_SERVER_FULL
virtual NetworkRecvStatus Receive_SERVER_FULL(Packet &p)
The server is full (connection gets closed).
Definition tcp_admin.cpp:138
NetworkAdminSocketHandler::Receive_ADMIN_QUIT
virtual NetworkRecvStatus Receive_ADMIN_QUIT(Packet &p)
Notification to the server that this admin is quitting.
Definition tcp_admin.cpp:127
NetworkAdminSocketHandler::Receive_SERVER_CLIENT_JOIN
virtual NetworkRecvStatus Receive_SERVER_CLIENT_JOIN(Packet &p)
Notification of a new client: uint32_t ID of the new client.
Definition tcp_admin.cpp:147
NetworkAdminSocketHandler::Receive_ADMIN_AUTH_RESPONSE
virtual NetworkRecvStatus Receive_ADMIN_AUTH_RESPONSE(Packet &p)
Admin responds to ADMIN_PACKET_SERVER_AUTH_REQUEST with the appropriate data given the agreed upon Ne...
Definition tcp_admin.cpp:136
NetworkAdminSocketHandler::Receive_SERVER_CLIENT_QUIT
virtual NetworkRecvStatus Receive_SERVER_CLIENT_QUIT(Packet &p)
Notification about a client leaving the game.
Definition tcp_admin.cpp:150
NetworkAdminSocketHandler::Receive_ADMIN_POLL
virtual NetworkRecvStatus Receive_ADMIN_POLL(Packet &p)
Poll the server for certain updates, an invalid poll (e.g.
Definition tcp_admin.cpp:129
NetworkAdminSocketHandler::Receive_ADMIN_JOIN
virtual NetworkRecvStatus Receive_ADMIN_JOIN(Packet &p)
Join the admin network using an unsecured password exchange: string Unsecured password the server is ...
Definition tcp_admin.cpp:126
NetworkAdminSocketHandler::Receive_ADMIN_PING
virtual NetworkRecvStatus Receive_ADMIN_PING(Packet &p)
Ping the server, requiring the server to reply with a pong packet.
Definition tcp_admin.cpp:134
NetworkAdminSocketHandler::Receive_ADMIN_CHAT
virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet &p)
Send chat as the server: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
Definition tcp_admin.cpp:130
NetworkAdminSocketHandler::Receive_SERVER_CONSOLE
virtual NetworkRecvStatus Receive_SERVER_CONSOLE(Packet &p)
Send what would be printed on the server's console also into the admin network.
Definition tcp_admin.cpp:160
NetworkAdminSocketHandler::Receive_SERVER_COMPANY_INFO
virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet &p)
Company information on a specific company: uint8_t ID of the company.
Definition tcp_admin.cpp:153
NetworkAdminSocketHandler::Receive_SERVER_PONG
virtual NetworkRecvStatus Receive_SERVER_PONG(Packet &p)
Send a ping-reply (pong) to the admin that sent us the ping packet.
Definition tcp_admin.cpp:164
NetworkAdminSocketHandler::Receive_SERVER_ENABLE_ENCRYPTION
virtual NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p)
Indication to the client that authentication is complete and encryption has to be used from here on f...
Definition tcp_admin.cpp:166
NetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE
virtual NetworkRecvStatus Receive_ADMIN_JOIN_SECURE(Packet &p)
Join the admin network using a secure authentication method: string Name of the application being use...
Definition tcp_admin.cpp:135
NetworkAdminSocketHandler::ReceiveInvalidPacket
NetworkRecvStatus ReceiveInvalidPacket(PacketAdminType type)
Helper for logging receiving invalid packets.
Definition tcp_admin.cpp:120
NetworkAdminSocketHandler::ReceivePackets
NetworkRecvStatus ReceivePackets()
Do the actual receiving of packets.
Definition tcp_admin.cpp:104
NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES
virtual NetworkRecvStatus Receive_SERVER_CMD_NAMES(Packet &p)
Send DoCommand names to the bot upon request only.
Definition tcp_admin.cpp:161
NetworkAdminSocketHandler::Receive_SERVER_NEWGAME
virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet &p)
Notification about a newgame.
Definition tcp_admin.cpp:143
NetworkAdminSocketHandler::admin_version
std::string admin_version
Version string of the admin.
Definition tcp_admin.h:119
NetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY
virtual NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet &p)
Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16_t Up...
Definition tcp_admin.cpp:128
NetworkAdminSocketHandler::Receive_SERVER_PROTOCOL
virtual NetworkRecvStatus Receive_SERVER_PROTOCOL(Packet &p)
Inform a just joined admin about the protocol specifics: uint8_t Protocol version.
Definition tcp_admin.cpp:141
NetworkAdminSocketHandler::Receive_SERVER_RCON_END
virtual NetworkRecvStatus Receive_SERVER_RCON_END(Packet &p)
Notify the admin connection that the rcon command has finished.
Definition tcp_admin.cpp:163
NetworkAdminSocketHandler::Receive_SERVER_CHAT
virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet &p)
Send chat from the game into the admin network: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (se...
Definition tcp_admin.cpp:158
NetworkAdminSocketHandler::Receive_SERVER_CLIENT_INFO
virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet &p)
Client information of a specific client: uint32_t ID of the client.
Definition tcp_admin.cpp:148
NetworkAdminSocketHandler::admin_name
std::string admin_name
Name of the admin.
Definition tcp_admin.h:118
NetworkAdminSocketHandler::Receive_SERVER_BANNED
virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet &p)
The source IP address is banned (connection gets closed).
Definition tcp_admin.cpp:139
NetworkSocketHandler::HasClientQuit
bool HasClientQuit() const
Whether the current client connected to the socket has quit.
Definition core.h:74
NetworkTCPSocketHandler::ReceivePacket
virtual std::unique_ptr< Packet > ReceivePacket()
Receives a packet for the given client.
Definition tcp.cpp:119
CRR_BANKRUPT
@ CRR_BANKRUPT
The company went belly-up.
Definition company_type.h:63
CRR_END
@ CRR_END
Sentinel for end.
Definition company_type.h:65
CRR_AUTOCLEAN
@ CRR_AUTOCLEAN
The company is removed due to autoclean.
Definition company_type.h:62
CRR_MANUAL
@ CRR_MANUAL
The company is manually removed.
Definition company_type.h:61
NetworkRecvStatus
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition core.h:23
NETWORK_RECV_STATUS_CLIENT_QUIT
@ NETWORK_RECV_STATUS_CLIENT_QUIT
The connection is lost gracefully. Other clients are already informed of this leaving client.
Definition core.h:28
NETWORK_RECV_STATUS_OKAY
@ NETWORK_RECV_STATUS_OKAY
Everything is okay.
Definition core.h:24
NETWORK_RECV_STATUS_MALFORMED_PACKET
@ NETWORK_RECV_STATUS_MALFORMED_PACKET
We apparently send a malformed packet.
Definition core.h:29
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
Packet
Internal entity of a packet.
Definition packet.h:43
Packet::Recv_uint8
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
Definition packet.cpp:318
tcp_admin.h
Basic functions to receive and send TCP packets to and from the admin network.
PacketAdminType
PacketAdminType
Enum with types of TCP packets specific to the admin network.
Definition tcp_admin.h:23
ADMIN_PACKET_ADMIN_PING
@ ADMIN_PACKET_ADMIN_PING
The admin sends a ping to the server, expecting a ping-reply (PONG) packet.
Definition tcp_admin.h:31
ADMIN_PACKET_SERVER_CONSOLE
@ ADMIN_PACKET_SERVER_CONSOLE
The server gives the admin the data that got printed to its console.
Definition tcp_admin.h:58
ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION
@ ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION
The server tells that authentication has completed and requests to enable encryption with the keys of...
Definition tcp_admin.h:66
ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY
@ ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY
The admin tells the server the update frequency of a particular piece of information.
Definition tcp_admin.h:26
ADMIN_PACKET_SERVER_CLIENT_UPDATE
@ ADMIN_PACKET_SERVER_CLIENT_UPDATE
The server gives the admin an information update on a client.
Definition tcp_admin.h:47
ADMIN_PACKET_SERVER_COMPANY_STATS
@ ADMIN_PACKET_SERVER_COMPANY_STATS
The server gives the admin some statistics about a company.
Definition tcp_admin.h:55
ADMIN_PACKET_SERVER_COMPANY_ECONOMY
@ ADMIN_PACKET_SERVER_COMPANY_ECONOMY
The server gives the admin some economy related company information.
Definition tcp_admin.h:54
ADMIN_PACKET_ADMIN_JOIN
@ ADMIN_PACKET_ADMIN_JOIN
The admin announces and authenticates itself to the server using an unsecured passwords.
Definition tcp_admin.h:24
ADMIN_PACKET_SERVER_CLIENT_INFO
@ ADMIN_PACKET_SERVER_CLIENT_INFO
The server gives the admin information about a client.
Definition tcp_admin.h:46
ADMIN_PACKET_SERVER_CLIENT_ERROR
@ ADMIN_PACKET_SERVER_CLIENT_ERROR
The server tells the admin that a client caused an error.
Definition tcp_admin.h:49
ADMIN_PACKET_ADMIN_GAMESCRIPT
@ ADMIN_PACKET_ADMIN_GAMESCRIPT
The admin sends a JSON string for the GameScript.
Definition tcp_admin.h:30
ADMIN_PACKET_SERVER_AUTH_REQUEST
@ ADMIN_PACKET_SERVER_AUTH_REQUEST
The server gives the admin the used authentication method and required parameters.
Definition tcp_admin.h:65
ADMIN_PACKET_SERVER_CHAT
@ ADMIN_PACKET_SERVER_CHAT
The server received a chat message and relays it.
Definition tcp_admin.h:56
ADMIN_PACKET_SERVER_SHUTDOWN
@ ADMIN_PACKET_SERVER_SHUTDOWN
The server tells the admin its shutting down.
Definition tcp_admin.h:42
ADMIN_PACKET_SERVER_RCON_END
@ ADMIN_PACKET_SERVER_RCON_END
The server indicates that the remote console command has completed.
Definition tcp_admin.h:62
ADMIN_PACKET_SERVER_WELCOME
@ ADMIN_PACKET_SERVER_WELCOME
The server welcomes the admin to a game.
Definition tcp_admin.h:40
ADMIN_PACKET_SERVER_COMPANY_REMOVE
@ ADMIN_PACKET_SERVER_COMPANY_REMOVE
The server tells the admin that a company was removed.
Definition tcp_admin.h:53
ADMIN_PACKET_SERVER_ERROR
@ ADMIN_PACKET_SERVER_ERROR
The server tells the admin an error has occurred.
Definition tcp_admin.h:38
ADMIN_PACKET_ADMIN_QUIT
@ ADMIN_PACKET_ADMIN_QUIT
The admin tells the server that it is quitting.
Definition tcp_admin.h:25
ADMIN_PACKET_ADMIN_POLL
@ ADMIN_PACKET_ADMIN_POLL
The admin explicitly polls for a piece of information.
Definition tcp_admin.h:27
ADMIN_PACKET_SERVER_NEWGAME
@ ADMIN_PACKET_SERVER_NEWGAME
The server tells the admin its going to start a new game.
Definition tcp_admin.h:41
ADMIN_PACKET_SERVER_BANNED
@ ADMIN_PACKET_SERVER_BANNED
The server tells the admin it is banned.
Definition tcp_admin.h:37
ADMIN_PACKET_SERVER_COMPANY_UPDATE
@ ADMIN_PACKET_SERVER_COMPANY_UPDATE
The server gives the admin an information update on a company.
Definition tcp_admin.h:52
ADMIN_PACKET_SERVER_PONG
@ ADMIN_PACKET_SERVER_PONG
The server replies to a ping request from the admin.
Definition tcp_admin.h:63
ADMIN_PACKET_SERVER_CLIENT_JOIN
@ ADMIN_PACKET_SERVER_CLIENT_JOIN
The server tells the admin that a client has joined.
Definition tcp_admin.h:45
ADMIN_PACKET_ADMIN_CHAT
@ ADMIN_PACKET_ADMIN_CHAT
The admin sends a chat message to be distributed.
Definition tcp_admin.h:28
ADMIN_PACKET_SERVER_CMD_LOGGING
@ ADMIN_PACKET_SERVER_CMD_LOGGING
The server gives the admin copies of incoming command packets.
Definition tcp_admin.h:64
ADMIN_PACKET_SERVER_PROTOCOL
@ ADMIN_PACKET_SERVER_PROTOCOL
The server tells the admin its protocol version.
Definition tcp_admin.h:39
ADMIN_PACKET_ADMIN_JOIN_SECURE
@ ADMIN_PACKET_ADMIN_JOIN_SECURE
The admin announces and starts a secure authentication handshake.
Definition tcp_admin.h:33
ADMIN_PACKET_SERVER_CLIENT_QUIT
@ ADMIN_PACKET_SERVER_CLIENT_QUIT
The server tells the admin that a client quit.
Definition tcp_admin.h:48
ADMIN_PACKET_SERVER_COMPANY_INFO
@ ADMIN_PACKET_SERVER_COMPANY_INFO
The server gives the admin information about a company.
Definition tcp_admin.h:51
ADMIN_PACKET_SERVER_CMD_NAMES
@ ADMIN_PACKET_SERVER_CMD_NAMES
The server sends out the names of the DoCommands to the admins.
Definition tcp_admin.h:59
ADMIN_PACKET_SERVER_FULL
@ ADMIN_PACKET_SERVER_FULL
The server tells the admin it cannot accept the admin.
Definition tcp_admin.h:36
ADMIN_PACKET_ADMIN_RCON
@ ADMIN_PACKET_ADMIN_RCON
The admin sends a remote console command.
Definition tcp_admin.h:29
ADMIN_PACKET_ADMIN_AUTH_RESPONSE
@ ADMIN_PACKET_ADMIN_AUTH_RESPONSE
The admin responds to the authentication request.
Definition tcp_admin.h:34
ADMIN_PACKET_SERVER_DATE
@ ADMIN_PACKET_SERVER_DATE
The server tells the admin what the current game date is.
Definition tcp_admin.h:44
ADMIN_PACKET_SERVER_COMPANY_NEW
@ ADMIN_PACKET_SERVER_COMPANY_NEW
The server tells the admin that a new company has started.
Definition tcp_admin.h:50
ADMIN_PACKET_ADMIN_EXTERNAL_CHAT
@ ADMIN_PACKET_ADMIN_EXTERNAL_CHAT
The admin sends a chat message from external source.
Definition tcp_admin.h:32
ADMIN_PACKET_SERVER_RCON
@ ADMIN_PACKET_SERVER_RCON
The server's reply to a remove console command.
Definition tcp_admin.h:57
ADMIN_CRR_BANKRUPT
@ ADMIN_CRR_BANKRUPT
The company went belly-up.
Definition tcp_admin.h:110
ADMIN_CRR_MANUAL
@ ADMIN_CRR_MANUAL
The company is manually removed.
Definition tcp_admin.h:108
ADMIN_CRR_AUTOCLEAN
@ ADMIN_CRR_AUTOCLEAN
The company is removed due to autoclean.
Definition tcp_admin.h:109
ADMIN_CRR_END
@ ADMIN_CRR_END
Sentinel for end.
Definition tcp_admin.h:112