OpenTTD Source: src/network/core/config.h File Reference

OpenTTD Source 15.0-RC2

Functions | Variables
config.h File Reference

Configuration options of the network stuff. More...

Go to the source code of this file.

## Functions
std::string_view | NetworkCoordinatorConnectionString ()
| Get the connection string for the game coordinator from the environment variable OTTD_COORDINATOR_CS, or when it has not been set a hard coded default DNS hostname of the production server.
std::string_view | NetworkStunConnectionString ()
| Get the connection string for the STUN server from the environment variable OTTD_STUN_CS, or when it has not been set a hard coded default DNS hostname of the production server.
std::string_view | NetworkContentServerConnectionString ()
| Get the connection string for the content server from the environment variable OTTD_CONTENT_SERVER_CS, or when it has not been set a hard coded default DNS hostname of the production server.
std::string_view | NetworkContentMirrorUriString ()
| Get the URI string for the content mirror from the environment variable OTTD_CONTENT_MIRROR_URI, or when it has not been set a hard coded URI of the production server.
std::string_view | NetworkSurveyUriString ()
| Get the URI string for the survey from the environment variable OTTD_SURVEY_URI, or when it has not been set a hard coded URI of the production server.

## Variables
static const uint16_t | NETWORK_COORDINATOR_SERVER_PORT = 3976
| The default port of the Game Coordinator server (TCP)
static const uint16_t | NETWORK_STUN_SERVER_PORT = 3975
| The default port of the STUN server (TCP)
static const uint16_t | NETWORK_TURN_SERVER_PORT = 3974
| The default port of the TURN server (TCP)
static const uint16_t | NETWORK_CONTENT_SERVER_PORT = 3978
| The default port of the content server (TCP)
static const uint16_t | NETWORK_DEFAULT_PORT = 3979
| The default port of the game server (TCP & UDP)
static const uint16_t | NETWORK_ADMIN_PORT = 3977
| The default port for admin network.
static const size_t | UDP_MTU = 1460
| Number of bytes we can pack in a single UDP packet.
static const std::string | NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.org/participate"
| Link with more details & privacy statement of the survey.
static const size_t | TCP_MTU = 32767
| Number of bytes we can pack in a single TCP packet.
static const size_t | COMPAT_MTU = 1460
| Number of bytes we can pack in a single packet for backward compatibility.
static const uint8_t | NETWORK_GAME_ADMIN_VERSION = 3
| What version of the admin network do we use?
static const uint8_t | NETWORK_GAME_INFO_VERSION = 7
| What version of game-info do we use?
static const uint8_t | NETWORK_COORDINATOR_VERSION = 6
| What version of game-coordinator-protocol do we use?
static const uint8_t | NETWORK_SURVEY_VERSION = 2
| What version of the survey do we use?
static const uint | NETWORK_NAME_LENGTH = 80
| The maximum length of the server name and map name, in bytes including '\0'.
static const uint | NETWORK_HOSTNAME_LENGTH = 80
| The maximum length of the host name, in bytes including '\0'.
static const uint | NETWORK_HOSTNAME_PORT_LENGTH = 80 + 6
| The maximum length of the host name + port, in bytes including '\0'. The extra six is ":" + port number (with a max of 65536)
static const uint | NETWORK_REVISION_LENGTH = 33
| The maximum length of the revision, in bytes including '\0'.
static const uint | NETWORK_PASSWORD_LENGTH = 33
| The maximum length of the password, in bytes including '\0'.
static const uint | NETWORK_CLIENT_NAME_LENGTH = 25
| The maximum length of a client's name, in bytes including '\0'.
static const uint | NETWORK_RCONCOMMAND_LENGTH = 500
| The maximum length of a rconsole command, in bytes including '\0'.
static const uint | NETWORK_GAMESCRIPT_JSON_LENGTH = 9000
| The maximum length of a receiving gamescript json string, in bytes including '\0'.
static const uint | NETWORK_CHAT_LENGTH = 900
| The maximum length of a chat message, in bytes including '\0'.
static const uint | NETWORK_CONTENT_FILENAME_LENGTH = 48
| The maximum length of a content's filename, in bytes including '\0'.
static const uint | NETWORK_CONTENT_NAME_LENGTH = 32
| The maximum length of a content's name, in bytes including '\0'.
static const uint | NETWORK_CONTENT_VERSION_LENGTH = 16
| The maximum length of a content's version, in bytes including '\0'.
static const uint | NETWORK_CONTENT_URL_LENGTH = 96
| The maximum length of a content's url, in bytes including '\0'.
static const uint | NETWORK_CONTENT_DESC_LENGTH = 512
| The maximum length of a content's description, in bytes including '\0'.
static const uint | NETWORK_CONTENT_TAG_LENGTH = 32
| The maximum length of a content's tag, in bytes including '\0'.
static const uint | NETWORK_ERROR_DETAIL_LENGTH = 100
| The maximum length of the error detail, in bytes including '\0'.
static const uint | NETWORK_INVITE_CODE_LENGTH = 64
| The maximum length of the invite code, in bytes including '\0'.
static const uint | NETWORK_INVITE_CODE_SECRET_LENGTH = 80
| The maximum length of the invite code secret, in bytes including '\0'.
static const uint | NETWORK_TOKEN_LENGTH = 64
| The maximum length of a token, in bytes including '\0'.
static const uint | NETWORK_GRF_NAME_LENGTH = 80
| Maximum length of the name of a GRF.
static const uint | NETWORK_MAX_GRF_COUNT = 255
| Maximum number of GRFs that can be sent.
static const uint | NETWORK_SECRET_KEY_LENGTH = 32 * 2 + 1
| The maximum length of the hexadecimal encoded secret keys, in bytes including '\0'.
static const uint | NETWORK_PUBLIC_KEY_LENGTH = 32 * 2 + 1
| The maximum length of the hexadecimal encoded public keys, in bytes including '\0'.

## Detailed Description

Configuration options of the network stuff.

It is used even when compiling without network support.

Definition in file config.h.

## Function Documentation

## ◆ NetworkContentMirrorUriString()

std::string_view NetworkContentMirrorUriString | ( |  | ) |

Get the URI string for the content mirror from the environment variable OTTD_CONTENT_MIRROR_URI, or when it has not been set a hard coded URI of the production server.

Returns
  The content mirror's URI string.

Definition at line 53 of file config.cpp.

References GetEnv().

Referenced by ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP().

## ◆ NetworkContentServerConnectionString()

std::string_view NetworkContentServerConnectionString | ( |  | ) |

Get the connection string for the content server from the environment variable OTTD_CONTENT_SERVER_CS, or when it has not been set a hard coded default DNS hostname of the production server.

Returns
  The content server's connection string.

Definition at line 43 of file config.cpp.

References GetEnv().

Referenced by ClientNetworkContentSocketHandler::Connect().

## ◆ NetworkCoordinatorConnectionString()

std::string_view NetworkCoordinatorConnectionString | ( |  | ) |

Get the connection string for the game coordinator from the environment variable OTTD_COORDINATOR_CS, or when it has not been set a hard coded default DNS hostname of the production server.

Returns
  The game coordinator's connection string.

Definition at line 23 of file config.cpp.

References GetEnv().

## ◆ NetworkStunConnectionString()

std::string_view NetworkStunConnectionString | ( |  | ) |

Get the connection string for the STUN server from the environment variable OTTD_STUN_CS, or when it has not been set a hard coded default DNS hostname of the production server.

Returns
  The STUN server's connection string.

Definition at line 33 of file config.cpp.

References GetEnv().

Referenced by ClientNetworkStunSocketHandler::Connect().

## ◆ NetworkSurveyUriString()

std::string_view NetworkSurveyUriString | ( |  | ) |

Get the URI string for the survey from the environment variable OTTD_SURVEY_URI, or when it has not been set a hard coded URI of the production server.

Returns
  The survey's URI string.

Definition at line 63 of file config.cpp.

References GetEnv().

Referenced by NetworkSurveyHandler::Transmit().

## Variable Documentation

## ◆ COMPAT_MTU

const size_t COMPAT_MTU = 1460
| static

Number of bytes we can pack in a single packet for backward compatibility.

Definition at line 46 of file config.h.

Referenced by ServerNetworkAdminSocketHandler::SendConsole().

## ◆ NETWORK_ADMIN_PORT

const uint16_t NETWORK_ADMIN_PORT = 3977
| static

The default port for admin network.

Definition at line 26 of file config.h.

## ◆ NETWORK_CHAT_LENGTH

const uint NETWORK_CHAT_LENGTH = 900
| static

The maximum length of a chat message, in bytes including '\0'.

Definition at line 61 of file config.h.

Referenced by ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(), ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(), ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(), ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(), ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(), and ClientNetworkGameSocketHandler::Receive_SERVER_EXTERNAL_CHAT().

## ◆ NETWORK_CLIENT_NAME_LENGTH

const uint NETWORK_CLIENT_NAME_LENGTH = 25
| static

The maximum length of a client's name, in bytes including '\0'.

Definition at line 58 of file config.h.

Referenced by NetworkMakeClientNameUnique(), NetworkClientListWindow::OnClick(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE(), ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(), and ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME().

## ◆ NETWORK_CONTENT_DESC_LENGTH

const uint NETWORK_CONTENT_DESC_LENGTH = 512
| static

The maximum length of a content's description, in bytes including '\0'.

Definition at line 66 of file config.h.

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().

## ◆ NETWORK_CONTENT_FILENAME_LENGTH

const uint NETWORK_CONTENT_FILENAME_LENGTH = 48
| static

The maximum length of a content's filename, in bytes including '\0'.

Definition at line 62 of file config.h.

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT().

## ◆ NETWORK_CONTENT_NAME_LENGTH

const uint NETWORK_CONTENT_NAME_LENGTH = 32
| static

The maximum length of a content's name, in bytes including '\0'.

Definition at line 63 of file config.h.

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().

## ◆ NETWORK_CONTENT_SERVER_PORT

const uint16_t NETWORK_CONTENT_SERVER_PORT = 3978
| static

The default port of the content server (TCP)

Definition at line 24 of file config.h.

## ◆ NETWORK_CONTENT_TAG_LENGTH

const uint NETWORK_CONTENT_TAG_LENGTH = 32
| static

The maximum length of a content's tag, in bytes including '\0'.

Definition at line 67 of file config.h.

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().

## ◆ NETWORK_CONTENT_URL_LENGTH

const uint NETWORK_CONTENT_URL_LENGTH = 96
| static

The maximum length of a content's url, in bytes including '\0'.

Definition at line 65 of file config.h.

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().

## ◆ NETWORK_CONTENT_VERSION_LENGTH

const uint NETWORK_CONTENT_VERSION_LENGTH = 16
| static

The maximum length of a content's version, in bytes including '\0'.

Definition at line 64 of file config.h.

Referenced by ClientNetworkContentSocketHandler::Receive_SERVER_INFO().

## ◆ NETWORK_COORDINATOR_SERVER_PORT

const uint16_t NETWORK_COORDINATOR_SERVER_PORT = 3976
| static

The default port of the Game Coordinator server (TCP)

Definition at line 21 of file config.h.

## ◆ NETWORK_COORDINATOR_VERSION

const uint8_t NETWORK_COORDINATOR_VERSION = 6
| static

What version of game-coordinator-protocol do we use?

Definition at line 50 of file config.h.

Referenced by ClientNetworkCoordinatorSocketHandler::ConnectFailure(), ClientNetworkCoordinatorSocketHandler::ConnectSuccess(), ClientNetworkCoordinatorSocketHandler::ConnectToServer(), ClientNetworkCoordinatorSocketHandler::GetListing(), ClientNetworkCoordinatorSocketHandler::Register(), ClientNetworkCoordinatorSocketHandler::SendServerUpdate(), ClientNetworkStunSocketHandler::Stun(), ClientNetworkCoordinatorSocketHandler::StunResult(), and ClientNetworkTurnSocketHandler::Turn().

## ◆ NETWORK_DEFAULT_PORT

const uint16_t NETWORK_DEFAULT_PORT = 3979
| static

The default port of the game server (TCP & UDP)

Definition at line 25 of file config.h.

Referenced by NetworkClientConnectGame(), NetworkFindBroadcastIPs(), NetworkGameListAddItem(), and ClientNetworkTurnSocketHandler::Receive_TURN_CONNECTED().

## ◆ NETWORK_ERROR_DETAIL_LENGTH

const uint NETWORK_ERROR_DETAIL_LENGTH = 100
| static

The maximum length of the error detail, in bytes including '\0'.

Definition at line 68 of file config.h.

Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_ERROR().

## ◆ NETWORK_GAME_ADMIN_VERSION

const uint8_t NETWORK_GAME_ADMIN_VERSION = 3
| static

What version of the admin network do we use?

Definition at line 48 of file config.h.

Referenced by ServerNetworkAdminSocketHandler::SendProtocol().

## ◆ NETWORK_GAME_INFO_VERSION

const uint8_t NETWORK_GAME_INFO_VERSION = 7
| static

What version of game-info do we use?

Definition at line 49 of file config.h.

Referenced by ClientNetworkCoordinatorSocketHandler::GetListing().

## ◆ NETWORK_GAMESCRIPT_JSON_LENGTH

const uint NETWORK_GAMESCRIPT_JSON_LENGTH = 9000
| static

The maximum length of a receiving gamescript json string, in bytes including '\0'.

Definition at line 60 of file config.h.

Referenced by ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT().

## ◆ NETWORK_GRF_NAME_LENGTH

const uint NETWORK_GRF_NAME_LENGTH = 80
| static

Maximum length of the name of a GRF.

Definition at line 73 of file config.h.

## ◆ NETWORK_HOSTNAME_LENGTH

const uint NETWORK_HOSTNAME_LENGTH = 80
| static

The maximum length of the host name, in bytes including '\0'.

Definition at line 54 of file config.h.

Referenced by NetworkAddress::GetHostname(), ClientNetworkCoordinatorSocketHandler::Receive_GC_DIRECT_CONNECT(), and ClientNetworkTurnSocketHandler::Receive_TURN_CONNECTED().

## ◆ NETWORK_HOSTNAME_PORT_LENGTH

const uint NETWORK_HOSTNAME_PORT_LENGTH = 80 + 6
| static

The maximum length of the host name + port, in bytes including '\0'. The extra six is ":" + port number (with a max of 65536)

Definition at line 55 of file config.h.

Referenced by NetworkGameWindow::OnClick(), ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(), ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_CONNECT(), and ClientNetworkCoordinatorSocketHandler::Receive_GC_TURN_CONNECT().

## ◆ NETWORK_INVITE_CODE_LENGTH

const uint NETWORK_INVITE_CODE_LENGTH = 64
| static

The maximum length of the invite code, in bytes including '\0'.

Definition at line 69 of file config.h.

Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_CONNECTING(), and ClientNetworkCoordinatorSocketHandler::Receive_GC_REGISTER_ACK().

## ◆ NETWORK_INVITE_CODE_SECRET_LENGTH

const uint NETWORK_INVITE_CODE_SECRET_LENGTH = 80
| static

The maximum length of the invite code secret, in bytes including '\0'.

Definition at line 70 of file config.h.

Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_REGISTER_ACK().

## ◆ NETWORK_MAX_GRF_COUNT

const uint NETWORK_MAX_GRF_COUNT = 255
| static

Maximum number of GRFs that can be sent.

This limit exists to avoid that the SERVER_INFO packet exceeding the maximum MTU. At the time of writing this limit is 32767 (TCP_MTU).

In the SERVER_INFO packet is the NetworkGameInfo struct, which is 142 bytes + 100 per NewGRF (under the assumption strings are used to their max). This brings us to roughly 326 possible NewGRFs. Round it down so people don't freak out because they see a weird value, and you get the limit: 255.

PS: in case you ever want to raise this number, please be mindful that "amount of NewGRFs" in NetworkGameInfo is currently an uint8.

Definition at line 90 of file config.h.

Referenced by NewGRFWindow::AddGRFToActive(), GRFLoadConfig(), and LoadNewGRF().

## ◆ NETWORK_NAME_LENGTH

const uint NETWORK_NAME_LENGTH = 80
| static

The maximum length of the server name and map name, in bytes including '\0'.

Definition at line 53 of file config.h.

Referenced by NetworkClientListWindow::OnClick(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), and ClientNetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE().

## ◆ NETWORK_PASSWORD_LENGTH

const uint NETWORK_PASSWORD_LENGTH = 33
| static

The maximum length of the password, in bytes including '\0'.

Definition at line 57 of file config.h.

Referenced by NetworkStartServerWindow::OnClick(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(), and ServerNetworkGameSocketHandler::Receive_CLIENT_RCON().

## ◆ NETWORK_PUBLIC_KEY_LENGTH

const uint NETWORK_PUBLIC_KEY_LENGTH = 32 * 2 + 1
| static

The maximum length of the hexadecimal encoded public keys, in bytes including '\0'.

This is related to `X25519_KEY_SIZE` in the network crypto internals.

Definition at line 101 of file config.h.

Referenced by CmdCompanyAllowListCtrl(), and ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO().

## ◆ NETWORK_RCONCOMMAND_LENGTH

const uint NETWORK_RCONCOMMAND_LENGTH = 500
| static

The maximum length of a rconsole command, in bytes including '\0'.

Definition at line 59 of file config.h.

Referenced by ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(), ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(), and ClientNetworkGameSocketHandler::Receive_SERVER_RCON().

## ◆ NETWORK_REVISION_LENGTH

const uint NETWORK_REVISION_LENGTH = 33
| static

The maximum length of the revision, in bytes including '\0'.

Definition at line 56 of file config.h.

Referenced by ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE(), and ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN().

## ◆ NETWORK_SECRET_KEY_LENGTH

const uint NETWORK_SECRET_KEY_LENGTH = 32 * 2 + 1
| static

The maximum length of the hexadecimal encoded secret keys, in bytes including '\0'.

This is related to `X25519_KEY_SIZE` in the network crypto internals.

Definition at line 96 of file config.h.

## ◆ NETWORK_STUN_SERVER_PORT

const uint16_t NETWORK_STUN_SERVER_PORT = 3975
| static

The default port of the STUN server (TCP)

Definition at line 22 of file config.h.

## ◆ NETWORK_SURVEY_DETAILS_LINK

const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.org/participate"
| static

Link with more details & privacy statement of the survey.

Definition at line 30 of file config.h.

Referenced by NetworkAskSurveyWindow::OnClick(), and GameOptionsWindow::OnClick().

## ◆ NETWORK_SURVEY_VERSION

const uint8_t NETWORK_SURVEY_VERSION = 2
| static

What version of the survey do we use?

Definition at line 51 of file config.h.

## ◆ NETWORK_TOKEN_LENGTH

const uint NETWORK_TOKEN_LENGTH = 64
| static

The maximum length of a token, in bytes including '\0'.

Definition at line 71 of file config.h.

Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_CONNECT_FAILED(), ClientNetworkCoordinatorSocketHandler::Receive_GC_CONNECTING(), ClientNetworkCoordinatorSocketHandler::Receive_GC_DIRECT_CONNECT(), ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_CONNECT(), ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_REQUEST(), and ClientNetworkCoordinatorSocketHandler::Receive_GC_TURN_CONNECT().

## ◆ NETWORK_TURN_SERVER_PORT

const uint16_t NETWORK_TURN_SERVER_PORT = 3974
| static

The default port of the TURN server (TCP)

Definition at line 23 of file config.h.

## ◆ TCP_MTU

const size_t TCP_MTU = 32767
| static

Number of bytes we can pack in a single TCP packet.

Definition at line 45 of file config.h.

Referenced by ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(), NetworkTCPSocketHandler::ReceivePacket(), ClientNetworkContentSocketHandler::RequestContentList(), ClientNetworkContentSocketHandler::RequestContentList(), ServerNetworkGameSocketHandler::SendGameInfo(), ServerNetworkGameSocketHandler::SendNewGRFCheck(), ClientNetworkCoordinatorSocketHandler::SendServerUpdate(), and PacketWriter::Write().

## ◆ UDP_MTU

const size_t UDP_MTU = 1460
| static

Number of bytes we can pack in a single UDP packet.

Definition at line 28 of file config.h.

Referenced by NetworkUDPSocketHandler::ReceivePackets().