From 45643135c4434033e0b8492ac7e9d27c9c0b4050 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 5 Apr 2022 18:12:44 +0100 Subject: Fix the cban and connectban modules sending out duplicate snotices. --- src/modules/m_connectban.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/m_connectban.cpp') diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 55ac8886e..72a8eec05 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -159,7 +159,7 @@ class ModuleConnectBan CXX11_FINAL } ServerInstance->XLines->ApplyLines(); std::string maskstr = mask.str(); - ServerInstance->SNO->WriteGlobalSno('x', "Z-line added by module m_connectban on %s to expire in %s (on %s): Connect flooding", + ServerInstance->SNO->WriteToSnoMask('x', "Z-line added by module m_connectban on %s to expire in %s (on %s): Connect flooding", maskstr.c_str(), InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()); ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", maskstr.c_str(), threshold); connects.erase(i); -- cgit v1.3.1-10-gc9f91 From e5a724595ff37ad8d050299fbdc94d62802c093d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 5 Apr 2022 17:45:46 +0100 Subject: Default connectban cidr ranges to the values specified in . --- src/modules/m_connectban.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules/m_connectban.cpp') diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 72a8eec05..fd3aeab26 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -104,8 +104,8 @@ class ModuleConnectBan CXX11_FINAL { ConfigTag* tag = ServerInstance->Config->ConfValue("connectban"); - ipv4_cidr = tag->getUInt("ipv4cidr", 32, 1, 32); - ipv6_cidr = tag->getUInt("ipv6cidr", 128, 1, 128); + ipv4_cidr = tag->getUInt("ipv4cidr", ServerInstance->Config->c_ipv4_range, 1, 32); + ipv6_cidr = tag->getUInt("ipv6cidr", ServerInstance->Config->c_ipv6_range, 1, 128); threshold = tag->getUInt("threshold", 10, 1); bootwait = tag->getDuration("bootwait", 60*2); splitwait = tag->getDuration("splitwait", 60*2); -- cgit v1.3.1-10-gc9f91 From f20fa911c4785f61f8d22c7861b810d38be2206b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 5 Apr 2022 18:15:56 +0100 Subject: Increase the default connectban ban duration from 10m to 6h. 10m is borderline useless for preventing bot floods. --- docs/conf/modules.conf.example | 2 +- src/modules/m_connectban.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules/m_connectban.cpp') diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 0d9f76d2e..9f4ef245c 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -714,7 +714,7 @@ # #getUInt("threshold", 10, 1); bootwait = tag->getDuration("bootwait", 60*2); splitwait = tag->getDuration("splitwait", 60*2); - banduration = tag->getDuration("banduration", tag->getDuration("duration", 10*60), 1); + banduration = tag->getDuration("banduration", tag->getDuration("duration", 6*60*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) -- cgit v1.3.1-10-gc9f91 From ddf306850efb9e4059ecb0506b073b3af4d79dca Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 5 Apr 2022 22:57:14 +0100 Subject: Include the module name in the setter for server-added xlines. --- src/modules/m_connectban.cpp | 2 +- src/modules/m_dnsbl.cpp | 6 +++--- src/modules/m_rline.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/modules/m_connectban.cpp') diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index a590e5b95..c24f03080 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -151,7 +151,7 @@ class ModuleConnectBan CXX11_FINAL if (i->second >= threshold) { // Create Z-line for set duration. - ZLine* zl = new ZLine(ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, banmessage, mask.str()); + ZLine* zl = new ZLine(ServerInstance->Time(), banduration, MODNAME "@" + ServerInstance->Config->ServerName, banmessage, mask.str()); if (!ServerInstance->XLines->AddLine(zl, NULL)) { delete zl; diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 6cfadff59..35b750e97 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -181,7 +181,7 @@ class DNSBLResolver : public DNS::Request } case DNSBLConfEntry::I_KLINE: { - KLine* kl = new KLine(ServerInstance->Time(), ConfEntry->duration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), + KLine* kl = new KLine(ServerInstance->Time(), ConfEntry->duration, MODNAME "@" + ServerInstance->Config->ServerName, reason, them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(kl,NULL)) { @@ -199,7 +199,7 @@ class DNSBLResolver : public DNS::Request } case DNSBLConfEntry::I_GLINE: { - GLine* gl = new GLine(ServerInstance->Time(), ConfEntry->duration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), + GLine* gl = new GLine(ServerInstance->Time(), ConfEntry->duration, MODNAME "@" + ServerInstance->Config->ServerName, reason, them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(gl,NULL)) { @@ -217,7 +217,7 @@ class DNSBLResolver : public DNS::Request } case DNSBLConfEntry::I_ZLINE: { - ZLine* zl = new ZLine(ServerInstance->Time(), ConfEntry->duration, ServerInstance->Config->ServerName.c_str(), reason.c_str(), + ZLine* zl = new ZLine(ServerInstance->Time(), ConfEntry->duration, MODNAME "@" + ServerInstance->Config->ServerName, reason, them->GetIPString()); if (ServerInstance->XLines->AddLine(zl,NULL)) { diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index ecaf9b6a3..214095706 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -72,7 +72,7 @@ class RLine : public XLine { if (ZlineOnMatch) { - ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString()); + ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason.c_str(), u->GetIPString()); if (ServerInstance->XLines->AddLine(zl, NULL)) { std::string expirystr = zl->duration ? InspIRCd::Format(" to expire in %s (on %s)", InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()) : ""; -- cgit v1.3.1-10-gc9f91 From 38c305bf0a7eeaf1b05343ee0718dc0b3f78ce3d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 5 Apr 2022 23:13:10 +0100 Subject: Notify opers about the connectban zline being added before applying it. This matches behaviour elsewhere. --- src/modules/m_connectban.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/m_connectban.cpp') diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index c24f03080..624ab57ec 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -157,12 +157,12 @@ class ModuleConnectBan CXX11_FINAL delete zl; return; } - ServerInstance->XLines->ApplyLines(); std::string maskstr = mask.str(); ServerInstance->SNO->WriteToSnoMask('x', "Z-line added by module m_connectban on %s to expire in %s (on %s): Connect flooding", maskstr.c_str(), InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()); ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", maskstr.c_str(), threshold); connects.erase(i); + ServerInstance->XLines->ApplyLines(); } } else -- cgit v1.3.1-10-gc9f91 From 070d41431084409a85660b7ef0b171840cae69ef Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 5 Apr 2022 23:13:56 +0100 Subject: Use consistent xline messages locally For connectban these messages would have previously been duplicated to other servers until this was fixed earlier today. For dnsbl and rline they would have just differed on the local to a remote. As of the previous commit the module name is included in the setter so there is no need to vary the snotice. This makes things more consistent for server operators and allows scripts to parse the messages. --- src/modules/m_connectban.cpp | 5 +++-- src/modules/m_dnsbl.cpp | 18 +++++++++--------- src/modules/m_rline.cpp | 14 +++++++++++--- 3 files changed, 23 insertions(+), 14 deletions(-) (limited to 'src/modules/m_connectban.cpp') diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 624ab57ec..80705bf81 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -158,8 +158,9 @@ class ModuleConnectBan CXX11_FINAL return; } std::string maskstr = mask.str(); - ServerInstance->SNO->WriteToSnoMask('x', "Z-line added by module m_connectban on %s to expire in %s (on %s): Connect flooding", - maskstr.c_str(), InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added a timed Z-line on %s, expires in %s (on %s): %s", + zl->source.c_str(), maskstr.c_str(), InspIRCd::DurationString(zl->duration).c_str(), + InspIRCd::TimeString(zl->expiry).c_str(), zl->reason.c_str()); ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", maskstr.c_str(), threshold); connects.erase(i); ServerInstance->XLines->ApplyLines(); diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 35b750e97..8777b6f24 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -185,9 +185,9 @@ class DNSBLResolver : public DNS::Request them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(kl,NULL)) { - ServerInstance->SNO->WriteToSnoMask('x', "K-line added due to DNSBL match on %s to expire in %s (on %s): %s", - kl->Displayable().c_str(), InspIRCd::DurationString(kl->duration).c_str(), - InspIRCd::TimeString(kl->expiry).c_str(), reason.c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added a timed K-line on %s, expires in %s (on %s): %s", + kl->source.c_str(), kl->Displayable().c_str(), InspIRCd::DurationString(kl->duration).c_str(), + InspIRCd::TimeString(kl->expiry).c_str(), kl->reason.c_str()); ServerInstance->XLines->ApplyLines(); } else @@ -203,9 +203,9 @@ class DNSBLResolver : public DNS::Request them->GetBanIdent(), them->GetIPString()); if (ServerInstance->XLines->AddLine(gl,NULL)) { - ServerInstance->SNO->WriteToSnoMask('x', "G-line added due to DNSBL match on %s to expire in %s (on %s): %s", - gl->Displayable().c_str(), InspIRCd::DurationString(gl->duration).c_str(), - InspIRCd::TimeString(gl->expiry).c_str(), reason.c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added a timed G-line on %s, expires in %s (on %s): %s", + gl->source.c_str(), gl->Displayable().c_str(), InspIRCd::DurationString(gl->duration).c_str(), + InspIRCd::TimeString(gl->expiry).c_str(), gl->reason.c_str()); ServerInstance->XLines->ApplyLines(); } else @@ -221,9 +221,9 @@ class DNSBLResolver : public DNS::Request them->GetIPString()); if (ServerInstance->XLines->AddLine(zl,NULL)) { - ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to DNSBL match on %s to expire in %s (on %s): %s", - them->GetIPString().c_str(), InspIRCd::DurationString(zl->duration).c_str(), - InspIRCd::TimeString(zl->expiry).c_str(), reason.c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s added a timed Z-line on %s, expires in %s (on %s): %s", + zl->source.c_str(), zl->Displayable().c_str(), InspIRCd::DurationString(zl->duration).c_str(), + InspIRCd::TimeString(zl->expiry).c_str(), zl->reason.c_str()); ServerInstance->XLines->ApplyLines(); } else diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 214095706..9d6028b09 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -75,9 +75,17 @@ class RLine : public XLine ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason.c_str(), u->GetIPString()); if (ServerInstance->XLines->AddLine(zl, NULL)) { - std::string expirystr = zl->duration ? InspIRCd::Format(" to expire in %s (on %s)", InspIRCd::DurationString(zl->duration).c_str(), InspIRCd::TimeString(zl->expiry).c_str()) : ""; - ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on %s%s: %s", - zl->ipaddr.c_str(), expirystr.c_str(), zl->reason.c_str()); + if (!duration) + { + ServerInstance->SNO->WriteToSnoMask('x', "%s added a permanent Z-line on %s: %s", + zl->source.c_str(), u->GetIPString().c_str(), zl->reason.c_str()); + } + else + { + ServerInstance->SNO->WriteToSnoMask('x', "%s added a timed Z-line on %s, expires in %s (on %s): %s", + zl->source.c_str(), u->GetIPString().c_str(), InspIRCd::DurationString(zl->duration).c_str(), + InspIRCd::TimeString(zl->duration).c_str(), zl->reason.c_str()); + } added_zline = true; } else -- cgit v1.3.1-10-gc9f91