diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2017-09-12 19:48:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 19:48:09 +0200 |
commit | ee9a442ecc26f2623a1b085344d37636342973eb (patch) | |
tree | 69ee10a648f777b1086ad9c9ea12a85af6162af6 /src/client.cpp | |
parent | 7f2a19da11f2106ecab7a074e7a7465912454e40 (diff) | |
download | minetest-ee9a442ecc26f2623a1b085344d37636342973eb.tar.gz minetest-ee9a442ecc26f2623a1b085344d37636342973eb.tar.bz2 minetest-ee9a442ecc26f2623a1b085344d37636342973eb.zip |
Network: Remove large parts of deprecated legacy code (#6404)
Also remove the setting 'send_pre_v25_init'
Keep old enum entries for obsolete commands
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 106 |
1 files changed, 11 insertions, 95 deletions
diff --git a/src/client.cpp b/src/client.cpp index 09ac5196d..dba7ffcc0 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -309,31 +309,7 @@ void Client::step(float dtime) LocalPlayer *myplayer = m_env.getLocalPlayer(); FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment."); - u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ? - CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN; - - if (proto_version_min < 25) { - // Send TOSERVER_INIT_LEGACY - // [0] u16 TOSERVER_INIT_LEGACY - // [2] u8 SER_FMT_VER_HIGHEST_READ - // [3] u8[20] player_name - // [23] u8[28] password (new in some version) - // [51] u16 minimum supported network protocol version (added sometime) - // [53] u16 maximum supported network protocol version (added later than the previous one) - - char pName[PLAYERNAME_SIZE]; - char pPassword[PASSWORD_SIZE]; - memset(pName, 0, PLAYERNAME_SIZE * sizeof(char)); - memset(pPassword, 0, PASSWORD_SIZE * sizeof(char)); - - std::string hashed_password = translate_password(myplayer->getName(), m_password); - snprintf(pName, PLAYERNAME_SIZE, "%s", myplayer->getName()); - snprintf(pPassword, PASSWORD_SIZE, "%s", hashed_password.c_str()); - - sendLegacyInit(pName, pPassword); - } - if (CLIENT_PROTOCOL_VERSION_MAX >= 25) - sendInit(myplayer->getName()); + sendInit(myplayer->getName()); } // Not connected, return @@ -428,11 +404,6 @@ void Client::step(float dtime) m_client_event_queue.push(event); } } - // Protocol v29 or greater obsoleted this event - else if (envEvent.type == CEE_PLAYER_BREATH && m_proto_ver < 29) { - u16 breath = envEvent.player_breath.amount; - sendBreath(breath); - } } /* @@ -949,10 +920,10 @@ void Client::deleteAuthData() case AUTH_MECHANISM_FIRST_SRP: break; case AUTH_MECHANISM_SRP: - case AUTH_MECHANISM_LEGACY_PASSWORD: srp_user_delete((SRPUser *) m_auth_data); m_auth_data = NULL; break; + case AUTH_MECHANISM_LEGACY_PASSWORD: case AUTH_MECHANISM_NONE: break; } @@ -968,28 +939,9 @@ AuthMechanism Client::choseAuthMech(const u32 mechs) if (mechs & AUTH_MECHANISM_FIRST_SRP) return AUTH_MECHANISM_FIRST_SRP; - if (mechs & AUTH_MECHANISM_LEGACY_PASSWORD) - return AUTH_MECHANISM_LEGACY_PASSWORD; - return AUTH_MECHANISM_NONE; } -void Client::sendLegacyInit(const char* playerName, const char* playerPassword) -{ - NetworkPacket pkt(TOSERVER_INIT_LEGACY, - 1 + PLAYERNAME_SIZE + PASSWORD_SIZE + 2 + 2); - - u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ? - CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN; - - pkt << (u8) SER_FMT_VER_HIGHEST_READ; - pkt.putRawString(playerName,PLAYERNAME_SIZE); - pkt.putRawString(playerPassword, PASSWORD_SIZE); - pkt << (u16) proto_version_min << (u16) CLIENT_PROTOCOL_VERSION_MAX; - - Send(&pkt); -} - void Client::sendInit(const std::string &playerName) { NetworkPacket pkt(TOSERVER_INIT, 1 + 2 + 2 + (1 + playerName.size())); @@ -997,11 +949,8 @@ void Client::sendInit(const std::string &playerName) // we don't support network compression yet u16 supp_comp_modes = NETPROTO_COMPRESSION_NONE; - u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ? - CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN; - pkt << (u8) SER_FMT_VER_HIGHEST_READ << (u16) supp_comp_modes; - pkt << (u16) proto_version_min << (u16) CLIENT_PROTOCOL_VERSION_MAX; + pkt << (u16) CLIENT_PROTOCOL_VERSION_MIN << (u16) CLIENT_PROTOCOL_VERSION_MAX; pkt << playerName; Send(&pkt); @@ -1025,14 +974,8 @@ void Client::startAuth(AuthMechanism chosen_auth_mechanism) Send(&resp_pkt); break; } - case AUTH_MECHANISM_SRP: - case AUTH_MECHANISM_LEGACY_PASSWORD: { - u8 based_on = 1; - - if (chosen_auth_mechanism == AUTH_MECHANISM_LEGACY_PASSWORD) { - m_password = translate_password(getPlayerName(), m_password); - based_on = 0; - } + case AUTH_MECHANISM_SRP: { + u8 legacy_based_on = 1; std::string playername_u = lowercase(getPlayerName()); m_auth_data = srp_user_new(SRP_SHA256, SRP_NG_2048, @@ -1047,10 +990,11 @@ void Client::startAuth(AuthMechanism chosen_auth_mechanism) FATAL_ERROR_IF(res != SRP_OK, "Creating local SRP user failed."); NetworkPacket resp_pkt(TOSERVER_SRP_BYTES_A, 0); - resp_pkt << std::string(bytes_A, len_A) << based_on; + resp_pkt << std::string(bytes_A, len_A) << legacy_based_on; Send(&resp_pkt); break; } + case AUTH_MECHANISM_LEGACY_PASSWORD: case AUTH_MECHANISM_NONE: break; // not handled in this method } @@ -1201,27 +1145,10 @@ void Client::sendChangePassword(const std::string &oldpassword, if (player == NULL) return; - std::string playername = player->getName(); - if (m_proto_ver >= 25) { - // get into sudo mode and then send new password to server - m_password = oldpassword; - m_new_password = newpassword; - startAuth(choseAuthMech(m_sudo_auth_methods)); - } else { - std::string oldpwd = translate_password(playername, oldpassword); - std::string newpwd = translate_password(playername, newpassword); - - NetworkPacket pkt(TOSERVER_PASSWORD_LEGACY, 2 * PASSWORD_SIZE); - - for (u8 i = 0; i < PASSWORD_SIZE; i++) { - pkt << (u8) (i < oldpwd.length() ? oldpwd[i] : 0); - } - - for (u8 i = 0; i < PASSWORD_SIZE; i++) { - pkt << (u8) (i < newpwd.length() ? newpwd[i] : 0); - } - Send(&pkt); - } + // get into sudo mode and then send new password to server + m_password = oldpassword; + m_new_password = newpassword; + startAuth(choseAuthMech(m_sudo_auth_methods)); } @@ -1232,17 +1159,6 @@ void Client::sendDamage(u8 damage) Send(&pkt); } -void Client::sendBreath(u16 breath) -{ - // Protocol v29 make this obsolete - if (m_proto_ver >= 29) - return; - - NetworkPacket pkt(TOSERVER_BREATH, sizeof(u16)); - pkt << breath; - Send(&pkt); -} - void Client::sendRespawn() { NetworkPacket pkt(TOSERVER_RESPAWN, 0); |