diff options
| author | 2021-06-18 11:18:56 +0100 | |
|---|---|---|
| committer | 2021-06-18 11:18:56 +0100 | |
| commit | a509f47b7d7c485dfafe2f8fe90d3dc2297b6027 (patch) | |
| tree | d06b2e07af9f5a0f64f3e630ca5ed51873dbacb1 /src | |
| parent | Fix joinflood overwriting the bootwait timer on split. (diff) | |
Add the bootwait and splitwait options to connectban.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/m_connectban.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index aa94adc2e..53aef6ca8 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -26,18 +26,25 @@ #include "inspircd.h" #include "xline.h" +#include "modules/server.h" #include "modules/webirc.h" -class ModuleConnectBan +class ModuleConnectBan CXX11_FINAL : public Module + , public ServerProtocol::LinkEventListener , public WebIRC::EventListener { + private: typedef std::map<irc::sockets::cidr_mask, unsigned int> ConnectMap; + ConnectMap connects; unsigned int threshold; unsigned int banduration; unsigned int ipv4_cidr; unsigned int ipv6_cidr; + unsigned long bootwait; + unsigned long splitwait; + time_t ignoreuntil; std::string banmessage; unsigned char GetRange(LocalUser* user) @@ -72,8 +79,13 @@ class ModuleConnectBan } public: + // Stop GCC warnings about the deprecated OnServerSplit event. + using ServerProtocol::LinkEventListener::OnServerSplit; + ModuleConnectBan() - : WebIRC::EventListener(this) + : ServerProtocol::LinkEventListener(this) + , WebIRC::EventListener(this) + , ignoreuntil(0) { } @@ -95,8 +107,13 @@ class ModuleConnectBan ipv4_cidr = tag->getUInt("ipv4cidr", 32, 1, 32); ipv6_cidr = tag->getUInt("ipv6cidr", 128, 1, 128); threshold = tag->getUInt("threshold", 10, 1); + bootwait = tag->getDuration("bootwait", 60*2); + splitwait = tag->getDuration("splitwait", 60*2); banduration = tag->getDuration("duration", 10*60, 1); 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."); + + if (status.initial) + ignoreuntil = std::max<time_t>(ignoreuntil, ServerInstance->Time() + splitwait); } void OnWebIRCAuth(LocalUser* user, const WebIRC::FlagMap* flags) CXX11_OVERRIDE @@ -113,9 +130,15 @@ class ModuleConnectBan iter->second--; } + void OnServerSplit(const Server* server, bool error) CXX11_OVERRIDE + { + if (splitwait) + ignoreuntil = ServerInstance->Time() + splitwait; + } + void OnSetUserIP(LocalUser* u) CXX11_OVERRIDE { - if (IsExempt(u)) + if (IsExempt(u) || ignoreuntil > ServerInstance->Time()) return; irc::sockets::cidr_mask mask(u->client_sa, GetRange(u)); |
