]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_connflood.cpp
WebSocket: use one WebSocket message per IRC message.
[user/henk/code/inspircd.git] / src / modules / m_connflood.cpp
index 9bc8277eeb0914afafc53a0558e2b1dc44494838..5070dd3a76b26e6e629f71b4415451e104c43ca3 100644 (file)
 
 #include "inspircd.h"
 
-/* $ModDesc: Connection throttle */
-
 class ModuleConnFlood : public Module
 {
-       int seconds, timeout, boot_wait;
+       unsigned int seconds;
+       unsigned int timeout;
+       unsigned int boot_wait;
        unsigned int conns;
        unsigned int maxconns;
        bool throttled;
@@ -38,35 +38,28 @@ public:
        {
        }
 
-       void init()
-       {
-               InitConf();
-               Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-       }
-
-       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");
-               maxconns = tag->getInt("maxconns");
-               timeout = tag->getInt("timeout");
+               seconds = tag->getDuration("period", tag->getDuration("seconds", 30));
+               maxconns = tag->getUInt("maxconns", 3);
+               timeout = tag->getDuration("timeout", 30);
                quitmsg = tag->getString("quitmsg");
 
                /* seconds to wait when the server just booted */
-               boot_wait = tag->getInt("bootwait");
+               boot_wait = tag->getDuration("bootwait", 10);
 
                first = ServerInstance->Time();
        }
 
-       virtual ModResult OnUserRegister(LocalUser* user)
+       ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
        {
                if (user->exempt)
                        return MOD_RES_PASSTHRU;
@@ -113,12 +106,6 @@ public:
                }
                return MOD_RES_PASSTHRU;
        }
-
-       virtual void OnRehash(User* user)
-       {
-               InitConf();
-       }
-
 };
 
 MODULE_INIT(ModuleConnFlood)