]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Annotations
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 5a0e28bb5e94958432591e9d6d9aff7879a5fda8..29d26a9ec7ab297f90af2e54d0f4ae226d95d9bf 100644 (file)
@@ -43,7 +43,7 @@
 
 /* $ModDesc: Provides masking of user hostnames */
 
-extern InspIRCd* ServerInstance;
+
 
 /* The four core functions - F1 is optimized somewhat */
 
@@ -60,6 +60,8 @@ typedef unsigned int uint32_t;
 typedef uint32_t word32; /* NOT unsigned long. We don't support 16 bit platforms, anyway. */
 typedef unsigned char byte;
 
+/** An MD5 context, used by m_cloaking
+ */
 class xMD5Context : public classbase
 {
  public:
@@ -68,9 +70,11 @@ class xMD5Context : public classbase
        word32 in[16];
 };
 
+/** Handles user mode +x
+ */
 class CloakUser : public ModeHandler
 {
-       Server* Srv;
+       
        std::string prefix;
        word32 key1;
        word32 key2;
@@ -285,7 +289,7 @@ class CloakUser : public ModeHandler
        }
        
  public:
-       CloakUser(Server* Me) : ModeHandler('x', 0, 0, false, MODETYPE_USER, false), Srv(Me) { }
+       CloakUser(InspIRCd* Instance) : ModeHandler(Instance, 'x', 0, 0, false, MODETYPE_USER, false) { }
 
        ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
        {
@@ -348,7 +352,7 @@ class CloakUser : public ModeHandler
                                                // else, they have an ip
                                                b = std::string(ra) + "." + prefix + ".cloak";
                                        }
-                                       Srv->Log(DEBUG,"cloak: allocated "+b);
+                                       ServerInstance->Log(DEBUG,"cloak: allocated "+b);
                                        dest->ChangeDisplayedHost(b.c_str());
                                }
                                
@@ -374,7 +378,7 @@ class CloakUser : public ModeHandler
        
        void DoRehash()
        {
-               ConfigReader Conf;
+               ConfigReader Conf(ServerInstance);
                key1 = key2 = key3 = key4 = 0;
                key1 = Conf.ReadInteger("cloak","key1",0,false);
                key2 = Conf.ReadInteger("cloak","key2",0,false);
@@ -398,24 +402,25 @@ class CloakUser : public ModeHandler
 class ModuleCloaking : public Module
 {
  private:
-       Server *Srv;
+       
        CloakUser* cu;
 
  public:
-       ModuleCloaking(Server* Me)
-       : Module::Module(Me), Srv(Me)
+       ModuleCloaking(InspIRCd* Me)
+               : Module::Module(Me)
        {
                /* Create new mode handler object */
-               cu = new CloakUser(Srv);
+               cu = new CloakUser(ServerInstance);
 
                /* Register it with the core */         
-               Srv->AddMode(cu, 'x');
+               ServerInstance->AddMode(cu, 'x');
 
                OnRehash("");
        }
        
        virtual ~ModuleCloaking()
        {
+               ServerInstance->Modes->DelMode(cu);
                DELETE(cu);
        }
        
@@ -423,7 +428,7 @@ class ModuleCloaking : public Module
        {
                // returns the version number of the module to be
                // listed in /MODULES
-               return Version(1,0,0,2,VF_STATIC|VF_VENDOR);
+               return Version(1,0,0,2,VF_COMMON|VF_VENDOR);
        }
 
        virtual void OnRehash(const std::string &parameter)
@@ -433,23 +438,8 @@ class ModuleCloaking : public Module
 
        void Implements(char* List)
        {
-               List[I_OnRehash] = List[I_OnUserConnect] = 1;
+               List[I_OnRehash] = 1;
        }
-
-       virtual void OnUserConnect(userrec* user)
-       {
-               // Heres the weird bit. When a user connects we must set +x on them, so
-               // we're going to use the SendMode method of the Server class to send
-               // the mode to the client. This is basically the same as sending an
-               // SAMODE in unreal. Note that to the user it will appear as if they set
-               // the mode on themselves.
-               
-               const char* modes[2];           // only two parameters
-               modes[0] = user->nick;          // first parameter is the nick
-               modes[1] = "+x";                // second parameter is the mode
-               Srv->SendMode(modes,2,user);    // send these, forming the command "MODE <nick> +x"
-       }
-
 };
 
 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
@@ -465,7 +455,7 @@ class ModuleCloakingFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleCloaking(Me);
        }