]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Next part of Development/Hooking (see wiki)
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 8e80ad89a4cd153bc7b7e0672840aa241746dbd4..99cf1dc0ffa8408f33f879a9e220355c2ede477b 100644 (file)
@@ -67,7 +67,7 @@ class CloakUser : public ModeHandler
        {
        }
 
-       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                if (source != dest)
                        return MODEACTION_DENY;
@@ -78,6 +78,9 @@ class CloakUser : public ModeHandler
                if (!IS_LOCAL(dest))
                        return MODEACTION_ALLOW;
 
+               /* don't allow this user to spam modechanges */
+               dest->IncreasePenalty(5);
+
                if (adding)
                {
                        if(!dest->IsModeSet('x'))
@@ -254,12 +257,17 @@ class CloakUser : public ModeHandler
        {
                ConfigReader Conf(ServerInstance);
                bool lowercase;
-
+               
+               /* These are *not* using the need_positive parameter of ReadInteger - 
+                * that will limit the valid values to only the positive values in a
+                * signed int. Instead, accept any value that fits into an int and
+                * cast it to an unsigned int. That will, a bit oddly, give us the full
+                * spectrum of an unsigned integer. - Special */
                key1 = key2 = key3 = key4 = 0;
-               key1 = Conf.ReadInteger("cloak","key1",0,true);
-               key2 = Conf.ReadInteger("cloak","key2",0,true);
-               key3 = Conf.ReadInteger("cloak","key3",0,true);
-               key4 = Conf.ReadInteger("cloak","key4",0,true);
+               key1 = (unsigned int) Conf.ReadInteger("cloak","key1",0,false);
+               key2 = (unsigned int) Conf.ReadInteger("cloak","key2",0,false);
+               key3 = (unsigned int) Conf.ReadInteger("cloak","key3",0,false);
+               key4 = (unsigned int) Conf.ReadInteger("cloak","key4",0,false);
                prefix = Conf.ReadValue("cloak","prefix",0);
                ipalways = Conf.ReadFlag("cloak", "ipalways", 0);
                lowercase = Conf.ReadFlag("cloak", "lowercase", 0);
@@ -322,7 +330,7 @@ class ModuleCloaking : public Module
                cu = new CloakUser(ServerInstance, this, HashModule);
 
                /* Register it with the core */         
-               if (!ServerInstance->AddMode(cu, 'x'))
+               if (!ServerInstance->AddMode(cu))
                        throw ModuleException("Could not add new modes!");
 
                OnRehash(NULL,"");
@@ -342,7 +350,7 @@ class ModuleCloaking : public Module
                return Version(1,1,0,2,VF_COMMON|VF_VENDOR,API_VERSION);
        }
 
-       virtual void OnRehash(userrec* user, const std::string &parameter)
+       virtual void OnRehash(User* user, const std::string &parameter)
        {
                cu->DoRehash();
        }