diff --git a/src/network/core/config.h b/src/network/core/config.h index 99e6a3bd94..648ef2a35c 100644 --- a/src/network/core/config.h +++ b/src/network/core/config.h @@ -54,9 +54,8 @@ static const uint NETWORK_NAME_LENGTH = 80; ///< The m static const uint NETWORK_COMPANY_NAME_LENGTH = 128; ///< The maximum length of the company 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_SERVER_ID_LENGTH = 33; ///< The maximum length of the network id of the servers, in bytes including '\0' 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' (must be >= NETWORK_SERVER_ID_LENGTH) +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'. diff --git a/src/network/network.cpp b/src/network/network.cpp index 18fc255f57..6b34df1229 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -227,49 +227,6 @@ uint8_t NetworkSpectatorCount() return count; } -/** - * Hash the given password using server ID and game seed. - * @param password Password to hash. - * @param password_server_id Server ID. - * @param password_game_seed Game seed. - * @return The hashed password. - */ -std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed) -{ - if (password.empty()) return password; - - size_t password_length = password.size(); - size_t password_server_id_length = password_server_id.size(); - - std::ostringstream salted_password; - /* Add the password with the server's ID and game seed as the salt. */ - for (uint i = 0; i < NETWORK_SERVER_ID_LENGTH - 1; i++) { - char password_char = (i < password_length ? password[i] : 0); - char server_id_char = (i < password_server_id_length ? password_server_id[i] : 0); - char seed_char = password_game_seed >> (i % 32); - salted_password << (char)(password_char ^ server_id_char ^ seed_char); // Cast needed, otherwise interpreted as integer to format - } - - Md5 checksum; - MD5Hash digest; - - /* Generate the MD5 hash */ - std::string salted_password_string = salted_password.str(); - checksum.Append(salted_password_string.data(), salted_password_string.size()); - checksum.Finish(digest); - - return FormatArrayAsHex(digest); -} - -/** - * Check if the company we want to join requires a password. - * @param company_id id of the company we want to check the 'passworded' flag for. - * @return true if the company requires a password. - */ -bool NetworkCompanyIsPassworded([[maybe_unused]] CompanyID company_id) -{ - return false; -} /* This puts a text-message to the console, or in the future, the chat-box, * (to keep it all a bit more general) @@ -1324,11 +1281,6 @@ void NetworkGameLoop() NetworkSend(); } -static void NetworkGenerateServerId() -{ - _settings_client.network.network_id = GenerateUid("OpenTTD Server ID"); -} - /** This tries to launch the network for a given OS */ void NetworkStartUp() { @@ -1338,9 +1290,6 @@ void NetworkStartUp() _network_available = NetworkCoreInitialize(); _network_dedicated = false; - /* Generate an server id when there is none yet */ - if (_settings_client.network.network_id.empty()) NetworkGenerateServerId(); - _network_game_info = {}; NetworkInitialize(); diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 920ac56bd4..307f38814f 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -321,9 +321,6 @@ std::string _network_server_name; /** Information about the game to join to. */ NetworkJoinInfo _network_join; -/** Make sure the server ID length is the same as a md5 hash. */ -static_assert(NETWORK_SERVER_ID_LENGTH == MD5_HASH_BYTES * 2 + 1); - /*********** * Sending functions ************/ diff --git a/src/network/network_func.h b/src/network/network_func.h index 4e88f7c998..d1dcd05d6c 100644 --- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -54,7 +54,6 @@ void NetworkClientRequestMove(CompanyID company); void NetworkClientSendRcon(const std::string &password, const std::string &command); void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data = 0); bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio); -bool NetworkCompanyIsPassworded(CompanyID company_id); uint NetworkMaxCompaniesAllowed(); bool NetworkMaxCompaniesReached(); void NetworkPrintClients(); diff --git a/src/network/network_internal.h b/src/network/network_internal.h index 1c2fe23ef2..aa394f6e44 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -114,7 +114,6 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, uint NetworkCalculateLag(const NetworkClientSocket *cs); StringID GetNetworkErrorMsg(NetworkErrorCode err); bool NetworkMakeClientNameUnique(std::string &new_name); -std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed); std::string_view ParseCompanyFromConnectionString(const std::string &connection_string, CompanyID *company_id); NetworkAddress ParseConnectionString(const std::string &connection_string, uint16_t default_port); diff --git a/src/settings_type.h b/src/settings_type.h index cfc6ad7c33..8064466404 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -320,9 +320,7 @@ struct NetworkSettings { std::string client_name; ///< name of the player (as client) std::string client_secret_key; ///< The secret key of the client for authorized key logins. std::string client_public_key; ///< The public key of the client for authorized key logins. - std::string default_company_pass; ///< default password for new companies in encrypted form std::string connect_to_ip; ///< default for the "Add server" query - std::string network_id; ///< network ID for servers bool autoclean_companies; ///< automatically remove companies that are not in use uint8_t autoclean_protected; ///< Remove companies after this many months. uint8_t autoclean_novehicles; ///< remove companies with no vehicles after this many months diff --git a/src/table/settings/network_secrets_settings.ini b/src/table/settings/network_secrets_settings.ini index 3d7908e75a..ed9ae27130 100644 --- a/src/table/settings/network_secrets_settings.ini +++ b/src/table/settings/network_secrets_settings.ini @@ -79,20 +79,6 @@ def = nullptr ; Prevent the user from setting the public key from the console using 'setting' pre_cb = [](auto) { return false; } -[SDTC_SSTR] -var = network.default_company_pass -type = SLE_STR -length = NETWORK_PASSWORD_LENGTH -flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC -def = nullptr - -[SDTC_SSTR] -var = network.network_id -type = SLE_STR -length = NETWORK_SERVER_ID_LENGTH -flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_NETWORK_ONLY -def = nullptr - [SDTC_SSTR] var = network.server_invite_code type = SLE_STR