Add a config option for exempting classes from connflood.

This commit is contained in:
Sadie Powell 2021-02-21 04:09:59 +00:00
parent b45b7f018d
commit 6f4aee365b
3 changed files with 17 additions and 1 deletions

View File

@ -308,6 +308,10 @@
# This setting only has effect when the connectban module is loaded. # This setting only has effect when the connectban module is loaded.
#useconnectban="yes" #useconnectban="yes"
# useconnflood: Defines if users in this class should be exempt from connflood limits.
# This setting only has effect when the connflood module is loaded.
#useconnflood="yes"
# usednsbl: Defines whether or not users in this class are subject to DNSBL. Default is 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. # This setting only has effect when the dnsbl module is loaded.
#usednsbl="yes" #usednsbl="yes"

View File

@ -8,6 +8,7 @@
globalmax="100" globalmax="100"
localmax="100" localmax="100"
useconnectban="no" useconnectban="no"
useconnflood="no"
usednsbl="no"> usednsbl="no">
<connect name="IRCCloud (Brockwell)" parent="IRCCloud" allow="192.184.10.118"> <connect name="IRCCloud (Brockwell)" parent="IRCCloud" allow="192.184.10.118">

View File

@ -27,6 +27,7 @@
class ModuleConnFlood : public Module class ModuleConnFlood : public Module
{ {
private:
unsigned int seconds; unsigned int seconds;
unsigned int timeout; unsigned int timeout;
unsigned int boot_wait; unsigned int boot_wait;
@ -36,6 +37,16 @@ class ModuleConnFlood : public Module
time_t first; time_t first;
std::string quitmsg; std::string quitmsg;
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("useconnflood", true);
}
public: public:
ModuleConnFlood() ModuleConnFlood()
: conns(0), throttled(false) : conns(0), throttled(false)
@ -65,7 +76,7 @@ public:
ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
{ {
if (user->exempt) if (IsExempt(user))
return MOD_RES_PASSTHRU; return MOD_RES_PASSTHRU;
time_t next = ServerInstance->Time(); time_t next = ServerInstance->Time();