]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_connflood.cpp
OnRehash changes: split to multiple hooks to clarify use and prevent explosion of...
[user/henk/code/inspircd.git] / src / modules / m_connflood.cpp
index d6d9eee0fc0be984539026f77ff95f964bcdf790..6828d28f2e58b143e65b172758d497244e43f569 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -25,13 +25,15 @@ private:
        std::string quitmsg;
 
        ConfigReader* conf;
-       
+
 
 public:
        ModuleConnFlood(InspIRCd* Me) : Module(Me)
        {
-               
+
                InitConf();
+               Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
+               ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
        virtual ~ModuleConnFlood()
@@ -40,14 +42,9 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version(1,1,0,0,VF_VENDOR,API_VERSION);
+               return Version("$Id$", VF_VENDOR,API_VERSION);
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnRehash] = List[I_OnUserRegister] = 1;
-       }
-   
        void InitConf()
        {
                /* read configuration variables */
@@ -63,14 +60,14 @@ public:
 
                first = ServerInstance->Time();
        }
+
        virtual int OnUserRegister(User* user)
        {
                time_t next = ServerInstance->Time();
-               
+
                if ((ServerInstance->startup_time + boot_wait) > next)
                        return 0;
-               
+
                /* time difference between first and latest connection */
                time_t tdiff = next - first;
 
@@ -83,10 +80,11 @@ public:
                        {
                                /* expire throttle */
                                throttled = 0;
-                               ServerInstance->WriteOpers("*** Connection throttle deactivated");
+                               ServerInstance->SNO->WriteGlobalSno('a', "Connection throttle deactivated");
                                return 0;
                        }
-                       User::QuitUser(ServerInstance, user, quitmsg);
+
+                       ServerInstance->Users->QuitUser(user, quitmsg);
                        return 1;
                }
 
@@ -95,8 +93,8 @@ public:
                        if (conns >= maxconns)
                        {
                                throttled = 1;
-                               ServerInstance->WriteOpers("*** Connection throttle activated");
-                               User::QuitUser(ServerInstance, user, quitmsg);
+                               ServerInstance->SNO->WriteGlobalSno('a', "Connection throttle activated");
+                               ServerInstance->Users->QuitUser(user, quitmsg);
                                return 1;
                        }
                }
@@ -108,7 +106,7 @@ public:
                return 0;
        }
 
-       virtual void OnRehash(User* user, const std::string &parameter)
+       virtual void OnRehash(User* user)
        {
                InitConf();
        }