X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_connectban.cpp;h=b4b16f5394420a442fd5c6f957253065253c1cc2;hb=55a0a6ab66739fae65d123fadff1a31d96999c16;hp=75bd0c0cb467dce06324972a200be1bf65e07a02;hpb=aa692dc1039b63deef7886e914ec499abe7facaf;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 75bd0c0cb..b4b16f539 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2019 Matt Schatz * Copyright (C) 2014 Googolplexed - * Copyright (C) 2013, 2017-2019 Sadie Powell + * Copyright (C) 2013, 2017-2020 Sadie Powell * Copyright (C) 2012-2014 Attila Molnar * Copyright (C) 2012, 2019 Robby * Copyright (C) 2009-2010 Daniel De Graaf @@ -61,15 +61,31 @@ 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) { } + void Prioritize() CXX11_OVERRIDE + { + Module* corexline = ServerInstance->Modules->Find("core_xline"); + ServerInstance->Modules->SetPriority(this, I_OnSetUserIP, PRIORITY_AFTER, corexline); + } + Version GetVersion() CXX11_OVERRIDE { - return Version("Throttles the connections of IP ranges who try to connect flood", VF_VENDOR); + return Version("Z-lines IP addresses which make excessive connections to the server.", VF_VENDOR); } void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE @@ -85,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 @@ -99,7 +115,7 @@ class ModuleConnectBan void OnSetUserIP(LocalUser* u) CXX11_OVERRIDE { - if (u->exempt) + if (IsExempt(u)) return; irc::sockets::cidr_mask mask(u->client_sa, GetRange(u));