summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-21 19:30:50 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-21 19:30:50 +0000
commit0fc89abe46fc3f98603340bc914f4ab4376c6708 (patch)
tree94445d2c6f0ddd1a997b83602491e09dc74091dc /src
parent991a893b5de0d168a3c7372905044a1ddadd9214 (diff)
Not finished yet. currently, this passes AUTHENTICATE messages to and from services and a client using ENCAP, and makes itself available via CAP
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9147 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_sasl.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
new file mode 100644
index 000000000..fc4a75fe3
--- /dev/null
+++ b/src/modules/m_sasl.cpp
@@ -0,0 +1,89 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "m_cap.h"
+
+/* $ModDesc: Provides support for atheme SASL via AUTHENTICATE. */
+
+class CommandAuthenticate : public Command
+{
+ public:
+ CommandAuthenticate (InspIRCd* Instance) : Command(Instance,"AUTHENTICATE", 0, 1)
+ {
+ this->source = "m_sasl.so";
+ }
+
+ CmdResult Handle (const char* const* parameters, int pcnt, User *user)
+ {
+ if (user->registered != REG_ALL)
+ {
+ /* Only allow AUTHENTICATE on unregistered clients */
+ std::deque<std::string> params;
+ params.push_back("*");
+ for (int i = 0; i < pcnt; ++i)
+ params.push_back(parameters[0]);
+ }
+ return CMD_FAILURE;
+ }
+};
+
+
+class ModuleSASL : public Module
+{
+ CommandAuthenticate* sasl;
+
+ public:
+
+ ModuleSASL(InspIRCd* Me)
+ : Module(Me)
+ {
+ Implementation eventlist[] = { I_OnEvent };
+ ServerInstance->Modules->Attach(eventlist, this, 1);
+
+ sasl = new CommandAuthenticate(ServerInstance);
+ }
+
+
+ virtual ~ModuleSASL()
+ {
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,2,0,1,VF_VENDOR,API_VERSION);
+ }
+
+ virtual void OnEvent(Event *ev)
+ {
+ GenericCapHandler(ev, "sasl", "sasl");
+
+ if (ev->GetEventID() == "encap_received")
+ {
+ /* Received encap reply, look for AUTHENTICATE */
+ std::deque<std::string>* parameters = (std::deque<std::string>*)ev->GetData();
+
+ User* target = ServerInstance->FindNick((*parameters)[0]);
+
+ if (target)
+ {
+ /* Found a user */
+ parameters->pop_front();
+ std::string line = irc::stringjoiner(" ", *parameters, 0, parameters->size() - 1).GetJoined();
+ target->WriteServ("AUTHENTICATE %s", line.c_str());
+ }
+ }
+ }
+};
+
+MODULE_INIT(ModuleSASL)