OpenTTD Source: src/network/network_admin.cpp Source File

OpenTTD Source 15.0-RC2

network_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
10#include "../stdafx.h"
11#include "../strings_func.h"
12#include "../timer/timer_game_calendar.h"
13#include "../timer/timer_game_calendar.h"
14#include "core/network_game_info.h"
15#include "network_admin.h"
16#include "network_base.h"
17#include "network_server.h"
18#include "../command_func.h"
19#include "../company_base.h"
20#include "../console_func.h"
21#include "../core/pool_func.hpp"
22#include "../map_func.h"
23#include "../rev.h"
24#include "../game/game.hpp"
25
26#include "table/strings.h"
27
28#include "../safeguards.h"
29
30
31/* This file handles all the admin network commands. */
32
34 AdminID _redirect_console_to_admin = AdminID::Invalid();
35
37 NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket");
38 INSTANTIATE_POOL_METHODS(NetworkAdminSocket)
39
40static NetworkAuthenticationDefaultPasswordProvider _admin_password_provider(_settings_client.network.admin_password);
41static NetworkAuthenticationDefaultAuthorizedKeyHandler _admin_authorized_key_handler(_settings_client.network.admin_authorized_keys);
42
44static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10);
45
46
48static const AdminUpdateFrequencies _admin_update_type_frequencies[] = {
49 {AdminUpdateFrequency::Poll, AdminUpdateFrequency::Daily, AdminUpdateFrequency::Weekly, AdminUpdateFrequency::Monthly, AdminUpdateFrequency::Quarterly, AdminUpdateFrequency::Annually}, // ADMIN_UPDATE_DATE
50 {AdminUpdateFrequency::Poll, AdminUpdateFrequency::Automatic, }, // ADMIN_UPDATE_CLIENT_INFO
51 {AdminUpdateFrequency::Poll, AdminUpdateFrequency::Automatic, }, // ADMIN_UPDATE_COMPANY_INFO
52 {AdminUpdateFrequency::Poll, AdminUpdateFrequency::Weekly, AdminUpdateFrequency::Monthly, AdminUpdateFrequency::Quarterly, AdminUpdateFrequency::Annually}, // ADMIN_UPDATE_COMPANY_ECONOMY
53 {AdminUpdateFrequency::Poll, AdminUpdateFrequency::Weekly, AdminUpdateFrequency::Monthly, AdminUpdateFrequency::Quarterly, AdminUpdateFrequency::Annually}, // ADMIN_UPDATE_COMPANY_STATS
54 { AdminUpdateFrequency::Automatic, }, // ADMIN_UPDATE_CHAT
55 { AdminUpdateFrequency::Automatic, }, // ADMIN_UPDATE_CONSOLE
56 {AdminUpdateFrequency::Poll, }, // ADMIN_UPDATE_CMD_NAMES
57 { AdminUpdateFrequency::Automatic, }, // ADMIN_UPDATE_CMD_LOGGING
58 { AdminUpdateFrequency::Automatic, }, // ADMIN_UPDATE_GAMESCRIPT
59};
61static_assert(lengthof(_admin_update_type_frequencies) == ADMIN_UPDATE_END);
62
67ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler(SOCKET s) : NetworkAdminSocketHandler(s)
68{
69 this->status = ADMIN_STATUS_INACTIVE;
70 this->connect_time = std::chrono::steady_clock::now();
71}
72
76ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
77{
78 Debug(net, 3, "[admin] '{}' ({}) has disconnected", this->admin_name, this->admin_version);
79 if (_redirect_console_to_admin == this->index) _redirect_console_to_admin = AdminID::Invalid();
80
81 if (this->update_frequency[ADMIN_UPDATE_CONSOLE].Test(AdminUpdateFrequency::Automatic)) {
82 this->update_frequency[ADMIN_UPDATE_CONSOLE] = {};
83 DebugReconsiderSendRemoteMessages();
84 }
85}
86
91/* static */ bool ServerNetworkAdminSocketHandler::AllowConnection()
92{
93 return _settings_client.network.AdminAuthenticationConfigured() && ServerNetworkAdminSocketHandler::CanAllocateItem();
94}
95
97/* static */ void ServerNetworkAdminSocketHandler::Send()
98{
99 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) {
100 if (as->status <= ADMIN_STATUS_AUTHENTICATE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) {
101 Debug(net, 2, "[admin] Admin did not send its authorisation within {} seconds", std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
102 as->CloseConnection(true);
103 continue;
104 }
105 if (as->writable) {
106 as->SendPackets();
107 }
108 }
109}
110
116/* static */ void ServerNetworkAdminSocketHandler::AcceptConnection(SOCKET s, const NetworkAddress &address)
117{
118 ServerNetworkAdminSocketHandler *as = new ServerNetworkAdminSocketHandler(s);
119 as->address = address; // Save the IP of the client
120}
121
122/***********
123 * Sending functions for admin network
124 ************/
125
130 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendError(NetworkErrorCode error)
131{
132 /* Whatever the error might be, authentication (keys) must be released as soon as possible. */
133 this->authentication_handler = nullptr;
134
135 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_ERROR);
136
137 p->Send_uint8(error);
138 this->SendPacket(std::move(p));
139
140 std::string error_message = GetString(GetNetworkErrorMsg(error));
141
142 Debug(net, 1, "[admin] The admin '{}' ({}) made an error and has been disconnected: '{}'", this->admin_name, this->admin_version, error_message);
143
144 return this->CloseConnection(true);
145}
146
148 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendProtocol()
149{
150 this->status = ADMIN_STATUS_ACTIVE;
151
152 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_PROTOCOL);
153
154 /* announce the protocol version */
155 p->Send_uint8(NETWORK_GAME_ADMIN_VERSION);
156
157 for (int i = 0; i < ADMIN_UPDATE_END; i++) {
158 p->Send_bool (true);
159 p->Send_uint16(i);
160 p->Send_uint16(_admin_update_type_frequencies[i].base());
161 }
162
163 p->Send_bool(false);
164 this->SendPacket(std::move(p));
165
166 return this->SendWelcome();
167}
168
170 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendWelcome()
171{
172 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_WELCOME);
173
174 p->Send_string(_settings_client.network.server_name);
175 p->Send_string(GetNetworkRevisionString());
176 p->Send_bool (_network_dedicated);
177
178 p->Send_string(""); // Used to be map-name.
179 p->Send_uint32(_settings_game.game_creation.generation_seed);
180 p->Send_uint8 (to_underlying(_settings_game.game_creation.landscape));
181 p->Send_uint32(TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1).base());
182 p->Send_uint16(Map::SizeX());
183 p->Send_uint16(Map::SizeY());
184
185 this->SendPacket(std::move(p));
186
187 return NETWORK_RECV_STATUS_OKAY;
188}
189
191 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendNewGame()
192{
193 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_NEWGAME);
194 this->SendPacket(std::move(p));
195 return NETWORK_RECV_STATUS_OKAY;
196}
197
199 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendShutdown()
200{
201 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_SHUTDOWN);
202 this->SendPacket(std::move(p));
203 return NETWORK_RECV_STATUS_OKAY;
204}
205
207 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendDate()
208{
209 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_DATE);
210
211 p->Send_uint32(TimerGameCalendar::date.base());
212 this->SendPacket(std::move(p));
213
214 return NETWORK_RECV_STATUS_OKAY;
215}
216
221 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientJoin(ClientID client_id)
222{
223 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_JOIN);
224
225 p->Send_uint32(client_id);
226 this->SendPacket(std::move(p));
227
228 return NETWORK_RECV_STATUS_OKAY;
229}
230
236 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci)
237{
238 /* Only send data when we're a proper client, not just someone trying to query the server. */
239 if (ci == nullptr) return NETWORK_RECV_STATUS_OKAY;
240
241 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_INFO);
242
243 p->Send_uint32(ci->client_id);
244 p->Send_string(cs == nullptr ? "" : const_cast<NetworkAddress &>(cs->client_address).GetHostname());
245 p->Send_string(ci->client_name);
246 p->Send_uint8 (0); // Used to be language
247 p->Send_uint32(ci->join_date.base());
248 p->Send_uint8 (ci->client_playas);
249
250 this->SendPacket(std::move(p));
251
252 return NETWORK_RECV_STATUS_OKAY;
253}
254
255
260 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientUpdate(const NetworkClientInfo *ci)
261{
262 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_UPDATE);
263
264 p->Send_uint32(ci->client_id);
265 p->Send_string(ci->client_name);
266 p->Send_uint8 (ci->client_playas);
267
268 this->SendPacket(std::move(p));
269
270 return NETWORK_RECV_STATUS_OKAY;
271}
272
277 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientQuit(ClientID client_id)
278{
279 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_QUIT);
280
281 p->Send_uint32(client_id);
282 this->SendPacket(std::move(p));
283
284 return NETWORK_RECV_STATUS_OKAY;
285}
286
292 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientError(ClientID client_id, NetworkErrorCode error)
293{
294 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_ERROR);
295
296 p->Send_uint32(client_id);
297 p->Send_uint8 (error);
298 this->SendPacket(std::move(p));
299
300 return NETWORK_RECV_STATUS_OKAY;
301}
302
307 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyNew(CompanyID company_id)
308{
309 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_NEW);
310 p->Send_uint8(company_id);
311
312 this->SendPacket(std::move(p));
313
314 return NETWORK_RECV_STATUS_OKAY;
315}
316
321 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company *c)
322{
323 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_INFO);
324
325 p->Send_uint8 (c->index);
326 p->Send_string(GetString(STR_COMPANY_NAME, c->index));
327 p->Send_string(GetString(STR_PRESIDENT_NAME, c->index));
328 p->Send_uint8 (c->colour);
329 p->Send_bool (true);
330 p->Send_uint32(c->inaugurated_year.base());
331 p->Send_bool (c->is_ai);
332 p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
333
334 this->SendPacket(std::move(p));
335
336 return NETWORK_RECV_STATUS_OKAY;
337}
338
339
344 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Company *c)
345{
346 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_UPDATE);
347
348 p->Send_uint8 (c->index);
349 p->Send_string(GetString(STR_COMPANY_NAME, c->index));
350 p->Send_string(GetString(STR_PRESIDENT_NAME, c->index));
351 p->Send_uint8 (c->colour);
352 p->Send_bool (true);
353 p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
354
355 this->SendPacket(std::move(p));
356
357 return NETWORK_RECV_STATUS_OKAY;
358}
359
365 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason acrr)
366{
367 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_REMOVE);
368
369 p->Send_uint8(company_id);
370 p->Send_uint8(acrr);
371
372 this->SendPacket(std::move(p));
373
374 return NETWORK_RECV_STATUS_OKAY;
375}
376
378 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy()
379{
380 for (const Company *company : Company::Iterate()) {
381 /* Get the income. */
382 Money income = -std::reduce(std::begin(company->yearly_expenses[0]), std::end(company->yearly_expenses[0]));
383
384 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_ECONOMY);
385
386 p->Send_uint8(company->index);
387
388 /* Current information. */
389 p->Send_uint64(company->money);
390 p->Send_uint64(company->current_loan);
391 p->Send_uint64(income);
392 p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<OverflowSafeInt64>())));
393
394 /* Send stats for the last 2 quarters. */
395 for (uint i = 0; i < 2; i++) {
396 p->Send_uint64(company->old_economy[i].company_value);
397 p->Send_uint16(company->old_economy[i].performance_history);
398 p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<OverflowSafeInt64>())));
399 }
400
401 this->SendPacket(std::move(p));
402 }
403
404
405 return NETWORK_RECV_STATUS_OKAY;
406}
407
409 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats()
410{
411 /* Fetch the latest version of the stats. */
412 NetworkCompanyStatsArray company_stats = NetworkGetCompanyStats();
413
414 /* Go through all the companies. */
415 for (const Company *company : Company::Iterate()) {
416 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_STATS);
417
418 /* Send the information. */
419 p->Send_uint8(company->index);
420
421 for (uint i = 0; i < NETWORK_VEH_END; i++) {
422 p->Send_uint16(company_stats[company->index].num_vehicle[i]);
423 }
424
425 for (uint i = 0; i < NETWORK_VEH_END; i++) {
426 p->Send_uint16(company_stats[company->index].num_station[i]);
427 }
428
429 this->SendPacket(std::move(p));
430 }
431
432 return NETWORK_RECV_STATUS_OKAY;
433}
434
443 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data)
444{
445 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CHAT);
446
447 p->Send_uint8 (action);
448 p->Send_uint8 (desttype);
449 p->Send_uint32(client_id);
450 p->Send_string(msg);
451 p->Send_uint64(data);
452
453 this->SendPacket(std::move(p));
454 return NETWORK_RECV_STATUS_OKAY;
455}
456
461 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRconEnd(std::string_view command)
462{
463 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_RCON_END);
464
465 p->Send_string(command);
466 this->SendPacket(std::move(p));
467
468 return NETWORK_RECV_STATUS_OKAY;
469}
470
476 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16_t colour, std::string_view result)
477{
478 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_RCON);
479
480 p->Send_uint16(colour);
481 p->Send_string(result);
482 this->SendPacket(std::move(p));
483
484 return NETWORK_RECV_STATUS_OKAY;
485}
486
487 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet &p)
488{
489 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
490
491 std::string command = p.Recv_string(NETWORK_RCONCOMMAND_LENGTH);
492
493 Debug(net, 3, "[admin] Rcon command from '{}' ({}): {}", this->admin_name, this->admin_version, command);
494
495 _redirect_console_to_admin = this->index;
496 IConsoleCmdExec(command);
497 _redirect_console_to_admin = AdminID::Invalid();
498 return this->SendRconEnd(command);
499}
500
501 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Packet &p)
502{
503 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
504
505 std::string json = p.Recv_string(NETWORK_GAMESCRIPT_JSON_LENGTH);
506
507 Debug(net, 6, "[admin] GameScript JSON from '{}' ({}): {}", this->admin_name, this->admin_version, json);
508
509 Game::NewEvent(new ScriptEventAdminPort(json));
510 return NETWORK_RECV_STATUS_OKAY;
511}
512
513 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(Packet &p)
514{
515 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
516
517 uint32_t d1 = p.Recv_uint32();
518
519 Debug(net, 6, "[admin] Ping from '{}' ({}): {}", this->admin_name, this->admin_version, d1);
520
521 return this->SendPong(d1);
522}
523
529 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(std::string_view origin, std::string_view string)
530{
531 /* If the length of both strings, plus the 2 '\0' terminations and 3 bytes of the packet
532 * are bigger than the MTU, just ignore the message. Better safe than sorry. It should
533 * never occur though as the longest strings are chat messages, which are still 30%
534 * smaller than COMPAT_MTU. */
535 if (origin.size() + string.size() + 2 + 3 >= COMPAT_MTU) return NETWORK_RECV_STATUS_OKAY;
536
537 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CONSOLE);
538
539 p->Send_string(origin);
540 p->Send_string(string);
541 this->SendPacket(std::move(p));
542
543 return NETWORK_RECV_STATUS_OKAY;
544}
545
550 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(std::string_view json)
551{
552 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_GAMESCRIPT);
553
554 p->Send_string(json);
555 this->SendPacket(std::move(p));
556
557 return NETWORK_RECV_STATUS_OKAY;
558}
559
561 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32_t d1)
562{
563 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_PONG);
564
565 p->Send_uint32(d1);
566 this->SendPacket(std::move(p));
567
568 return NETWORK_RECV_STATUS_OKAY;
569}
570
572 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames()
573{
574 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES);
575
576 for (uint16_t i = 0; i < CMD_END; i++) {
577 std::string_view cmdname = GetCommandName(static_cast<Commands>(i));
578
579 /* Should COMPAT_MTU be exceeded, start a new packet
580 * (magic 5: 1 bool "more data" and one uint16_t "command id", one
581 * byte for string '\0' termination and 1 bool "no more data" */
582 if (!p->CanWriteToPacket(cmdname.size() + 5)) {
583 p->Send_bool(false);
584 this->SendPacket(std::move(p));
585
586 p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES);
587 }
588
589 p->Send_bool(true);
590 p->Send_uint16(i);
591 p->Send_string(cmdname);
592 }
593
594 /* Marker to notify the end of the packet has been reached. */
595 p->Send_bool(false);
596 this->SendPacket(std::move(p));
597
598 return NETWORK_RECV_STATUS_OKAY;
599}
600
606 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdLogging(ClientID client_id, const CommandPacket &cp)
607{
608 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_LOGGING);
609
610 p->Send_uint32(client_id);
611 p->Send_uint8 (cp.company);
612 p->Send_uint16(cp.cmd);
613 p->Send_buffer(cp.data);
614 p->Send_uint32(cp.frame);
615
616 this->SendPacket(std::move(p));
617
618 return NETWORK_RECV_STATUS_OKAY;
619}
620
621/***********
622 * Receiving functions
623 ************/
624
625 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(Packet &p)
626{
627 if (this->status != ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
628
629 if (!_settings_client.network.allow_insecure_admin_login) {
630 /* You're not authorized to login using this method. */
631 return this->SendError(NETWORK_ERROR_NOT_AUTHORIZED);
632 }
633
634 std::string password = p.Recv_string(NETWORK_PASSWORD_LENGTH);
635
636 if (_settings_client.network.admin_password.empty() || _settings_client.network.admin_password != password) {
637 /* Password is invalid */
638 return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
639 }
640
641 this->admin_name = p.Recv_string(NETWORK_CLIENT_NAME_LENGTH);
642 this->admin_version = p.Recv_string(NETWORK_REVISION_LENGTH);
643
644 if (this->admin_name.empty() || this->admin_version.empty()) {
645 /* no name or version supplied */
646 return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
647 }
648
649 Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
650
651 return this->SendProtocol();
652}
653
654 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_QUIT(Packet &)
655{
656 /* The admin is leaving nothing else to do */
657 return this->CloseConnection();
658}
659
660 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY(Packet &p)
661{
662 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
663
664 AdminUpdateType type = (AdminUpdateType)p.Recv_uint16();
665 AdminUpdateFrequencies freq = static_cast<AdminUpdateFrequencies>(p.Recv_uint16());
666
667 if (type >= ADMIN_UPDATE_END || !_admin_update_type_frequencies[type].All(freq)) {
668 /* The server does not know of this UpdateType. */
669 Debug(net, 1, "[admin] Not supported update frequency {} ({}) from '{}' ({})", type, freq, this->admin_name, this->admin_version);
670 return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
671 }
672
673 this->update_frequency[type] = freq;
674
675 if (type == ADMIN_UPDATE_CONSOLE) DebugReconsiderSendRemoteMessages();
676
677 return NETWORK_RECV_STATUS_OKAY;
678}
679
680 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet &p)
681{
682 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
683
684 AdminUpdateType type = (AdminUpdateType)p.Recv_uint8();
685 uint32_t d1 = p.Recv_uint32();
686
687 switch (type) {
688 case ADMIN_UPDATE_DATE:
689 /* The admin is requesting the current date. */
690 this->SendDate();
691 break;
692
693 case ADMIN_UPDATE_CLIENT_INFO:
694 /* The admin is requesting client info. */
695 if (d1 == UINT32_MAX) {
696 this->SendClientInfo(nullptr, NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER));
697 for (const NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
698 this->SendClientInfo(cs, cs->GetInfo());
699 }
700 } else {
701 if (d1 == CLIENT_ID_SERVER) {
702 this->SendClientInfo(nullptr, NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER));
703 } else {
704 const NetworkClientSocket *cs = NetworkClientSocket::GetByClientID((ClientID)d1);
705 if (cs != nullptr) this->SendClientInfo(cs, cs->GetInfo());
706 }
707 }
708 break;
709
710 case ADMIN_UPDATE_COMPANY_INFO:
711 /* The admin is asking for company info. */
712 if (d1 == UINT32_MAX) {
713 for (const Company *company : Company::Iterate()) {
714 this->SendCompanyInfo(company);
715 }
716 } else {
717 const Company *company = Company::GetIfValid(d1);
718 if (company != nullptr) this->SendCompanyInfo(company);
719 }
720 break;
721
722 case ADMIN_UPDATE_COMPANY_ECONOMY:
723 /* The admin is requesting economy info. */
724 this->SendCompanyEconomy();
725 break;
726
727 case ADMIN_UPDATE_COMPANY_STATS:
728 /* the admin is requesting company stats. */
729 this->SendCompanyStats();
730 break;
731
732 case ADMIN_UPDATE_CMD_NAMES:
733 /* The admin is requesting the names of DoCommands. */
734 this->SendCmdNames();
735 break;
736
737 default:
738 /* An unsupported "poll" update type. */
739 Debug(net, 1, "[admin] Not supported poll {} ({}) from '{}' ({}).", type, d1, this->admin_name, this->admin_version);
740 return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
741 }
742
743 return NETWORK_RECV_STATUS_OKAY;
744}
745
746 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet &p)
747{
748 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
749
750 NetworkAction action = (NetworkAction)p.Recv_uint8();
751 DestType desttype = (DestType)p.Recv_uint8();
752 int dest = p.Recv_uint32();
753
754 std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
755
756 switch (action) {
757 case NETWORK_ACTION_CHAT:
758 case NETWORK_ACTION_CHAT_CLIENT:
759 case NETWORK_ACTION_CHAT_COMPANY:
760 case NETWORK_ACTION_SERVER_MESSAGE:
761 NetworkServerSendChat(action, desttype, dest, msg, _network_own_client_id, 0, true);
762 break;
763
764 default:
765 Debug(net, 1, "[admin] Invalid chat action {} from admin '{}' ({}).", action, this->admin_name, this->admin_version);
766 return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
767 }
768
769 return NETWORK_RECV_STATUS_OKAY;
770}
771
772 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(Packet &p)
773{
774 if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
775
776 std::string source = p.Recv_string(NETWORK_CHAT_LENGTH);
777 TextColour colour = (TextColour)p.Recv_uint16();
778 std::string user = p.Recv_string(NETWORK_CHAT_LENGTH);
779 std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
780
781 if (!IsValidConsoleColour(colour)) {
782 Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16_t)colour, source, user, msg, this->admin_name, this->admin_version);
783 return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
784 }
785
786 NetworkServerSendExternalChat(source, colour, user, msg);
787
788 return NETWORK_RECV_STATUS_OKAY;
789}
790
791/*
792 * Secure authentication send and receive methods.
793 */
794
795 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE(Packet &p)
796{
797 if (this->status != ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
798
799 this->admin_name = p.Recv_string(NETWORK_CLIENT_NAME_LENGTH);
800 this->admin_version = p.Recv_string(NETWORK_REVISION_LENGTH);
801 NetworkAuthenticationMethodMask method_mask{p.Recv_uint16()};
802
803 /* Always exclude key exchange only, as that provides no credential checking. */
804 method_mask.Reset(NetworkAuthenticationMethod::X25519_KeyExchangeOnly);
805
806 if (this->admin_name.empty() || this->admin_version.empty()) {
807 /* No name or version supplied. */
808 return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
809 }
810
811 auto handler = NetworkAuthenticationServerHandler::Create(&_admin_password_provider, &_admin_authorized_key_handler, method_mask);
812 if (!handler->CanBeUsed()) return this->SendError(NETWORK_ERROR_NO_AUTHENTICATION_METHOD_AVAILABLE);
813
814 this->authentication_handler = std::move(handler);
815 Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
816
817 return this->SendAuthRequest();
818}
819
820 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendAuthRequest()
821{
822 this->status = ADMIN_STATUS_AUTHENTICATE;
823
824 Debug(net, 6, "[admin] '{}' ({}) authenticating using {}", this->admin_name, this->admin_version, this->authentication_handler->GetName());
825
826 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_AUTH_REQUEST);
827 this->authentication_handler->SendRequest(*p);
828
829 this->SendPacket(std::move(p));
830
831 return NETWORK_RECV_STATUS_OKAY;
832}
833
834 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendEnableEncryption()
835{
836 if (this->status != ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
837
838 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION);
839 this->authentication_handler->SendEnableEncryption(*p);
840 this->SendPacket(std::move(p));
841
842 return NETWORK_RECV_STATUS_OKAY;
843}
844
845 NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_AUTH_RESPONSE(Packet &p)
846{
847 if (this->status != ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
848
849 switch (this->authentication_handler->ReceiveResponse(p)) {
850 case NetworkAuthenticationServerHandler::ResponseResult::Authenticated:
851 Debug(net, 3, "[admin] '{}' ({}) authenticated", this->admin_name, this->admin_version);
852
853 this->SendEnableEncryption();
854
855 this->receive_encryption_handler = this->authentication_handler->CreateClientToServerEncryptionHandler();
856 this->send_encryption_handler = this->authentication_handler->CreateServerToClientEncryptionHandler();
857 this->authentication_handler = nullptr;
858 return this->SendProtocol();
859
860 case NetworkAuthenticationServerHandler::ResponseResult::RetryNextMethod:
861 Debug(net, 6, "[admin] '{}' ({}) authentication failed, trying next method", this->admin_name, this->admin_version);
862 return this->SendAuthRequest();
863
864 case NetworkAuthenticationServerHandler::ResponseResult::NotAuthenticated:
865 default:
866 Debug(net, 3, "[admin] '{}' ({}) authentication failed", this->admin_name, this->admin_version);
867 return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
868 }
869}
870
871/*
872 * Useful wrapper functions
873 */
874
880 void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client)
881{
882 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
883 if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO].Test(AdminUpdateFrequency::Automatic)) {
884 as->SendClientInfo(cs, cs->GetInfo());
885 if (new_client) {
886 as->SendClientJoin(cs->client_id);
887 }
888 }
889 }
890}
891
896 void NetworkAdminClientUpdate(const NetworkClientInfo *ci)
897{
898 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
899 if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO].Test(AdminUpdateFrequency::Automatic)) {
900 as->SendClientUpdate(ci);
901 }
902 }
903}
904
909 void NetworkAdminClientQuit(ClientID client_id)
910{
911 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
912 if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO].Test(AdminUpdateFrequency::Automatic)) {
913 as->SendClientQuit(client_id);
914 }
915 }
916}
917
923 void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code)
924{
925 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
926 if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO].Test(AdminUpdateFrequency::Automatic)) {
927 as->SendClientError(client_id, error_code);
928 }
929 }
930}
931
936 void NetworkAdminCompanyNew(const Company *company)
937{
938 if (company == nullptr) {
939 Debug(net, 1, "[admin] Empty company given for update");
940 return;
941 }
942
943 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
944 if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != AdminUpdateFrequency::Automatic) continue;
945
946 as->SendCompanyNew(company->index);
947 as->SendCompanyInfo(company);
948 }
949}
950
955 void NetworkAdminCompanyUpdate(const Company *company)
956{
957 if (company == nullptr) return;
958
959 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
960 if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != AdminUpdateFrequency::Automatic) continue;
961
962 as->SendCompanyUpdate(company);
963 }
964}
965
971 void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
972{
973 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
974 as->SendCompanyRemove(company_id, bcrr);
975 }
976}
977
978
982 void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data, bool from_admin)
983{
984 if (from_admin) return;
985
986 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
987 if (as->update_frequency[ADMIN_UPDATE_CHAT].Test(AdminUpdateFrequency::Automatic)) {
988 as->SendChat(action, desttype, client_id, msg, data);
989 }
990 }
991}
992
999 void NetworkServerSendAdminRcon(AdminID admin_index, TextColour colour_code, std::string_view string)
1000{
1001 ServerNetworkAdminSocketHandler::Get(admin_index)->SendRcon(colour_code, string);
1002}
1003
1009 void NetworkAdminConsole(std::string_view origin, std::string_view string)
1010{
1011 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
1012 if (as->update_frequency[ADMIN_UPDATE_CONSOLE].Test(AdminUpdateFrequency::Automatic)) {
1013 as->SendConsole(origin, string);
1014 }
1015 }
1016}
1017
1022 void NetworkAdminGameScript(std::string_view json)
1023{
1024 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
1025 if (as->update_frequency[ADMIN_UPDATE_GAMESCRIPT].Test(AdminUpdateFrequency::Automatic)) {
1026 as->SendGameScript(json);
1027 }
1028 }
1029}
1030
1036 void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket &cp)
1037{
1038 ClientID client_id = owner == nullptr ? _network_own_client_id : owner->client_id;
1039
1040 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
1041 if (as->update_frequency[ADMIN_UPDATE_CMD_LOGGING].Test(AdminUpdateFrequency::Automatic)) {
1042 as->SendCmdLogging(client_id, cp);
1043 }
1044 }
1045}
1046
1050 void ServerNetworkAdminSocketHandler::WelcomeAll()
1051{
1052 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
1053 as->SendWelcome();
1054 }
1055}
1056
1061 void NetworkAdminUpdate(AdminUpdateFrequency freq)
1062{
1063 for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) {
1064 for (int i = 0; i < ADMIN_UPDATE_END; i++) {
1065 if (as->update_frequency[i].Test(freq)) {
1066 /* Update the admin for the required details */
1067 switch (i) {
1068 case ADMIN_UPDATE_DATE:
1069 as->SendDate();
1070 break;
1071
1072 case ADMIN_UPDATE_COMPANY_ECONOMY:
1073 as->SendCompanyEconomy();
1074 break;
1075
1076 case ADMIN_UPDATE_COMPANY_STATS:
1077 as->SendCompanyStats();
1078 break;
1079
1080 default: NOT_REACHED();
1081 }
1082 }
1083 }
1084 }
1085}
EnumBitSet
Enum-as-bit-set wrapper.
Definition enum_type.hpp:177
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition game_core.cpp:136
NetworkAddress
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Definition address.h:28
NetworkAdminSocketHandler
Main socket handler for admin related connections.
Definition tcp_admin.h:116
NetworkAdminSocketHandler::CloseConnection
NetworkRecvStatus CloseConnection(bool error=true) override
This will put this socket handler in a close state.
Definition tcp_admin.cpp:26
NetworkAdminSocketHandler::status
AdminStatus status
Status of this admin.
Definition tcp_admin.h:120
NetworkAdminSocketHandler::admin_version
std::string admin_version
Version string of the admin.
Definition tcp_admin.h:119
NetworkAdminSocketHandler::admin_name
std::string admin_name
Name of the admin.
Definition tcp_admin.h:118
NetworkAuthenticationDefaultAuthorizedKeyHandler
Default implementation for the authorized key handler.
Definition network_crypto.h:161
NetworkAuthenticationDefaultPasswordProvider
Default implementation of the password provider.
Definition network_crypto.h:123
NetworkAuthenticationServerHandler::Create
static std::unique_ptr< NetworkAuthenticationServerHandler > Create(const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask={NetworkAuthenticationMethod::X25519_KeyExchangeOnly, NetworkAuthenticationMethod::X25519_PAKE, NetworkAuthenticationMethod::X25519_AuthorizedKey})
Create a NetworkAuthenticationServerHandler.
Definition network_crypto.cpp:478
NetworkAuthenticationServerHandler::ResponseResult::RetryNextMethod
@ RetryNextMethod
The client failed to authenticate, but there is another method to try.
NetworkAuthenticationServerHandler::ResponseResult::NotAuthenticated
@ NotAuthenticated
All authentications for this handler have been exhausted.
NetworkAuthenticationServerHandler::ResponseResult::Authenticated
@ Authenticated
The client was authenticated successfully.
NetworkSocketHandler::send_encryption_handler
std::unique_ptr< class NetworkEncryptionHandler > send_encryption_handler
The handler for encrypting sent packets.
Definition core.h:50
NetworkSocketHandler::receive_encryption_handler
std::unique_ptr< class NetworkEncryptionHandler > receive_encryption_handler
The handler for decrypting received packets.
Definition core.h:49
NetworkTCPSocketHandler::SendPacket
virtual void SendPacket(std::unique_ptr< Packet > &&packet)
This function puts the packet in the send-queue and it is send as soon as possible.
Definition tcp.cpp:58
OverflowSafeInt< int64_t >
ServerNetworkAdminSocketHandler
Class for handling the server side of the game connection.
Definition network_admin.h:25
ServerNetworkAdminSocketHandler::Send
static void Send()
Send the packets for the server sockets.
Definition network_admin.cpp:97
ServerNetworkAdminSocketHandler::SendGameScript
NetworkRecvStatus SendGameScript(std::string_view json)
Send GameScript JSON output.
Definition network_admin.cpp:550
ServerNetworkAdminSocketHandler::SendPong
NetworkRecvStatus SendPong(uint32_t d1)
Send ping-reply (pong) to admin.
Definition network_admin.cpp:561
ServerNetworkAdminSocketHandler::SendDate
NetworkRecvStatus SendDate()
Tell the admin the date.
Definition network_admin.cpp:207
ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE
NetworkRecvStatus Receive_ADMIN_JOIN_SECURE(Packet &p) override
Join the admin network using a secure authentication method: string Name of the application being use...
Definition network_admin.cpp:795
ServerNetworkAdminSocketHandler::SendClientUpdate
NetworkRecvStatus SendClientUpdate(const NetworkClientInfo *ci)
Send an update for some client's information.
Definition network_admin.cpp:260
ServerNetworkAdminSocketHandler::SendClientInfo
NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci)
Send an initial set of data from some client's information.
Definition network_admin.cpp:236
ServerNetworkAdminSocketHandler::SendRconEnd
NetworkRecvStatus SendRconEnd(std::string_view command)
Send a notification indicating the rcon command has completed.
Definition network_admin.cpp:461
ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY
NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet &p) override
Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16_t Up...
Definition network_admin.cpp:660
ServerNetworkAdminSocketHandler::SendNewGame
NetworkRecvStatus SendNewGame()
Tell the admin we started a new game.
Definition network_admin.cpp:191
ServerNetworkAdminSocketHandler::SendCompanyRemove
NetworkRecvStatus SendCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Tell the admin that a company got removed.
Definition network_admin.cpp:365
ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON
NetworkRecvStatus Receive_ADMIN_RCON(Packet &p) override
Execute a command on the servers console: string Command to be executed.
Definition network_admin.cpp:487
ServerNetworkAdminSocketHandler::update_frequency
std::array< AdminUpdateFrequencies, ADMIN_UPDATE_END > update_frequency
Admin requested update intervals.
Definition network_admin.h:46
ServerNetworkAdminSocketHandler::SendClientError
NetworkRecvStatus SendClientError(ClientID client_id, NetworkErrorCode error)
Tell the admin that a client made an error.
Definition network_admin.cpp:292
ServerNetworkAdminSocketHandler::SendCmdNames
NetworkRecvStatus SendCmdNames()
Send the names of the commands.
Definition network_admin.cpp:572
ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL
NetworkRecvStatus Receive_ADMIN_POLL(Packet &p) override
Poll the server for certain updates, an invalid poll (e.g.
Definition network_admin.cpp:680
ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN
NetworkRecvStatus Receive_ADMIN_JOIN(Packet &p) override
Join the admin network using an unsecured password exchange: string Unsecured password the server is ...
Definition network_admin.cpp:625
ServerNetworkAdminSocketHandler::SendShutdown
NetworkRecvStatus SendShutdown()
Tell the admin we're shutting down.
Definition network_admin.cpp:199
ServerNetworkAdminSocketHandler::SendCompanyStats
NetworkRecvStatus SendCompanyStats()
Send statistics about the companies.
Definition network_admin.cpp:409
ServerNetworkAdminSocketHandler::SendWelcome
NetworkRecvStatus SendWelcome()
Send a welcome message to the admin.
Definition network_admin.cpp:170
ServerNetworkAdminSocketHandler::SendCompanyInfo
NetworkRecvStatus SendCompanyInfo(const Company *c)
Send the admin some information about a company.
Definition network_admin.cpp:321
ServerNetworkAdminSocketHandler::WelcomeAll
static void WelcomeAll()
Send a Welcome packet to all connected admins.
Definition network_admin.cpp:1050
ServerNetworkAdminSocketHandler::AcceptConnection
static void AcceptConnection(SOCKET s, const NetworkAddress &address)
Handle the acceptance of a connection.
Definition network_admin.cpp:116
ServerNetworkAdminSocketHandler::SendCmdLogging
NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket &cp)
Send a command for logging purposes.
Definition network_admin.cpp:606
ServerNetworkAdminSocketHandler::authentication_handler
std::unique_ptr< NetworkAuthenticationServerHandler > authentication_handler
The handler for the authentication.
Definition network_admin.h:27
ServerNetworkAdminSocketHandler::AllowConnection
static bool AllowConnection()
Whether a connection is allowed or not at this moment.
Definition network_admin.cpp:91
ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT
NetworkRecvStatus Receive_ADMIN_CHAT(Packet &p) override
Send chat as the server: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
Definition network_admin.cpp:746
ServerNetworkAdminSocketHandler::IterateActive
static Pool::IterateWrapperFiltered< ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter > IterateActive(size_t from=0)
Returns an iterable ensemble of all active admin sockets.
Definition network_admin.h:102
ServerNetworkAdminSocketHandler::SendRcon
NetworkRecvStatus SendRcon(uint16_t colour, std::string_view command)
Send the reply of an rcon command.
Definition network_admin.cpp:476
ServerNetworkAdminSocketHandler::SendConsole
NetworkRecvStatus SendConsole(std::string_view origin, std::string_view command)
Send console output of other clients.
Definition network_admin.cpp:529
ServerNetworkAdminSocketHandler::SendCompanyEconomy
NetworkRecvStatus SendCompanyEconomy()
Send economic information of all companies.
Definition network_admin.cpp:378
ServerNetworkAdminSocketHandler::Receive_ADMIN_AUTH_RESPONSE
NetworkRecvStatus Receive_ADMIN_AUTH_RESPONSE(Packet &p) override
Admin responds to ADMIN_PACKET_SERVER_AUTH_REQUEST with the appropriate data given the agreed upon Ne...
Definition network_admin.cpp:845
ServerNetworkAdminSocketHandler::SendChat
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data)
Send a chat message.
Definition network_admin.cpp:443
ServerNetworkAdminSocketHandler::SendCompanyUpdate
NetworkRecvStatus SendCompanyUpdate(const Company *c)
Send an update about a company.
Definition network_admin.cpp:344
ServerNetworkAdminSocketHandler::address
NetworkAddress address
Address of the admin.
Definition network_admin.h:48
ServerNetworkAdminSocketHandler::SendClientQuit
NetworkRecvStatus SendClientQuit(ClientID client_id)
Tell the admin that a client quit.
Definition network_admin.cpp:277
ServerNetworkAdminSocketHandler::SendCompanyNew
NetworkRecvStatus SendCompanyNew(CompanyID company_id)
Tell the admin that a new company was founded.
Definition network_admin.cpp:307
ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT
NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet &p) override
Send a JSON string to the current active GameScript.
Definition network_admin.cpp:501
ServerNetworkAdminSocketHandler::SendProtocol
NetworkRecvStatus SendProtocol()
Send the protocol version to the admin.
Definition network_admin.cpp:148
ServerNetworkAdminSocketHandler::SendClientJoin
NetworkRecvStatus SendClientJoin(ClientID client_id)
Tell the admin that a client joined.
Definition network_admin.cpp:221
ServerNetworkAdminSocketHandler::connect_time
std::chrono::steady_clock::time_point connect_time
Time of connection.
Definition network_admin.h:47
ServerNetworkAdminSocketHandler::Receive_ADMIN_PING
NetworkRecvStatus Receive_ADMIN_PING(Packet &p) override
Ping the server, requiring the server to reply with a pong packet.
Definition network_admin.cpp:513
ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT
NetworkRecvStatus Receive_ADMIN_EXTERNAL_CHAT(Packet &p) override
Send chat from the external source: string Name of the source this message came from.
Definition network_admin.cpp:772
ServerNetworkAdminSocketHandler::Receive_ADMIN_QUIT
NetworkRecvStatus Receive_ADMIN_QUIT(Packet &p) override
Notification to the server that this admin is quitting.
Definition network_admin.cpp:654
ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler
~ServerNetworkAdminSocketHandler()
Clear everything related to this admin.
Definition network_admin.cpp:76
ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler
ServerNetworkAdminSocketHandler(SOCKET s)
Sanity check.
Definition network_admin.cpp:67
ServerNetworkAdminSocketHandler::SendError
NetworkRecvStatus SendError(NetworkErrorCode error)
Send an error to the admin.
Definition network_admin.cpp:130
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition timer_game_calendar.cpp:55
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition timer_game_calendar.h:33
TypedIndexContainer
A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific type.
Definition convertible_through_base.hpp:38
GetCommandName
std::string_view GetCommandName(Commands cmd)
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given com...
Definition command.cpp:132
Commands
Commands
List of commands.
Definition command_type.h:196
CMD_END
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
Definition command_type.h:378
NETWORK_GAMESCRIPT_JSON_LENGTH
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH
The maximum length of a receiving gamescript json string, in bytes including '\0'.
Definition config.h:60
NETWORK_CLIENT_NAME_LENGTH
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
Definition config.h:58
NETWORK_CHAT_LENGTH
static const uint NETWORK_CHAT_LENGTH
The maximum length of a chat message, in bytes including '\0'.
Definition config.h:61
COMPAT_MTU
static const size_t COMPAT_MTU
Number of bytes we can pack in a single packet for backward compatibility.
Definition config.h:46
NETWORK_REVISION_LENGTH
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including '\0'.
Definition config.h:56
NETWORK_RCONCOMMAND_LENGTH
static const uint NETWORK_RCONCOMMAND_LENGTH
The maximum length of a rconsole command, in bytes including '\0'.
Definition config.h:59
NETWORK_PASSWORD_LENGTH
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0'.
Definition config.h:57
NETWORK_GAME_ADMIN_VERSION
static const uint8_t NETWORK_GAME_ADMIN_VERSION
What version of the admin network do we use?
Definition config.h:48
IConsoleCmdExec
void IConsoleCmdExec(std::string_view command_string, const uint recurse_count)
Execute a given command passed to us.
Definition console.cpp:269
IsValidConsoleColour
bool IsValidConsoleColour(TextColour c)
Check whether the given TextColour is valid for console usage.
Definition console_gui.cpp:538
NetworkRecvStatus
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition core.h:23
NETWORK_RECV_STATUS_OKAY
@ NETWORK_RECV_STATUS_OKAY
Everything is okay.
Definition core.h:24
DebugReconsiderSendRemoteMessages
void DebugReconsiderSendRemoteMessages()
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
Definition debug.cpp:259
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:307
CeilDiv
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition math_func.hpp:310
GetNetworkErrorMsg
StringID GetNetworkErrorMsg(NetworkErrorCode err)
Retrieve the string id of an internal error number.
Definition network.cpp:310
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition network.cpp:69
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition network.cpp:71
NetworkAdminClientUpdate
void NetworkAdminClientUpdate(const NetworkClientInfo *ci)
Notify the admin network of a client update (if they did opt in for the respective update).
Definition network_admin.cpp:896
NetworkAdminClientQuit
void NetworkAdminClientQuit(ClientID client_id)
Notify the admin network that a client quit (if they have opt in for the respective update).
Definition network_admin.cpp:909
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 network_admin.cpp:982
NetworkAdminCompanyUpdate
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
Definition network_admin.cpp:955
NetworkAdminUpdate
void NetworkAdminUpdate(AdminUpdateFrequency freq)
Send (push) updates to the admin network as they have registered for these updates.
Definition network_admin.cpp:1061
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).
Definition network_admin.cpp:880
NetworkAdminCmdLogging
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket &cp)
Distribute CommandPacket details over the admin network for logging purposes.
Definition network_admin.cpp:1036
NetworkServerSendAdminRcon
void NetworkServerSendAdminRcon(AdminID admin_index, TextColour colour_code, std::string_view string)
Pass the rcon reply to the admin.
Definition network_admin.cpp:999
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).
Definition network_admin.cpp:923
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).
Definition network_admin.cpp:1009
NetworkAdminGameScript
void NetworkAdminGameScript(std::string_view json)
Send GameScript JSON to the admin network (if they did opt in for the respective update).
Definition network_admin.cpp:1022
NetworkAdminCompanyNew
void NetworkAdminCompanyNew(const Company *company)
Notify the admin network of a new company.
Definition network_admin.cpp:936
_admin_authorized_key_handler
static NetworkAuthenticationDefaultAuthorizedKeyHandler _admin_authorized_key_handler(_settings_client.network.admin_authorized_keys)
Provides the authorized key handling for the game authentication.
_admin_update_type_frequencies
static const AdminUpdateFrequencies _admin_update_type_frequencies[]
Frequencies, which may be registered for a certain update type.
Definition network_admin.cpp:48
_admin_password_provider
static NetworkAuthenticationDefaultPasswordProvider _admin_password_provider(_settings_client.network.admin_password)
Provides the password validation for the game's password.
_networkadminsocket_pool
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket")
The pool with sockets/clients.
NetworkAdminCompanyRemove
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Notify the admin network of a company to be removed (including the reason why).
Definition network_admin.cpp:971
_redirect_console_to_admin
AdminID _redirect_console_to_admin
Redirection of the (remote) console to the admin.
Definition network_admin.cpp:34
ADMIN_AUTHORISATION_TIMEOUT
static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10)
The timeout for authorisation of the client.
network_admin.h
Server part of the admin network protocol.
_redirect_console_to_admin
AdminID _redirect_console_to_admin
Redirection of the (remote) console to the admin.
Definition network_admin.cpp:34
network_base.h
Base core network types and some helper functions to access them.
NetworkAuthenticationMethod::X25519_KeyExchangeOnly
@ X25519_KeyExchangeOnly
No actual authentication is taking place, just perform a x25519 key exchange. This method is not supp...
NetworkServerSendExternalChat
void NetworkServerSendExternalChat(std::string_view source, TextColour colour, std::string_view user, std::string_view msg)
Send a chat message from external source.
Definition network_server.cpp:1369
NetworkGetCompanyStats
NetworkCompanyStatsArray NetworkGetCompanyStats()
Get the company stats.
Definition network_server.cpp:1491
NetworkServerSendChat
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, std::string_view msg, ClientID from_id, int64_t data=0, bool from_admin=false)
Send an actual chat message.
Definition network_server.cpp:1252
network_server.h
Server part of the network protocol.
DestType
DestType
Destination of our chat messages.
Definition network_type.h:68
NetworkErrorCode
NetworkErrorCode
The error codes we send around in the protocols.
Definition network_type.h:99
NetworkAction
NetworkAction
Actions that can be used for NetworkTextMessage.
Definition network_type.h:79
ClientID
ClientID
'Unique' identifier to be given to clients
Definition network_type.h:43
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition network_type.h:45
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition pool_func.hpp:210
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
ClientSettings::network
NetworkSettings network
settings related to the network
Definition settings_type.h:651
CommandPacket
Everything we need to know about a command to be able to execute it.
Definition network_internal.h:95
CommandPacket::data
CommandDataBuffer data
command parameters.
Definition network_internal.h:103
CommandPacket::frame
uint32_t frame
the frame in which this packet is executed
Definition network_internal.h:97
CommandPacket::company
CompanyID company
company that is executing the command
Definition network_internal.h:96
CommandPacket::cmd
Commands cmd
command being executed.
Definition network_internal.h:100
CompanyProperties::months_of_bankruptcy
uint8_t months_of_bankruptcy
Number of months that the company is unable to pay its debts.
Definition company_base.h:100
CompanyProperties::is_ai
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Definition company_base.h:114
CompanyProperties::inaugurated_year
TimerGameEconomy::Year inaugurated_year
Economy year of starting the company.
Definition company_base.h:96
CompanyProperties::colour
Colours colour
Company colour.
Definition company_base.h:89
Company
Definition company_base.h:127
GameCreationSettings::landscape
LandscapeType landscape
the landscape we're currently in
Definition settings_type.h:395
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition settings_type.h:380
GameCreationSettings::generation_seed
uint32_t generation_seed
noise seed for world generation
Definition settings_type.h:379
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition settings_type.h:634
Map::SizeX
static uint SizeX()
Get the size of the map along the X.
Definition map_func.h:272
Map::SizeY
static uint SizeY()
Get the size of the map along the Y.
Definition map_func.h:281
NetworkClientInfo
Container for all information known about a client.
Definition network_base.h:24
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition network.cpp:117
NetworkClientInfo::join_date
TimerGameEconomy::Date join_date
Gamedate the client has joined.
Definition network_base.h:29
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition network_base.h:28
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition network_base.h:25
NetworkClientInfo::client_name
std::string client_name
Name of the client.
Definition network_base.h:26
NetworkSettings::allow_insecure_admin_login
bool allow_insecure_admin_login
Whether to allow logging in as admin using the insecure old JOIN packet.
Definition settings_type.h:354
NetworkSettings::admin_password
std::string admin_password
password for the admin network
Definition settings_type.h:355
NetworkSettings::server_name
std::string server_name
name of the server
Definition settings_type.h:349
Packet
Internal entity of a packet.
Definition packet.h:43
Packet::Recv_uint16
uint16_t Recv_uint16()
Read a 16 bits integer from the packet.
Definition packet.cpp:332
Packet::Recv_uint32
uint32_t Recv_uint32()
Read a 32 bits integer from the packet.
Definition packet.cpp:347
Packet::Recv_string
std::string Recv_string(size_t length, StringValidationSettings settings=StringValidationSetting::ReplaceWithQuestionMark)
Reads characters (bytes) from the packet until it finds a '\0', or reaches a maximum of length charac...
Definition packet.cpp:425
Packet::Recv_uint8
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
Definition packet.cpp:318
PoolID
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:43
Pool::PoolItem<&_networkadminsocket_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition pool_type.hpp:436
Pool::PoolItem<&_networkadminsocket_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool::PoolItem<&_networkadminsocket_pool >::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:286
Pool::PoolItem<&_networkadminsocket_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition pool_type.hpp:357
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(auto index)
Returns Titem with given index.
Definition pool_type.hpp:398
Pool
Base class for all pools.
Definition pool_type.hpp:133
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_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_SERVER_GAMESCRIPT
@ ADMIN_PACKET_SERVER_GAMESCRIPT
The server gives the admin information from the GameScript in JSON.
Definition tcp_admin.h:61
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_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_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_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_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_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_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_SERVER_RCON
@ ADMIN_PACKET_SERVER_RCON
The server's reply to a remove console command.
Definition tcp_admin.h:57
AdminUpdateType
AdminUpdateType
Update types an admin can register a frequency for.
Definition tcp_admin.h:80
ADMIN_UPDATE_DATE
@ ADMIN_UPDATE_DATE
Updates about the date of the game.
Definition tcp_admin.h:81
ADMIN_UPDATE_GAMESCRIPT
@ ADMIN_UPDATE_GAMESCRIPT
The admin would like to have gamescript messages.
Definition tcp_admin.h:90
ADMIN_UPDATE_COMPANY_INFO
@ ADMIN_UPDATE_COMPANY_INFO
Updates about the generic information of companies.
Definition tcp_admin.h:83
ADMIN_UPDATE_CONSOLE
@ ADMIN_UPDATE_CONSOLE
The admin would like to have console messages.
Definition tcp_admin.h:87
ADMIN_UPDATE_CHAT
@ ADMIN_UPDATE_CHAT
The admin would like to have chat messages.
Definition tcp_admin.h:86
ADMIN_UPDATE_COMPANY_STATS
@ ADMIN_UPDATE_COMPANY_STATS
Updates about the statistics of companies.
Definition tcp_admin.h:85
ADMIN_UPDATE_COMPANY_ECONOMY
@ ADMIN_UPDATE_COMPANY_ECONOMY
Updates about the economy of companies.
Definition tcp_admin.h:84
ADMIN_UPDATE_END
@ ADMIN_UPDATE_END
Must ALWAYS be on the end of this list!! (period)
Definition tcp_admin.h:91
ADMIN_UPDATE_CLIENT_INFO
@ ADMIN_UPDATE_CLIENT_INFO
Updates about the information of clients.
Definition tcp_admin.h:82
ADMIN_UPDATE_CMD_NAMES
@ ADMIN_UPDATE_CMD_NAMES
The admin would like a list of all DoCommand names.
Definition tcp_admin.h:88
ADMIN_UPDATE_CMD_LOGGING
@ ADMIN_UPDATE_CMD_LOGGING
The admin would like to have DoCommand information.
Definition tcp_admin.h:89
AdminCompanyRemoveReason
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
Definition tcp_admin.h:107
AdminUpdateFrequency
AdminUpdateFrequency
Update frequencies an admin can register.
Definition tcp_admin.h:95
AdminUpdateFrequency::Automatic
@ Automatic
The admin gets information about this when it changes.
AdminUpdateFrequency::Annually
@ Annually
The admin gets information about this on a yearly basis.
AdminUpdateFrequency::Weekly
@ Weekly
The admin gets information about this on a weekly basis.
AdminUpdateFrequency::Poll
@ Poll
The admin can poll this.
AdminUpdateFrequency::Monthly
@ Monthly
The admin gets information about this on a monthly basis.
AdminUpdateFrequency::Quarterly
@ Quarterly
The admin gets information about this on a quarterly basis.
AdminUpdateFrequency::Daily
@ Daily
The admin gets information about this on a daily basis.
ADMIN_STATUS_INACTIVE
@ ADMIN_STATUS_INACTIVE
The admin is not connected nor active.
Definition tcp_admin.h:73
ADMIN_STATUS_ACTIVE
@ ADMIN_STATUS_ACTIVE
The admin is active.
Definition tcp_admin.h:75
ADMIN_STATUS_AUTHENTICATE
@ ADMIN_STATUS_AUTHENTICATE
The admin is connected and working on authentication.
Definition tcp_admin.h:74