]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Hosts vector not cleared on rehash, made rehashing for changes impossible
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index d8dae202bd9d97cc3e60b7effb086c38334f2060..593f3227ff0109fd389a2bb72336b90b39d3d263 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -67,7 +67,7 @@ class CloakUser : public ModeHandler
        {
        }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
        {
                if (source != dest)
                        return MODEACTION_DENY;
@@ -109,7 +109,7 @@ class CloakUser : public ModeHandler
                                         * 'real' hostname which you shouldnt write to.
                                         */
 
-                                       /* 2007/08/18: add <cloak:ipalways> which always cloaks
+                                       /* 2008/08/18: add <cloak:ipalways> which always cloaks
                                         * the IP, for anonymity. --nenolod
                                         */
                                        if (!ipalways)
@@ -319,21 +319,32 @@ class ModuleCloaking : public Module
        ModuleCloaking(InspIRCd* Me)
                : Module(Me)
        {
-               ServerInstance->Modules->UseInterface("HashRequest");
-
                /* Attempt to locate the md5 service provider, bail if we can't find it */
                HashModule = ServerInstance->Modules->Find("m_md5.so");
                if (!HashModule)
                        throw ModuleException("Can't find m_md5.so. Please load m_md5.so before m_cloaking.so.");
 
-               /* Create new mode handler object */
                cu = new CloakUser(ServerInstance, this, HashModule);
 
-               /* Register it with the core */         
-               if (!ServerInstance->AddMode(cu))
+               try
+               {
+                       OnRehash(NULL,"");
+               }
+               catch (CoreException &e)
+               {
+                       delete cu;
+                       throw e;
+               }
+
+               /* Register it with the core */
+               if (!ServerInstance->Modes->AddMode(cu))
+               {
+                       delete cu;
                        throw ModuleException("Could not add new modes!");
+               }
+
+               ServerInstance->Modules->UseInterface("HashRequest");
 
-               OnRehash(NULL,"");
                Implementation eventlist[] = { I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
@@ -349,7 +360,7 @@ class ModuleCloaking : public Module
        {
                // returns the version number of the module to be
                // listed in /MODULES
-               return Version(1,1,0,2,VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version(1,2,0,2,VF_COMMON|VF_VENDOR,API_VERSION);
        }
 
        virtual void OnRehash(User* user, const std::string &parameter)
@@ -357,10 +368,6 @@ class ModuleCloaking : public Module
                cu->DoRehash();
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnRehash] = 1;
-       }
 };
 
 MODULE_INIT(ModuleCloaking)