aboutsummaryrefslogtreecommitdiff
path: root/src/clientiface.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2022-05-17 22:12:00 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2022-05-17 22:12:00 +0200
commit21df26984da91143c15587f5a03c98d68c3adc4e (patch)
treeaaa707a628ad331f67890023dffe1b4f60dd01d3 /src/clientiface.cpp
parentb09fc5de5cdb021f43ad32b7e3f50dc75c0bc622 (diff)
parenteabf05758e3ba5f6f4bb1b8d1d1f02179b84e410 (diff)
downloaddragonfireclient-21df26984da91143c15587f5a03c98d68c3adc4e.tar.xz
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/clientiface.cpp')
-rw-r--r--src/clientiface.cpp48
1 files changed, 12 insertions, 36 deletions
diff --git a/src/clientiface.cpp b/src/clientiface.cpp
index f35dcd0eb..5733b05de 100644
--- a/src/clientiface.cpp
+++ b/src/clientiface.cpp
@@ -472,20 +472,14 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
{
case CSE_AuthAccept:
m_state = CS_AwaitingInit2;
- if (chosen_mech == AUTH_MECHANISM_SRP ||
- chosen_mech == AUTH_MECHANISM_LEGACY_PASSWORD)
- srp_verifier_delete((SRPVerifier *) auth_data);
- chosen_mech = AUTH_MECHANISM_NONE;
+ resetChosenMech();
break;
case CSE_Disconnect:
m_state = CS_Disconnecting;
break;
case CSE_SetDenied:
m_state = CS_Denied;
- if (chosen_mech == AUTH_MECHANISM_SRP ||
- chosen_mech == AUTH_MECHANISM_LEGACY_PASSWORD)
- srp_verifier_delete((SRPVerifier *) auth_data);
- chosen_mech = AUTH_MECHANISM_NONE;
+ resetChosenMech();
break;
default:
myerror << "HelloSent: Invalid client state transition! " << event;
@@ -561,9 +555,7 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
break;
case CSE_SudoSuccess:
m_state = CS_SudoMode;
- if (chosen_mech == AUTH_MECHANISM_SRP)
- srp_verifier_delete((SRPVerifier *) auth_data);
- chosen_mech = AUTH_MECHANISM_NONE;
+ resetChosenMech();
break;
/* Init GotInit2 SetDefinitionsSent SetMediaSent SetDenied */
default:
@@ -596,6 +588,15 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
}
}
+void RemoteClient::resetChosenMech()
+{
+ if (auth_data) {
+ srp_verifier_delete((SRPVerifier *) auth_data);
+ auth_data = nullptr;
+ }
+ chosen_mech = AUTH_MECHANISM_NONE;
+}
+
u64 RemoteClient::uptime() const
{
return porting::getTimeS() - m_connection_time;
@@ -714,31 +715,6 @@ void ClientInterface::sendToAll(NetworkPacket *pkt)
}
}
-void ClientInterface::sendToAllCompat(NetworkPacket *pkt, NetworkPacket *legacypkt,
- u16 min_proto_ver)
-{
- RecursiveMutexAutoLock clientslock(m_clients_mutex);
- for (auto &client_it : m_clients) {
- RemoteClient *client = client_it.second;
- NetworkPacket *pkt_to_send = nullptr;
-
- if (client->net_proto_version >= min_proto_ver) {
- pkt_to_send = pkt;
- } else if (client->net_proto_version != 0) {
- pkt_to_send = legacypkt;
- } else {
- warningstream << "Client with unhandled version to handle: '"
- << client->net_proto_version << "'";
- continue;
- }
-
- m_con->Send(client->peer_id,
- clientCommandFactoryTable[pkt_to_send->getCommand()].channel,
- pkt_to_send,
- clientCommandFactoryTable[pkt_to_send->getCommand()].reliable);
- }
-}
-
RemoteClient* ClientInterface::getClientNoEx(session_t peer_id, ClientState state_min)
{
RecursiveMutexAutoLock clientslock(m_clients_mutex);