X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sasl.cpp;h=480f8f6db0d0ebc2ee559a80b705ae77417e6f8c;hb=bb15147464a463d2ca260fa6d7f02395f0f57620;hp=eedf968b404a5af062ca01030006eaabebf7a350;hpb=a3e0768758ca68429a29d9c78ce672f2d938c6e7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index eedf968b4..480f8f6db 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -23,7 +23,7 @@ #include "modules/account.h" #include "modules/sasl.h" #include "modules/ssl.h" -#include "modules/spanningtree.h" +#include "modules/server.h" enum { @@ -37,7 +37,7 @@ enum static std::string sasl_target; -class ServerTracker : public SpanningTreeEventListener +class ServerTracker : public ServerEventListener { bool online; @@ -65,7 +65,7 @@ class ServerTracker : public SpanningTreeEventListener public: ServerTracker(Module* mod) - : SpanningTreeEventListener(mod) + : ServerEventListener(mod) { Reset(); } @@ -143,9 +143,9 @@ enum SaslResult { SASL_OK, SASL_FAIL, SASL_ABORT }; static Events::ModuleEventProvider* saslevprov; -static void SendSASL(LocalUser* user, const std::string& agent, char mode, const parameterlist& parameters) +static void SendSASL(LocalUser* user, const std::string& agent, char mode, const std::vector& parameters) { - parameterlist params(parameters.size() + 3); + CommandBase::Params params; params.push_back(user->uuid); params.push_back(agent); params.push_back(ConvToStr(mode)); @@ -157,6 +157,8 @@ static void SendSASL(LocalUser* user, const std::string& agent, char mode, const } } +static ClientProtocol::EventProvider* g_protoev; + /** * Tracks SASL authentication state like charybdis does. --nenolod */ @@ -171,8 +173,8 @@ class SaslAuthenticator void SendHostIP() { - parameterlist params; - params.push_back(user->host); + std::vector params; + params.push_back(user->GetRealHost()); params.push_back(user->GetIPString()); params.push_back(SSLIOHook::IsSSL(&user->eh) ? "S" : "P"); @@ -185,7 +187,7 @@ class SaslAuthenticator { SendHostIP(); - parameterlist params; + std::vector params; params.push_back(method); const std::string fp = SSLClientCert::GetFingerprint(&user->eh); @@ -207,7 +209,7 @@ class SaslAuthenticator } /* checks for and deals with a state change. */ - SaslState ProcessInboundMessage(const std::vector &msg) + SaslState ProcessInboundMessage(const CommandBase::Params& msg) { switch (this->state) { @@ -223,7 +225,15 @@ class SaslAuthenticator return this->state; if (msg[2] == "C") - this->user->Write("AUTHENTICATE %s", msg[3].c_str()); + { + ClientProtocol::Message authmsg("AUTHENTICATE"); + authmsg.PushParamRef(msg[3]); + + ClientProtocol::Event authevent(*g_protoev, authmsg); + LocalUser* const localuser = IS_LOCAL(user); + if (localuser) + localuser->Send(authevent); + } else if (msg[2] == "D") { this->state = SASL_DONE; @@ -304,7 +314,7 @@ class CommandAuthenticate : public SplitCommand allow_empty_last_param = false; } - CmdResult HandleLocal(const std::vector& parameters, LocalUser* user) + CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE { { if (!cap.get(user)) @@ -341,7 +351,7 @@ class CommandSASL : public Command this->flags_needed = FLAG_SERVERONLY; // should not be called by users } - CmdResult Handle(const std::vector& parameters, User *user) + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { User* target = ServerInstance->FindUUID(parameters[1]); if (!target) @@ -363,7 +373,7 @@ class CommandSASL : public Command return CMD_SUCCESS; } - RouteDescriptor GetRouting(User* user, const std::vector& parameters) + RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE { return ROUTE_BROADCAST; } @@ -377,6 +387,7 @@ class ModuleSASL : public Module CommandAuthenticate auth; CommandSASL sasl; Events::ModuleEventProvider sasleventprov; + ClientProtocol::EventProvider protoev; public: ModuleSASL() @@ -386,8 +397,10 @@ class ModuleSASL : public Module , auth(this, authExt, cap) , sasl(this, authExt) , sasleventprov(this, "event/sasl") + , protoev(this, auth.name) { saslevprov = &sasleventprov; + g_protoev = &protoev; } void init() CXX11_OVERRIDE @@ -398,7 +411,11 @@ class ModuleSASL : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - sasl_target = ServerInstance->Config->ConfValue("sasl")->getString("target", "*"); + std::string target = ServerInstance->Config->ConfValue("sasl")->getString("target"); + if (target.empty()) + throw ModuleException(" must be set to the name of your services server!"); + + sasl_target = target; servertracker.Reset(); }