]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sslmodes.cpp
Merge pull request #495 from SaberUK/master+fix-libcpp
[user/henk/code/inspircd.git] / src / modules / m_sslmodes.cpp
index ef63b2511733b8369155b2a3678989acaf9357e8..bfd05238d30d60534e555fa950707eb060652170 100644 (file)
@@ -22,7 +22,7 @@
 
 
 #include "inspircd.h"
-#include "ssl.h"
+#include "modules/ssl.h"
 
 /* $ModDesc: Provides channel mode +z to allow for Secure/SSL only channels */
 
@@ -83,13 +83,16 @@ class ModuleSSLModes : public Module
        ModuleSSLModes()
                : sslm(this)
        {
-               if (!ServerInstance->Modes->AddMode(&sslm))
-                       throw ModuleException("Could not add new modes!");
+       }
+
+       void init()
+       {
+               ServerInstance->Modules->AddService(sslm);
                Implementation eventlist[] = { I_OnUserPreJoin, I_OnCheckBan, I_On005Numeric };
-               ServerInstance->Modules->Attach(eventlist, this, 3);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
+       ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven)
        {
                if(chan && chan->IsModeSet('z'))
                {
@@ -103,7 +106,7 @@ class ModuleSSLModes : public Module
                        else
                        {
                                // Deny
-                               user->WriteServ( "489 %s %s :Cannot join channel; SSL users only (+z)", user->nick.c_str(), cname);
+                               user->WriteServ( "489 %s %s :Cannot join channel; SSL users only (+z)", user->nick.c_str(), cname.c_str());
                                return MOD_RES_DENY;
                        }
                }
@@ -113,7 +116,7 @@ class ModuleSSLModes : public Module
 
        ModResult OnCheckBan(User *user, Channel *c, const std::string& mask)
        {
-               if (mask[0] == 'z' && mask[1] == ':')
+               if ((mask.length() > 2) && (mask[0] == 'z') && (mask[1] == ':'))
                {
                        UserCertificateRequest req(user, this);
                        req.Send();
@@ -123,13 +126,9 @@ class ModuleSSLModes : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       ~ModuleSSLModes()
-       {
-       }
-
-       void On005Numeric(std::string &output)
+       void On005Numeric(std::map<std::string, std::string>& tokens)
        {
-               ServerInstance->AddExtBanChar('z');
+               tokens["EXTBAN"].push_back('z');
        }
 
        Version GetVersion()
@@ -138,6 +137,4 @@ class ModuleSSLModes : public Module
        }
 };
 
-
 MODULE_INIT(ModuleSSLModes)
-