]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_connflood.cpp
m_services_account Fix possible recursion when checking 'U' extbans
[user/henk/code/inspircd.git] / src / modules / m_connflood.cpp
index d0e9257168c0ec038c5c39ff1504e42688ecc098..9d7c9cb2cf648014ea3e31d49fd0cbbe0cafcd57 100644 (file)
 
 /* $ModDesc: Connection throttle */
 
-int conns = 0, throttled = 0;
-
 class ModuleConnFlood : public Module
 {
 private:
-       int seconds, maxconns, timeout, boot_wait;
+       int seconds, timeout, boot_wait;
+       unsigned int conns;
+       unsigned int maxconns;
+       bool throttled;
        time_t first;
        std::string quitmsg;
 
 public:
-       ModuleConnFlood()       {
-
+       ModuleConnFlood()
+               : conns(0), throttled(false)
+       {
                InitConf();
                Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
                ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
-       virtual ~ModuleConnFlood()
-       {
-       }
-
        virtual Version GetVersion()
        {
                return Version("Connection throttle", VF_VENDOR);
@@ -78,12 +76,12 @@ public:
                /* increase connection count */
                conns++;
 
-               if (throttled == 1)
+               if (throttled)
                {
                        if (tdiff > seconds + timeout)
                        {
                                /* expire throttle */
-                               throttled = 0;
+                               throttled = false;
                                ServerInstance->SNO->WriteGlobalSno('a', "Connection throttle deactivated");
                                return MOD_RES_PASSTHRU;
                        }
@@ -96,7 +94,7 @@ public:
                {
                        if (conns >= maxconns)
                        {
-                               throttled = 1;
+                               throttled = true;
                                ServerInstance->SNO->WriteGlobalSno('a', "Connection throttle activated");
                                ServerInstance->Users->QuitUser(user, quitmsg);
                                return MOD_RES_DENY;