Player *myplayer = m_env.getLocalPlayer();
FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment.");
- // 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 = translatePassword(myplayer->getName(), m_password);
- snprintf(pName, PLAYERNAME_SIZE, "%s", myplayer->getName());
- snprintf(pPassword, PASSWORD_SIZE, "%s", hashed_password.c_str());
-
- sendLegacyInit(pName, pPassword);
- if (LATEST_PROTOCOL_VERSION >= 25)
+ 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());
}
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) CLIENT_PROTOCOL_VERSION_MIN << (u16) CLIENT_PROTOCOL_VERSION_MAX;
+ pkt << (u16) proto_version_min << (u16) CLIENT_PROTOCOL_VERSION_MAX;
Send(&pkt);
}
// 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) CLIENT_PROTOCOL_VERSION_MIN << (u16) CLIENT_PROTOCOL_VERSION_MAX;
+ pkt << (u16) proto_version_min << (u16) CLIENT_PROTOCOL_VERSION_MAX;
pkt << playerName;
Send(&pkt);
switch (chosen_auth_mechanism) {
case AUTH_MECHANISM_FIRST_SRP: {
// send srp verifier to server
+ std::string verifier;
+ std::string salt;
+ generate_srp_verifier_and_salt(getPlayerName(), m_password,
+ &verifier, &salt);
+
NetworkPacket resp_pkt(TOSERVER_FIRST_SRP, 0);
- char *salt, *bytes_v;
- std::size_t len_salt, len_v;
- salt = NULL;
- getSRPVerifier(getPlayerName(), m_password,
- &salt, &len_salt, &bytes_v, &len_v);
- resp_pkt
- << std::string((char*)salt, len_salt)
- << std::string((char*)bytes_v, len_v)
- << (u8)((m_password == "") ? 1 : 0);
- free(salt);
- free(bytes_v);
+ resp_pkt << salt << verifier << (u8)((m_password == "") ? 1 : 0);
+
Send(&resp_pkt);
break;
}
u8 based_on = 1;
if (chosen_auth_mechanism == AUTH_MECHANISM_LEGACY_PASSWORD) {
- m_password = translatePassword(getPlayerName(), m_password);
+ m_password = translate_password(getPlayerName(), m_password);
based_on = 0;
}
m_new_password = newpassword;
startAuth(choseAuthMech(m_sudo_auth_methods));
} else {
- std::string oldpwd = translatePassword(playername, oldpassword);
- std::string newpwd = translatePassword(playername, newpassword);
+ std::string oldpwd = translate_password(playername, oldpassword);
+ std::string newpwd = translate_password(playername, newpassword);
NetworkPacket pkt(TOSERVER_PASSWORD_LEGACY, 2 * PASSWORD_SIZE);