From 875d4ac21470f57ffd6dac9ea584d2ed5b9df996 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 21 Jul 2023 15:30:41 +0100 Subject: Perform DNSBL lookups on E-lined users. Even if we aren't going to punish these users it can be useful for opers to know if users are in a DNSBL. --- src/modules/m_dnsbl.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/modules/m_dnsbl.cpp') diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index a27e9268e..c9ed8efd9 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -271,8 +271,11 @@ private: const std::string uuid; template - void AddLine(const char* type, const std::string& reason, unsigned long duration, Extra&&... extra) + void AddLine(const char* type, const std::string& reason, unsigned long duration, LocalUser* user, Extra&&... extra) { + if (user->exempt) + return; // This user shouldn't be banned. + auto line = new Line(ServerInstance->Time(), duration, MODNAME "@" + ServerInstance->Config->ServerName, reason, std::forward(extra)...); if (!ServerInstance->XLines->AddLine(line, nullptr)) { @@ -372,7 +375,8 @@ public: { case DNSBLEntry::Action::KILL: { - ServerInstance->Users.QuitUser(them, "Killed (" + reason + ")"); + if (!them->exempt) + ServerInstance->Users.QuitUser(them, "Killed (" + reason + ")"); break; } case DNSBLEntry::Action::MARK: @@ -392,29 +396,29 @@ public: } case DNSBLEntry::Action::KLINE: { - AddLine("K-line", reason, config->xlineduration, them->GetBanUser(true), them->GetAddress()); + AddLine("K-line", reason, config->xlineduration, them, them->GetBanUser(true), them->GetAddress()); break; } case DNSBLEntry::Action::GLINE: { - AddLine("G-line", reason, config->xlineduration, them->GetBanUser(true), them->GetAddress()); + AddLine("G-line", reason, config->xlineduration, them, them->GetBanUser(true), them->GetAddress()); break; } case DNSBLEntry::Action::ZLINE: { - AddLine("Z-line", reason, config->xlineduration, them->GetAddress()); + AddLine("Z-line", reason, config->xlineduration, them, them->GetAddress()); break; } case DNSBLEntry::Action::SHUN: { - AddLine("Shun", reason, config->xlineduration, them->GetAddress()); + AddLine("Shun", reason, config->xlineduration, them, them->GetAddress()); break; } } - ServerInstance->SNO.WriteGlobalSno('d', "{} {} ({}) detected as being on the '{}' DNSBL with result {}", + ServerInstance->SNO.WriteGlobalSno('d', "{} {} ({}) detected as being on the '{}' DNSBL with result {}{}", them->IsFullyConnected() ? "User" : "Connecting user", them->GetRealMask(), them->GetAddress(), - config->name, result); + config->name, result, them->exempt ? " -- exempt" : ""); } else config->stats_misses++; @@ -518,8 +522,8 @@ void SharedData::Lookup(LocalUser* user) if (!dns) return; // The core_dns module is not loaded. - if (user->exempt || !user->GetClass()->config->getBool("usednsbl", true)) - return; // The user is exempt from DNSBL lookups. + if (!user->GetClass()->config->getBool("usednsbl", true)) + return; // The user's class is exempt from DNSBL lookups. const std::string reversedip = ReverseIP(user->client_sa); ServerInstance->Logs.Debug(MODNAME, "Reversed IP {} => {}", user->GetAddress(), reversedip); -- cgit v1.3.1-10-gc9f91