]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_connflood.cpp
Merge tag 'v2.0.25' into master.
[user/henk/code/inspircd.git] / src / modules / m_connflood.cpp
index 71516063b263539ae56048bee4e6c4c0df1ff9da..1d27e3990d1581f967486cecef6ef068967c164e 100644 (file)
 
 #include "inspircd.h"
 
-/* $ModDesc: Connection throttle */
-
 class ModuleConnFlood : public Module
 {
-private:
        int seconds, timeout, boot_wait;
        unsigned int conns;
        unsigned int maxconns;
@@ -37,24 +34,21 @@ public:
        ModuleConnFlood()
                : conns(0), throttled(false)
        {
-               InitConf();
-               Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Connection throttle", VF_VENDOR);
        }
 
-       void InitConf()
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                /* read configuration variables */
                ConfigTag* tag = ServerInstance->Config->ConfValue("connflood");
                /* throttle configuration */
-               seconds = tag->getInt("seconds");
+               seconds = tag->getDuration("period", tag->getInt("seconds"));
                maxconns = tag->getInt("maxconns");
-               timeout = tag->getInt("timeout");
+               timeout = tag->getDuration("timeout");
                quitmsg = tag->getString("quitmsg");
 
                /* seconds to wait when the server just booted */
@@ -63,8 +57,11 @@ public:
                first = ServerInstance->Time();
        }
 
-       virtual ModResult OnUserRegister(LocalUser* user)
+       ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
        {
+               if (user->exempt)
+                       return MOD_RES_PASSTHRU;
+
                time_t next = ServerInstance->Time();
 
                if ((ServerInstance->startup_time + boot_wait) > next)
@@ -107,12 +104,6 @@ public:
                }
                return MOD_RES_PASSTHRU;
        }
-
-       virtual void OnRehash(User* user)
-       {
-               InitConf();
-       }
-
 };
 
 MODULE_INIT(ModuleConnFlood)