OpenTTD Source  20241121-master-g67a0fccfad
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 <http://www.gnu.org/licenses/>.
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 "../safeguards.h"
27 
28 
29 /* This file handles all the admin network commands. */
30 
33 
36 
39 INSTANTIATE_POOL_METHODS(NetworkAdminSocket)
40 
43 
45 static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10);
46 
47 
60 };
63 
69 {
72  this->connect_time = std::chrono::steady_clock::now();
73 }
74 
79 {
81  Debug(net, 3, "[admin] '{}' ({}) has disconnected", this->admin_name, this->admin_version);
83 
87  }
88 }
89 
95 {
96  bool accept = _settings_client.network.AdminAuthenticationConfigured() && _network_admins_connected < MAX_ADMINS;
97  /* We can't go over the MAX_ADMINS limit here. However, if we accept
98  * the connection, there has to be space in the pool. */
101  return accept;
102 }
103 
106 {
108  if (as->status <= ADMIN_STATUS_AUTHENTICATE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) {
109  Debug(net, 2, "[admin] Admin did not send its authorisation within {} seconds", std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
110  as->CloseConnection(true);
111  continue;
112  }
113  if (as->writable) {
114  as->SendPackets();
115  }
116  }
117 }
118 
124 /* static */ void ServerNetworkAdminSocketHandler::AcceptConnection(SOCKET s, const NetworkAddress &address)
125 {
127  as->address = address; // Save the IP of the client
128 }
129 
130 /***********
131  * Sending functions for admin network
132  ************/
133 
139 {
140  /* Whatever the error might be, authentication (keys) must be released as soon as possible. */
141  this->authentication_handler = nullptr;
142 
143  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_ERROR);
144 
145  p->Send_uint8(error);
146  this->SendPacket(std::move(p));
147 
148  std::string error_message = GetString(GetNetworkErrorMsg(error));
149 
150  Debug(net, 1, "[admin] The admin '{}' ({}) made an error and has been disconnected: '{}'", this->admin_name, this->admin_version, error_message);
151 
152  return this->CloseConnection(true);
153 }
154 
157 {
158  this->status = ADMIN_STATUS_ACTIVE;
159 
160  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_PROTOCOL);
161 
162  /* announce the protocol version */
163  p->Send_uint8(NETWORK_GAME_ADMIN_VERSION);
164 
165  for (int i = 0; i < ADMIN_UPDATE_END; i++) {
166  p->Send_bool (true);
167  p->Send_uint16(i);
168  p->Send_uint16(_admin_update_type_frequencies[i]);
169  }
170 
171  p->Send_bool(false);
172  this->SendPacket(std::move(p));
173 
174  return this->SendWelcome();
175 }
176 
179 {
180  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_WELCOME);
181 
182  p->Send_string(_settings_client.network.server_name);
183  p->Send_string(GetNetworkRevisionString());
184  p->Send_bool (_network_dedicated);
185 
186  p->Send_string(""); // Used to be map-name.
188  p->Send_uint8 (_settings_game.game_creation.landscape);
190  p->Send_uint16(Map::SizeX());
191  p->Send_uint16(Map::SizeY());
192 
193  this->SendPacket(std::move(p));
194 
196 }
197 
200 {
201  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_NEWGAME);
202  this->SendPacket(std::move(p));
204 }
205 
208 {
209  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_SHUTDOWN);
210  this->SendPacket(std::move(p));
212 }
213 
216 {
217  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_DATE);
218 
219  p->Send_uint32(TimerGameCalendar::date.base());
220  this->SendPacket(std::move(p));
221 
223 }
224 
230 {
231  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_JOIN);
232 
233  p->Send_uint32(client_id);
234  this->SendPacket(std::move(p));
235 
237 }
238 
245 {
246  /* Only send data when we're a proper client, not just someone trying to query the server. */
247  if (ci == nullptr) return NETWORK_RECV_STATUS_OKAY;
248 
249  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_INFO);
250 
251  p->Send_uint32(ci->client_id);
252  p->Send_string(cs == nullptr ? "" : const_cast<NetworkAddress &>(cs->client_address).GetHostname());
253  p->Send_string(ci->client_name);
254  p->Send_uint8 (0); // Used to be language
255  p->Send_uint32(ci->join_date.base());
256  p->Send_uint8 (ci->client_playas);
257 
258  this->SendPacket(std::move(p));
259 
261 }
262 
263 
269 {
270  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_UPDATE);
271 
272  p->Send_uint32(ci->client_id);
273  p->Send_string(ci->client_name);
274  p->Send_uint8 (ci->client_playas);
275 
276  this->SendPacket(std::move(p));
277 
279 }
280 
286 {
287  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_QUIT);
288 
289  p->Send_uint32(client_id);
290  this->SendPacket(std::move(p));
291 
293 }
294 
301 {
302  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CLIENT_ERROR);
303 
304  p->Send_uint32(client_id);
305  p->Send_uint8 (error);
306  this->SendPacket(std::move(p));
307 
309 }
310 
316 {
317  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_NEW);
318  p->Send_uint8(company_id);
319 
320  this->SendPacket(std::move(p));
321 
323 }
324 
330 {
331  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_INFO);
332 
333  p->Send_uint8 (c->index);
334  SetDParam(0, c->index);
335  p->Send_string(GetString(STR_COMPANY_NAME));
336  SetDParam(0, c->index);
337  p->Send_string(GetString(STR_PRESIDENT_NAME));
338  p->Send_uint8 (c->colour);
339  p->Send_bool (true);
340  p->Send_uint32(c->inaugurated_year.base());
341  p->Send_bool (c->is_ai);
342  p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
343 
344  this->SendPacket(std::move(p));
345 
347 }
348 
349 
355 {
356  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_UPDATE);
357 
358  p->Send_uint8 (c->index);
359  SetDParam(0, c->index);
360  p->Send_string(GetString(STR_COMPANY_NAME));
361  SetDParam(0, c->index);
362  p->Send_string(GetString(STR_PRESIDENT_NAME));
363  p->Send_uint8 (c->colour);
364  p->Send_bool (true);
365  p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
366 
367  this->SendPacket(std::move(p));
368 
370 }
371 
378 {
379  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_REMOVE);
380 
381  p->Send_uint8(company_id);
382  p->Send_uint8(acrr);
383 
384  this->SendPacket(std::move(p));
385 
387 }
388 
391 {
392  for (const Company *company : Company::Iterate()) {
393  /* Get the income. */
394  Money income = -std::reduce(std::begin(company->yearly_expenses[0]), std::end(company->yearly_expenses[0]));
395 
396  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_ECONOMY);
397 
398  p->Send_uint8(company->index);
399 
400  /* Current information. */
401  p->Send_uint64(company->money);
402  p->Send_uint64(company->current_loan);
403  p->Send_uint64(income);
404  p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<OverflowSafeInt64>())));
405 
406  /* Send stats for the last 2 quarters. */
407  for (uint i = 0; i < 2; i++) {
408  p->Send_uint64(company->old_economy[i].company_value);
409  p->Send_uint16(company->old_economy[i].performance_history);
410  p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<OverflowSafeInt64>())));
411  }
412 
413  this->SendPacket(std::move(p));
414  }
415 
416 
418 }
419 
422 {
423  /* Fetch the latest version of the stats. */
424  NetworkCompanyStats company_stats[MAX_COMPANIES];
425  NetworkPopulateCompanyStats(company_stats);
426 
427  /* Go through all the companies. */
428  for (const Company *company : Company::Iterate()) {
429  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_STATS);
430 
431  /* Send the information. */
432  p->Send_uint8(company->index);
433 
434  for (uint i = 0; i < NETWORK_VEH_END; i++) {
435  p->Send_uint16(company_stats[company->index].num_vehicle[i]);
436  }
437 
438  for (uint i = 0; i < NETWORK_VEH_END; i++) {
439  p->Send_uint16(company_stats[company->index].num_station[i]);
440  }
441 
442  this->SendPacket(std::move(p));
443  }
444 
446 }
447 
456 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data)
457 {
458  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CHAT);
459 
460  p->Send_uint8 (action);
461  p->Send_uint8 (desttype);
462  p->Send_uint32(client_id);
463  p->Send_string(msg);
464  p->Send_uint64(data);
465 
466  this->SendPacket(std::move(p));
468 }
469 
475 {
476  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_RCON_END);
477 
478  p->Send_string(command);
479  this->SendPacket(std::move(p));
480 
482 }
483 
489 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16_t colour, const std::string_view result)
490 {
491  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_RCON);
492 
493  p->Send_uint16(colour);
494  p->Send_string(result);
495  this->SendPacket(std::move(p));
496 
498 }
499 
501 {
502  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
503 
504  std::string command = p.Recv_string(NETWORK_RCONCOMMAND_LENGTH);
505 
506  Debug(net, 3, "[admin] Rcon command from '{}' ({}): {}", this->admin_name, this->admin_version, command);
507 
509  IConsoleCmdExec(command);
511  return this->SendRconEnd(command);
512 }
513 
515 {
516  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
517 
518  std::string json = p.Recv_string(NETWORK_GAMESCRIPT_JSON_LENGTH);
519 
520  Debug(net, 6, "[admin] GameScript JSON from '{}' ({}): {}", this->admin_name, this->admin_version, json);
521 
522  Game::NewEvent(new ScriptEventAdminPort(json));
524 }
525 
527 {
528  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
529 
530  uint32_t d1 = p.Recv_uint32();
531 
532  Debug(net, 6, "[admin] Ping from '{}' ({}): {}", this->admin_name, this->admin_version, d1);
533 
534  return this->SendPong(d1);
535 }
536 
542 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(const std::string_view origin, const std::string_view string)
543 {
544  /* If the length of both strings, plus the 2 '\0' terminations and 3 bytes of the packet
545  * are bigger than the MTU, just ignore the message. Better safe than sorry. It should
546  * never occur though as the longest strings are chat messages, which are still 30%
547  * smaller than COMPAT_MTU. */
548  if (origin.size() + string.size() + 2 + 3 >= COMPAT_MTU) return NETWORK_RECV_STATUS_OKAY;
549 
550  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CONSOLE);
551 
552  p->Send_string(origin);
553  p->Send_string(string);
554  this->SendPacket(std::move(p));
555 
557 }
558 
564 {
565  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_GAMESCRIPT);
566 
567  p->Send_string(json);
568  this->SendPacket(std::move(p));
569 
571 }
572 
575 {
576  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_PONG);
577 
578  p->Send_uint32(d1);
579  this->SendPacket(std::move(p));
580 
582 }
583 
586 {
587  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES);
588 
589  for (uint16_t i = 0; i < CMD_END; i++) {
590  const char *cmdname = GetCommandName(static_cast<Commands>(i));
591 
592  /* Should COMPAT_MTU be exceeded, start a new packet
593  * (magic 5: 1 bool "more data" and one uint16_t "command id", one
594  * byte for string '\0' termination and 1 bool "no more data" */
595  if (!p->CanWriteToPacket(strlen(cmdname) + 5)) {
596  p->Send_bool(false);
597  this->SendPacket(std::move(p));
598 
599  p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_NAMES);
600  }
601 
602  p->Send_bool(true);
603  p->Send_uint16(i);
604  p->Send_string(cmdname);
605  }
606 
607  /* Marker to notify the end of the packet has been reached. */
608  p->Send_bool(false);
609  this->SendPacket(std::move(p));
610 
612 }
613 
620 {
621  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CMD_LOGGING);
622 
623  p->Send_uint32(client_id);
624  p->Send_uint8 (cp.company);
625  p->Send_uint16(cp.cmd);
626  p->Send_buffer(cp.data);
627  p->Send_uint32(cp.frame);
628 
629  this->SendPacket(std::move(p));
630 
632 }
633 
634 /***********
635  * Receiving functions
636  ************/
637 
639 {
640  if (this->status != ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
641 
643  /* You're not authorized to login using this method. */
644  return this->SendError(NETWORK_ERROR_NOT_AUTHORIZED);
645  }
646 
647  std::string password = p.Recv_string(NETWORK_PASSWORD_LENGTH);
648 
650  _settings_client.network.admin_password.compare(password) != 0) {
651  /* Password is invalid */
652  return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
653  }
654 
657 
658  if (this->admin_name.empty() || this->admin_version.empty()) {
659  /* no name or version supplied */
660  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
661  }
662 
663  Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
664 
665  return this->SendProtocol();
666 }
667 
669 {
670  /* The admin is leaving nothing else to do */
671  return this->CloseConnection();
672 }
673 
675 {
676  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
677 
680 
681  if (type >= ADMIN_UPDATE_END || (_admin_update_type_frequencies[type] & freq) != freq) {
682  /* The server does not know of this UpdateType. */
683  Debug(net, 1, "[admin] Not supported update frequency {} ({}) from '{}' ({})", type, freq, this->admin_name, this->admin_version);
684  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
685  }
686 
687  this->update_frequency[type] = freq;
688 
690 
692 }
693 
695 {
696  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
697 
699  uint32_t d1 = p.Recv_uint32();
700 
701  switch (type) {
702  case ADMIN_UPDATE_DATE:
703  /* The admin is requesting the current date. */
704  this->SendDate();
705  break;
706 
708  /* The admin is requesting client info. */
709  if (d1 == UINT32_MAX) {
711  for (const NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
712  this->SendClientInfo(cs, cs->GetInfo());
713  }
714  } else {
715  if (d1 == CLIENT_ID_SERVER) {
717  } else {
718  const NetworkClientSocket *cs = NetworkClientSocket::GetByClientID((ClientID)d1);
719  if (cs != nullptr) this->SendClientInfo(cs, cs->GetInfo());
720  }
721  }
722  break;
723 
725  /* The admin is asking for company info. */
726  if (d1 == UINT32_MAX) {
727  for (const Company *company : Company::Iterate()) {
728  this->SendCompanyInfo(company);
729  }
730  } else {
731  const Company *company = Company::GetIfValid(d1);
732  if (company != nullptr) this->SendCompanyInfo(company);
733  }
734  break;
735 
737  /* The admin is requesting economy info. */
738  this->SendCompanyEconomy();
739  break;
740 
742  /* the admin is requesting company stats. */
743  this->SendCompanyStats();
744  break;
745 
747  /* The admin is requesting the names of DoCommands. */
748  this->SendCmdNames();
749  break;
750 
751  default:
752  /* An unsupported "poll" update type. */
753  Debug(net, 1, "[admin] Not supported poll {} ({}) from '{}' ({}).", type, d1, this->admin_name, this->admin_version);
754  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
755  }
756 
758 }
759 
761 {
762  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
763 
764  NetworkAction action = (NetworkAction)p.Recv_uint8();
765  DestType desttype = (DestType)p.Recv_uint8();
766  int dest = p.Recv_uint32();
767 
768  std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
769 
770  switch (action) {
771  case NETWORK_ACTION_CHAT:
772  case NETWORK_ACTION_CHAT_CLIENT:
773  case NETWORK_ACTION_CHAT_COMPANY:
774  case NETWORK_ACTION_SERVER_MESSAGE:
775  NetworkServerSendChat(action, desttype, dest, msg, _network_own_client_id, 0, true);
776  break;
777 
778  default:
779  Debug(net, 1, "[admin] Invalid chat action {} from admin '{}' ({}).", action, this->admin_name, this->admin_version);
780  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
781  }
782 
784 }
785 
787 {
788  if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
789 
790  std::string source = p.Recv_string(NETWORK_CHAT_LENGTH);
791  TextColour colour = (TextColour)p.Recv_uint16();
792  std::string user = p.Recv_string(NETWORK_CHAT_LENGTH);
793  std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
794 
795  if (!IsValidConsoleColour(colour)) {
796  Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16_t)colour, source, user, msg, this->admin_name, this->admin_version);
797  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
798  }
799 
800  NetworkServerSendExternalChat(source, colour, user, msg);
801 
803 }
804 
805 /*
806  * Secure authentication send and receive methods.
807  */
808 
810 {
811  if (this->status != ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
812 
816 
817  /* Always exclude key exchange only, as that provides no credential checking. */
819 
820  if (this->admin_name.empty() || this->admin_version.empty()) {
821  /* No name or version supplied. */
822  return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
823  }
824 
826  if (!handler->CanBeUsed()) return this->SendError(NETWORK_ERROR_NO_AUTHENTICATION_METHOD_AVAILABLE);
827 
828  this->authentication_handler = std::move(handler);
829  Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
830 
831  return this->SendAuthRequest();
832 }
833 
834 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendAuthRequest()
835 {
837 
838  Debug(net, 6, "[admin] '{}' ({}) authenticating using {}", this->admin_name, this->admin_version, this->authentication_handler->GetName());
839 
840  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_AUTH_REQUEST);
841  this->authentication_handler->SendRequest(*p);
842 
843  this->SendPacket(std::move(p));
844 
846 }
847 
848 NetworkRecvStatus ServerNetworkAdminSocketHandler::SendEnableEncryption()
849 {
850  if (this->status != ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
851 
852  auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_ENABLE_ENCRYPTION);
853  this->authentication_handler->SendEnableEncryption(*p);
854  this->SendPacket(std::move(p));
855 
857 }
858 
860 {
861  if (this->status != ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
862 
863  switch (this->authentication_handler->ReceiveResponse(p)) {
865  Debug(net, 3, "[admin] '{}' ({}) authenticated", this->admin_name, this->admin_version);
866 
867  this->SendEnableEncryption();
868 
869  this->receive_encryption_handler = this->authentication_handler->CreateClientToServerEncryptionHandler();
870  this->send_encryption_handler = this->authentication_handler->CreateServerToClientEncryptionHandler();
871  this->authentication_handler = nullptr;
872  return this->SendProtocol();
873 
875  Debug(net, 6, "[admin] '{}' ({}) authentication failed, trying next method", this->admin_name, this->admin_version);
876  return this->SendAuthRequest();
877 
879  default:
880  Debug(net, 3, "[admin] '{}' ({}) authentication failed", this->admin_name, this->admin_version);
881  return this->SendError(NETWORK_ERROR_WRONG_PASSWORD);
882  }
883 }
884 
885 /*
886  * Useful wrapper functions
887  */
888 
894 void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client)
895 {
897  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
898  as->SendClientInfo(cs, cs->GetInfo());
899  if (new_client) {
900  as->SendClientJoin(cs->client_id);
901  }
902  }
903  }
904 }
905 
911 {
913  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
914  as->SendClientUpdate(ci);
915  }
916  }
917 }
918 
924 {
926  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
927  as->SendClientQuit(client_id);
928  }
929  }
930 }
931 
938 {
940  if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
941  as->SendClientError(client_id, error_code);
942  }
943  }
944 }
945 
950 void NetworkAdminCompanyNew(const Company *company)
951 {
952  if (company == nullptr) {
953  Debug(net, 1, "[admin] Empty company given for update");
954  return;
955  }
956 
958  if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue;
959 
960  as->SendCompanyNew(company->index);
961  as->SendCompanyInfo(company);
962  }
963 }
964 
969 void NetworkAdminCompanyUpdate(const Company *company)
970 {
971  if (company == nullptr) return;
972 
974  if (as->update_frequency[ADMIN_UPDATE_COMPANY_INFO] != ADMIN_FREQUENCY_AUTOMATIC) continue;
975 
976  as->SendCompanyUpdate(company);
977  }
978 }
979 
986 {
988  as->SendCompanyRemove(company_id, bcrr);
989  }
990 }
991 
992 
996 void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data, bool from_admin)
997 {
998  if (from_admin) return;
999 
1001  if (as->update_frequency[ADMIN_UPDATE_CHAT] & ADMIN_FREQUENCY_AUTOMATIC) {
1002  as->SendChat(action, desttype, client_id, msg, data);
1003  }
1004  }
1005 }
1006 
1013 void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string)
1014 {
1015  ServerNetworkAdminSocketHandler::Get(admin_index)->SendRcon(colour_code, string);
1016 }
1017 
1023 void NetworkAdminConsole(const std::string_view origin, const std::string_view string)
1024 {
1026  if (as->update_frequency[ADMIN_UPDATE_CONSOLE] & ADMIN_FREQUENCY_AUTOMATIC) {
1027  as->SendConsole(origin, string);
1028  }
1029  }
1030 }
1031 
1036 void NetworkAdminGameScript(const std::string_view json)
1037 {
1039  if (as->update_frequency[ADMIN_UPDATE_GAMESCRIPT] & ADMIN_FREQUENCY_AUTOMATIC) {
1040  as->SendGameScript(json);
1041  }
1042  }
1043 }
1044 
1050 void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket &cp)
1051 {
1052  ClientID client_id = owner == nullptr ? _network_own_client_id : owner->client_id;
1053 
1055  if (as->update_frequency[ADMIN_UPDATE_CMD_LOGGING] & ADMIN_FREQUENCY_AUTOMATIC) {
1056  as->SendCmdLogging(client_id, cp);
1057  }
1058  }
1059 }
1060 
1065 {
1067  as->SendWelcome();
1068  }
1069 }
1070 
1076 {
1078  for (int i = 0; i < ADMIN_UPDATE_END; i++) {
1079  if (as->update_frequency[i] & freq) {
1080  /* Update the admin for the required details */
1081  switch (i) {
1082  case ADMIN_UPDATE_DATE:
1083  as->SendDate();
1084  break;
1085 
1087  as->SendCompanyEconomy();
1088  break;
1089 
1091  as->SendCompanyStats();
1092  break;
1093 
1094  default: NOT_REACHED();
1095  }
1096  }
1097  }
1098  }
1099 }
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:146
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Definition: address.h:28
const std::string & GetHostname()
Get the hostname; in case it wasn't given the IPv4 dotted representation is given.
Definition: address.cpp:23
Main socket handler for admin related connections.
Definition: tcp_admin.h:117
NetworkRecvStatus CloseConnection(bool error=true) override
This will put this socket handler in a close state.
Definition: tcp_admin.cpp:35
AdminStatus status
Status of this admin.
Definition: tcp_admin.h:121
std::string admin_version
Version string of the admin.
Definition: tcp_admin.h:120
std::string admin_name
Name of the admin.
Definition: tcp_admin.h:119
Default implementation for the authorized key handler.
Default implementation of the password provider.
static std::unique_ptr< NetworkAuthenticationServerHandler > Create(const NetworkAuthenticationPasswordProvider *password_provider, const NetworkAuthenticationAuthorizedKeyHandler *authorized_key_handler, NetworkAuthenticationMethodMask client_supported_method_mask=~static_cast< NetworkAuthenticationMethodMask >(0))
Create a NetworkAuthenticationServerHandler.
@ RETRY_NEXT_METHOD
The client failed to authenticate, but there is another method to try.
@ AUTHENTICATED
The client was authenticated successfully.
@ NOT_AUTHENTICATED
All authentications for this handler have been exhausted.
std::unique_ptr< class NetworkEncryptionHandler > send_encryption_handler
The handler for encrypting sent packets.
Definition: core.h:50
std::unique_ptr< class NetworkEncryptionHandler > receive_encryption_handler
The handler for decrypting received packets.
Definition: core.h:49
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:68
Class for handling the server side of the game connection.
Definition: network_admin.h:25
static void Send()
Send the packets for the server sockets.
NetworkRecvStatus SendPong(uint32_t d1)
Send ping-reply (pong) to admin.
NetworkRecvStatus SendDate()
Tell the admin the date.
NetworkRecvStatus Receive_ADMIN_JOIN_SECURE(Packet &p) override
Join the admin network using a secure authentication method: string Name of the application being use...
NetworkRecvStatus SendClientUpdate(const NetworkClientInfo *ci)
Send an update for some client's information.
AdminUpdateFrequency update_frequency[ADMIN_UPDATE_END]
Admin requested update intervals.
Definition: network_admin.h:46
NetworkRecvStatus SendGameScript(const std::string_view json)
Send GameScript JSON output.
NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci)
Send an initial set of data from some client's information.
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...
NetworkRecvStatus SendNewGame()
Tell the admin we started a new game.
NetworkRecvStatus SendCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Tell the admin that a company got removed.
NetworkRecvStatus Receive_ADMIN_RCON(Packet &p) override
Execute a command on the servers console: string Command to be executed.
static Pool::IterateWrapperFiltered< ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter > IterateActive(size_t from=0)
Returns an iterable ensemble of all active admin sockets.
NetworkRecvStatus SendClientError(ClientID client_id, NetworkErrorCode error)
Tell the admin that a client made an error.
NetworkRecvStatus SendCmdNames()
Send the names of the commands.
NetworkRecvStatus Receive_ADMIN_POLL(Packet &p) override
Poll the server for certain updates, an invalid poll (e.g.
NetworkRecvStatus Receive_ADMIN_JOIN(Packet &p) override
Join the admin network using an unsecured password exchange: string Unsecured password the server is ...
NetworkRecvStatus SendRconEnd(const std::string_view command)
Send a notification indicating the rcon command has completed.
NetworkRecvStatus SendConsole(const std::string_view origin, const std::string_view command)
Send console output of other clients.
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data)
Send a chat message.
NetworkRecvStatus SendShutdown()
Tell the admin we're shutting down.
NetworkRecvStatus SendCompanyStats()
Send statistics about the companies.
NetworkRecvStatus SendWelcome()
Send a welcome message to the admin.
NetworkRecvStatus SendCompanyInfo(const Company *c)
Send the admin some information about a company.
static void WelcomeAll()
Send a Welcome packet to all connected admins.
static void AcceptConnection(SOCKET s, const NetworkAddress &address)
Handle the acception of a connection.
NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket &cp)
Send a command for logging purposes.
std::unique_ptr< NetworkAuthenticationServerHandler > authentication_handler
The handler for the authentication.
Definition: network_admin.h:27
static bool AllowConnection()
Whether a connection is allowed or not at this moment.
NetworkRecvStatus SendRcon(uint16_t colour, const std::string_view command)
Send the reply of an rcon command.
NetworkRecvStatus Receive_ADMIN_CHAT(Packet &p) override
Send chat as the server: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
NetworkRecvStatus SendCompanyEconomy()
Send economic information of all companies.
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...
NetworkRecvStatus SendCompanyUpdate(const Company *c)
Send an update about a company.
NetworkAddress address
Address of the admin.
Definition: network_admin.h:48
NetworkRecvStatus SendClientQuit(ClientID client_id)
Tell the admin that a client quit.
NetworkRecvStatus SendCompanyNew(CompanyID company_id)
Tell the admin that a new company was founded.
NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet &p) override
Send a JSON string to the current active GameScript.
NetworkRecvStatus SendProtocol()
Send the protocol version to the admin.
NetworkRecvStatus SendClientJoin(ClientID client_id)
Tell the admin that a client joined.
std::chrono::steady_clock::time_point connect_time
Time of connection.
Definition: network_admin.h:47
NetworkRecvStatus Receive_ADMIN_PING(Packet &p) override
Ping the server, requiring the server to reply with a pong packet.
NetworkRecvStatus Receive_ADMIN_EXTERNAL_CHAT(Packet &p) override
Send chat from the external source: string Name of the source this message came from.
NetworkRecvStatus Receive_ADMIN_QUIT(Packet &p) override
Notification to the server that this admin is quitting.
~ServerNetworkAdminSocketHandler()
Clear everything related to this admin.
ServerNetworkAdminSocketHandler(SOCKET s)
Sanity check.
NetworkRecvStatus SendError(NetworkErrorCode error)
Send an error to the admin.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static Date date
Current date in days (day counter).
const char * 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
List of commands.
Definition: command_type.h:187
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
Definition: command_type.h:366
Owner
Enum for all companies/owners.
Definition: company_type.h:18
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH
The maximum length of a receiving gamescript json string, in bytes including '\0'.
Definition: config.h:60
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client's name, in bytes including '\0'.
Definition: config.h:58
static const uint NETWORK_CHAT_LENGTH
The maximum length of a chat message, in bytes including '\0'.
Definition: config.h:61
static const size_t COMPAT_MTU
Number of bytes we can pack in a single packet for backward compatibility.
Definition: config.h:46
static const uint NETWORK_REVISION_LENGTH
The maximum length of the revision, in bytes including '\0'.
Definition: config.h:56
static const uint NETWORK_RCONCOMMAND_LENGTH
The maximum length of a rconsole command, in bytes including '\0'.
Definition: config.h:59
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0'.
Definition: config.h:57
static const uint8_t NETWORK_GAME_ADMIN_VERSION
What version of the admin network do we use?
Definition: config.h:48
void IConsoleCmdExec(const std::string &command_string, const uint recurse_count)
Execute a given command passed to us.
Definition: console.cpp:291
bool IsValidConsoleColour(TextColour c)
Check whether the given TextColour is valid for console usage.
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition: core.h:23
@ NETWORK_RECV_STATUS_OKAY
Everything is okay.
Definition: core.h:24
void DebugReconsiderSendRemoteMessages()
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
Definition: debug.cpp:264
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:260
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:320
StringID GetNetworkErrorMsg(NetworkErrorCode err)
Retrieve the string id of an internal error number.
Definition: network.cpp:313
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:68
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:70
void NetworkAdminClientUpdate(const NetworkClientInfo *ci)
Notify the admin network of a client update (if they did opt in for the respective update).
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data, bool from_admin)
Send chat to the admin network (if they did opt in for the respective update).
AdminIndex _redirect_console_to_admin
Redirection of the (remote) console to the admin.
void NetworkAdminClientQuit(ClientID client_id)
Notify the admin network that a client quit (if they have opt in for the respective update).
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
void NetworkAdminUpdate(AdminUpdateFrequency freq)
Send (push) updates to the admin network as they have registered for these updates.
void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client)
Notify the admin network of a new client (if they did opt in for the respective update).
void NetworkAdminGameScript(const std::string_view json)
Send GameScript JSON to the admin network (if they did opt in for the respective update).
void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket &cp)
Distribute CommandPacket details over the admin network for logging purposes.
static const AdminUpdateFrequency _admin_update_type_frequencies[]
Frequencies, which may be registered for a certain update type.
void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code)
Notify the admin network of a client error (if they have opt in for the respective update).
void NetworkAdminConsole(const std::string_view origin, const std::string_view string)
Send console to the admin network (if they did opt in for the respective update).
void NetworkAdminCompanyNew(const Company *company)
Notify the admin network of a new company.
uint8_t _network_admins_connected
The amount of admins connected.
static NetworkAuthenticationDefaultAuthorizedKeyHandler _admin_authorized_key_handler(_settings_client.network.admin_authorized_keys)
Provides the authorized key handling for the game authentication.
static NetworkAuthenticationDefaultPasswordProvider _admin_password_provider(_settings_client.network.admin_password)
Provides the password validation for the game's password.
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket")
The pool with sockets/clients.
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Notify the admin network of a company to be removed (including the reason why).
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string)
Pass the rcon reply to the admin.
static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10)
The timeout for authorisation of the client.
Server part of the admin network protocol.
Base core network types and some helper functions to access them.
@ NETWORK_AUTH_METHOD_X25519_KEY_EXCHANGE_ONLY
No actual authentication is taking place, just perform a x25519 key exchange. This method is not supp...
uint16_t NetworkAuthenticationMethodMask
The mask of authentication methods that can be used.
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64_t data=0, bool from_admin=false)
Send an actual chat message.
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
Populate the company stats.
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
Send a chat message from external source.
Server part of the network protocol.
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
Definition: network_type.h:64
DestType
Destination of our chat messages.
Definition: network_type.h:79
uint8_t AdminIndex
Indices into the admin tables.
Definition: network_type.h:59
NetworkAction
Actions that can be used for NetworkTextMessage.
Definition: network_type.h:90
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:49
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:51
NetworkErrorCode
The error codes we send around in the protocols.
Definition: network_type.h:110
static const AdminIndex MAX_ADMINS
Maximum number of allowed admins.
Definition: network_type.h:62
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition: pool_func.hpp:237
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:57
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:56
#define lengthof(array)
Return the length of an fixed size array.
Definition: stdafx.h:280
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:319
NetworkSettings network
settings related to the network
Everything we need to know about a command to be able to execute it.
CommandDataBuffer data
command parameters.
uint32_t frame
the frame in which this packet is executed
CompanyID company
company that is executing the command
Commands cmd
command being executed.
uint8_t months_of_bankruptcy
Number of months that the company is unable to pay its debts.
Definition: company_base.h:98
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Definition: company_base.h:112
TimerGameEconomy::Year inaugurated_year
Economy year of starting the company.
Definition: company_base.h:94
Colours colour
Company colour.
Definition: company_base.h:87
uint8_t landscape
the landscape we're currently in
TimerGameCalendar::Year starting_year
starting date
uint32_t generation_seed
noise seed for world generation
GameCreationSettings game_creation
settings used during the creation of a game (map)
static uint SizeY()
Get the size of the map along the Y.
Definition: map_func.h:279
static debug_inline uint SizeX()
Get the size of the map along the X.
Definition: map_func.h:270
Container for all information known about a client.
Definition: network_base.h:24
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:116
TimerGameEconomy::Date join_date
Gamedate the client has joined.
Definition: network_base.h:29
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:28
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:25
std::string client_name
Name of the client.
Definition: network_base.h:26
Simple calculated statistics of a company.
Definition: network_type.h:67
uint16_t num_vehicle[NETWORK_VEH_END]
How many vehicles are there of this type?
Definition: network_type.h:68
uint16_t num_station[NETWORK_VEH_END]
How many stations are there of this type?
Definition: network_type.h:69
bool allow_insecure_admin_login
Whether to allow logging in as admin using the insecure old JOIN packet.
std::string admin_password
password for the admin network
std::string server_name
name of the server
Internal entity of a packet.
Definition: packet.h:42
uint16_t Recv_uint16()
Read a 16 bits integer from the packet.
Definition: packet.cpp:332
uint32_t Recv_uint32()
Read a 32 bits integer from the packet.
Definition: packet.cpp:347
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
Definition: packet.cpp:318
std::string Recv_string(size_t length, StringValidationSettings settings=SVS_REPLACE_WITH_QUESTION_MARK)
Reads characters (bytes) from the packet until it finds a '\0', or reaches a maximum of length charac...
Definition: packet.cpp:425
Tindex index
Index of this pool item.
Definition: pool_type.hpp:238
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:339
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:309
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:350
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:388
Base class for all pools.
Definition: pool_type.hpp:80
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition: pool_type.hpp:84
@ ADMIN_PACKET_SERVER_CONSOLE
The server gives the admin the data that got printed to its console.
Definition: tcp_admin.h:59
@ 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:67
@ ADMIN_PACKET_SERVER_CLIENT_UPDATE
The server gives the admin an information update on a client.
Definition: tcp_admin.h:48
@ ADMIN_PACKET_SERVER_COMPANY_STATS
The server gives the admin some statistics about a company.
Definition: tcp_admin.h:56
@ ADMIN_PACKET_SERVER_COMPANY_ECONOMY
The server gives the admin some economy related company information.
Definition: tcp_admin.h:55
@ ADMIN_PACKET_SERVER_GAMESCRIPT
The server gives the admin information from the GameScript in JSON.
Definition: tcp_admin.h:62
@ ADMIN_PACKET_SERVER_CLIENT_INFO
The server gives the admin information about a client.
Definition: tcp_admin.h:47
@ ADMIN_PACKET_SERVER_CLIENT_ERROR
The server tells the admin that a client caused an error.
Definition: tcp_admin.h:50
@ ADMIN_PACKET_SERVER_AUTH_REQUEST
The server gives the admin the used authentication method and required parameters.
Definition: tcp_admin.h:66
@ ADMIN_PACKET_SERVER_CHAT
The server received a chat message and relays it.
Definition: tcp_admin.h:57
@ ADMIN_PACKET_SERVER_SHUTDOWN
The server tells the admin its shutting down.
Definition: tcp_admin.h:43
@ ADMIN_PACKET_SERVER_RCON_END
The server indicates that the remote console command has completed.
Definition: tcp_admin.h:63
@ ADMIN_PACKET_SERVER_WELCOME
The server welcomes the admin to a game.
Definition: tcp_admin.h:41
@ ADMIN_PACKET_SERVER_COMPANY_REMOVE
The server tells the admin that a company was removed.
Definition: tcp_admin.h:54
@ ADMIN_PACKET_SERVER_ERROR
The server tells the admin an error has occurred.
Definition: tcp_admin.h:39
@ ADMIN_PACKET_SERVER_NEWGAME
The server tells the admin its going to start a new game.
Definition: tcp_admin.h:42
@ ADMIN_PACKET_SERVER_COMPANY_UPDATE
The server gives the admin an information update on a company.
Definition: tcp_admin.h:53
@ ADMIN_PACKET_SERVER_PONG
The server replies to a ping request from the admin.
Definition: tcp_admin.h:64
@ ADMIN_PACKET_SERVER_CLIENT_JOIN
The server tells the admin that a client has joined.
Definition: tcp_admin.h:46
@ ADMIN_PACKET_SERVER_CMD_LOGGING
The server gives the admin copies of incoming command packets.
Definition: tcp_admin.h:65
@ ADMIN_PACKET_SERVER_PROTOCOL
The server tells the admin its protocol version.
Definition: tcp_admin.h:40
@ ADMIN_PACKET_SERVER_CLIENT_QUIT
The server tells the admin that a client quit.
Definition: tcp_admin.h:49
@ ADMIN_PACKET_SERVER_COMPANY_INFO
The server gives the admin information about a company.
Definition: tcp_admin.h:52
@ ADMIN_PACKET_SERVER_CMD_NAMES
The server sends out the names of the DoCommands to the admins.
Definition: tcp_admin.h:60
@ ADMIN_PACKET_SERVER_DATE
The server tells the admin what the current game date is.
Definition: tcp_admin.h:45
@ ADMIN_PACKET_SERVER_COMPANY_NEW
The server tells the admin that a new company has started.
Definition: tcp_admin.h:51
@ ADMIN_PACKET_SERVER_RCON
The server's reply to a remove console command.
Definition: tcp_admin.h:58
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
Definition: tcp_admin.h:108
AdminUpdateFrequency
Update frequencies an admin can register.
Definition: tcp_admin.h:96
@ ADMIN_FREQUENCY_MONTHLY
The admin gets information about this on a monthly basis.
Definition: tcp_admin.h:100
@ ADMIN_FREQUENCY_QUARTERLY
The admin gets information about this on a quarterly basis.
Definition: tcp_admin.h:101
@ ADMIN_FREQUENCY_AUTOMATIC
The admin gets information about this when it changes.
Definition: tcp_admin.h:103
@ ADMIN_FREQUENCY_ANUALLY
The admin gets information about this on a yearly basis.
Definition: tcp_admin.h:102
@ ADMIN_FREQUENCY_WEEKLY
The admin gets information about this on a weekly basis.
Definition: tcp_admin.h:99
@ ADMIN_FREQUENCY_DAILY
The admin gets information about this on a daily basis.
Definition: tcp_admin.h:98
@ ADMIN_FREQUENCY_POLL
The admin can poll this.
Definition: tcp_admin.h:97
AdminUpdateType
Update types an admin can register a frequency for.
Definition: tcp_admin.h:81
@ ADMIN_UPDATE_DATE
Updates about the date of the game.
Definition: tcp_admin.h:82
@ ADMIN_UPDATE_GAMESCRIPT
The admin would like to have gamescript messages.
Definition: tcp_admin.h:91
@ ADMIN_UPDATE_COMPANY_INFO
Updates about the generic information of companies.
Definition: tcp_admin.h:84
@ ADMIN_UPDATE_CONSOLE
The admin would like to have console messages.
Definition: tcp_admin.h:88
@ ADMIN_UPDATE_CHAT
The admin would like to have chat messages.
Definition: tcp_admin.h:87
@ ADMIN_UPDATE_COMPANY_STATS
Updates about the statistics of companies.
Definition: tcp_admin.h:86
@ ADMIN_UPDATE_COMPANY_ECONOMY
Updates about the economy of companies.
Definition: tcp_admin.h:85
@ ADMIN_UPDATE_END
Must ALWAYS be on the end of this list!! (period)
Definition: tcp_admin.h:92
@ ADMIN_UPDATE_CLIENT_INFO
Updates about the information of clients.
Definition: tcp_admin.h:83
@ ADMIN_UPDATE_CMD_NAMES
The admin would like a list of all DoCommand names.
Definition: tcp_admin.h:89
@ ADMIN_UPDATE_CMD_LOGGING
The admin would like to have DoCommand information.
Definition: tcp_admin.h:90
@ ADMIN_STATUS_INACTIVE
The admin is not connected nor active.
Definition: tcp_admin.h:74
@ ADMIN_STATUS_ACTIVE
The admin is active.
Definition: tcp_admin.h:76
@ ADMIN_STATUS_AUTHENTICATE
The admin is connected and working on authentication.
Definition: tcp_admin.h:75