]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_connectban.cpp
Allow Channel::WriteNotice send to other servers and status ranks.
[user/henk/code/inspircd.git] / src / modules / m_connectban.cpp
index 12b1234980f8e007db4013a08c6e450c6970d381..dd9ae4f5450158180cdc98aca7467b1f9dcd3133 100644 (file)
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/webirc.h"
 
-class ModuleConnectBan : public Module
+class ModuleConnectBan
+       : public Module
+       , public WebIRC::EventListener
 {
        typedef std::map<irc::sockets::cidr_mask, unsigned int> ConnectMap;
        ConnectMap connects;
@@ -52,6 +55,11 @@ class ModuleConnectBan : public Module
        }
 
  public:
+       ModuleConnectBan()
+               : WebIRC::EventListener(this)
+       {
+       }
+
        Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Throttles the connections of IP ranges who try to connect flood", VF_VENDOR);
@@ -68,6 +76,20 @@ class ModuleConnectBan : public Module
                banmessage = tag->getString("banmessage", "Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect.");
        }
 
+       void OnWebIRCAuth(LocalUser* user, const WebIRC::FlagMap* flags) CXX11_OVERRIDE
+       {
+               if (user->exempt)
+                       return;
+
+               // HACK: Lower the connection attempts for the gateway IP address. The user
+               // will be rechecked for connect spamming shortly after when their IP address
+               // is changed and OnSetUserIP is called.
+               irc::sockets::cidr_mask mask(user->client_sa, GetRange(user));
+               ConnectMap::iterator iter = connects.find(mask);
+               if (iter != connects.end() && iter->second)
+                       iter->second--;
+       }
+
        void OnSetUserIP(LocalUser* u) CXX11_OVERRIDE
        {
                if (u->exempt)