summaryrefslogtreecommitdiff
path: root/src/clientiface.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-04-12 04:49:13 +0200
committerest31 <MTest31@outlook.com>2015-05-11 18:40:27 +0200
commit82e35edff52d88dcd64a9bfc9d2c4c93f1341b78 (patch)
treebf55839e296c6d1cb9b7f81b8f5cf69e0492b4c0 /src/clientiface.cpp
parent181f7baa453c58d4070de7196fd74663110946a8 (diff)
downloadminetest-82e35edff52d88dcd64a9bfc9d2c4c93f1341b78.tar.gz
minetest-82e35edff52d88dcd64a9bfc9d2c4c93f1341b78.tar.bz2
minetest-82e35edff52d88dcd64a9bfc9d2c4c93f1341b78.zip
Make early protocol auth mechanism generic, and add SRP
Adds everything needed for SRP (and everything works too), but still deactivated, as protocol v25 init packets aren't final yet. Can be activated by changing the LATEST_PROTOCOL_VERSION header to 25 inside networkprotocol.h.
Diffstat (limited to 'src/clientiface.cpp')
-rw-r--r--src/clientiface.cpp63
1 files changed, 58 insertions, 5 deletions
diff --git a/src/clientiface.cpp b/src/clientiface.cpp
index 7649be29e..6944e56db 100644
--- a/src/clientiface.cpp
+++ b/src/clientiface.cpp
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "emerge.h"
#include "serverobject.h" // TODO this is used for cleanup of only
#include "log.h"
+#include "util/srp.h"
const char *ClientInterface::statenames[] = {
"Invalid",
@@ -427,10 +428,12 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
//intentionally do nothing
break;
case CS_Created:
- switch(event)
- {
- case CSE_Init:
- m_state = CS_InitSent;
+ switch (event) {
+ case CSE_Hello:
+ m_state = CS_HelloSent;
+ break;
+ case CSE_InitLegacy:
+ m_state = CS_AwaitingInit2;
break;
case CSE_Disconnect:
m_state = CS_Disconnecting;
@@ -447,7 +450,32 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
case CS_Denied:
/* don't do anything if in denied state */
break;
- case CS_InitSent:
+ case CS_HelloSent:
+ switch(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;
+ 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;
+ break;
+ default:
+ myerror << "HelloSent: Invalid client state transition! " << event;
+ throw ClientStateError(myerror.str());
+ }
+ break;
+ case CS_AwaitingInit2:
switch(event)
{
case CSE_GotInit2:
@@ -514,6 +542,13 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
case CSE_Disconnect:
m_state = CS_Disconnecting;
break;
+ case CSE_SudoSuccess:
+ m_state = CS_SudoMode;
+ if ((chosen_mech == AUTH_MECHANISM_SRP)
+ || (chosen_mech == AUTH_MECHANISM_LEGACY_PASSWORD))
+ srp_verifier_delete((SRPVerifier *) auth_data);
+ chosen_mech = AUTH_MECHANISM_NONE;
+ break;
/* Init GotInit2 SetDefinitionsSent SetMediaSent SetDenied */
default:
myerror << "Active: Invalid client state transition! " << event;
@@ -521,6 +556,24 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
break;
}
break;
+ case CS_SudoMode:
+ switch(event)
+ {
+ case CSE_SetDenied:
+ m_state = CS_Denied;
+ break;
+ case CSE_Disconnect:
+ m_state = CS_Disconnecting;
+ break;
+ case CSE_SudoLeave:
+ m_state = CS_Active;
+ break;
+ default:
+ myerror << "Active: Invalid client state transition! " << event;
+ throw ClientStateError(myerror.str());
+ break;
+ }
+ break;
case CS_Disconnecting:
/* we are already disconnecting */
break;