]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Allow disabling connectban for specific connect classes.
authorSadie Powell <sadie@witchery.services>
Wed, 27 Jan 2021 19:31:48 +0000 (19:31 +0000)
committerSadie Powell <sadie@witchery.services>
Wed, 27 Jan 2021 19:39:32 +0000 (19:39 +0000)
Ref: #1841.

docs/conf/inspircd.conf.example
src/modules/m_connectban.cpp

index 06ad9669dab84ed6bdcfb73a81536e334795991c..fecaafdc2d78a4a5d76d27f3a4cc49daceb9dd36 100644 (file)
          # in this class. This can save a lot of resources on very busy servers.
          resolvehostnames="yes"
 
+         # useconnectban: Defines if users in this class should be exempt from connectban limits.
+         # This setting only has effect when the connectban module is loaded.
+         #useconnectban="yes"
+
          # usednsbl: Defines whether or not users in this class are subject to DNSBL. Default is yes.
          # This setting only has effect when the dnsbl module is loaded.
          #usednsbl="yes"
index 81b0fcfa79f3aff3d02eeff65781896ddbcf8d13..b4b16f5394420a442fd5c6f957253065253c1cc2 100644 (file)
@@ -61,6 +61,16 @@ class ModuleConnectBan
                return 0;
        }
 
+       static bool IsExempt(LocalUser* user)
+       {
+               // E-lined and already banned users shouldn't be hit.
+               if (user->exempt || user->quitting)
+                       return true;
+
+               // Users in an exempt class shouldn't be hit.
+               return user->GetClass() && !user->GetClass()->config->getBool("useconnectban", true);
+       }
+
  public:
        ModuleConnectBan()
                : WebIRC::EventListener(this)
@@ -91,7 +101,7 @@ class ModuleConnectBan
 
        void OnWebIRCAuth(LocalUser* user, const WebIRC::FlagMap* flags) CXX11_OVERRIDE
        {
-               if (user->exempt)
+               if (IsExempt(user))
                        return;
 
                // HACK: Lower the connection attempts for the gateway IP address. The user
@@ -105,7 +115,7 @@ class ModuleConnectBan
 
        void OnSetUserIP(LocalUser* u) CXX11_OVERRIDE
        {
-               if (u->exempt || u->quitting)
+               if (IsExempt(u))
                        return;
 
                irc::sockets::cidr_mask mask(u->client_sa, GetRange(u));