X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_xline%2Fcore_xline.cpp;h=7fa7da0197369fb412955489fb1e261473e11443;hb=045747290ba1088daf7f70d5d36d0eb4c8ba2b4e;hp=dcd85b4f62a3026e15df572b9cc7dcefdaa0644d;hpb=8de3635fab6d3de02b4a352380448316ebefe825;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp index dcd85b4f6..7fa7da019 100644 --- a/src/coremods/core_xline/core_xline.cpp +++ b/src/coremods/core_xline/core_xline.cpp @@ -18,8 +18,38 @@ #include "inspircd.h" +#include "xline.h" #include "core_xline.h" +bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey) +{ + ConfigTag* insane = ServerInstance->Config->ConfValue("insane"); + + if (insane->getBool(confkey)) + return false; + + float itrigger = insane->getFloat("trigger", 95.5); + + long matches = test.Run(mask); + + if (!matches) + return false; + + float percent = ((float)matches / (float)ServerInstance->Users->GetUsers().size()) * 100; + if (percent > itrigger) + { + ServerInstance->SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a %s-line mask of %s, which covers %.2f%% of the network!", user->nick.c_str(), bantype, mask.c_str(), percent); + return true; + } + return false; +} + +bool InsaneBan::IPHostMatcher::Check(User* user, const std::string& mask) const +{ + return ((InspIRCd::Match(user->MakeHost(), mask, ascii_case_insensitive_map)) || + (InspIRCd::Match(user->MakeHostIP(), mask, ascii_case_insensitive_map))); +} + class CoreModXLine : public Module { CommandEline cmdeline; @@ -34,6 +64,26 @@ class CoreModXLine : public Module { } + ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE + { + // Check Q-Lines (for local nick changes only, remote servers have our Q-Lines to enforce themselves) + + XLine* xline = ServerInstance->XLines->MatchesLine("Q", newnick); + if (!xline) + return MOD_RES_PASSTHRU; // No match + + // A Q-Line matched the new nick, tell opers if the user is registered + if (user->registered == REG_ALL) + { + ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s: %s", + newnick.c_str(), user->GetFullRealHost().c_str(), xline->reason.c_str()); + } + + // Send a numeric because if we deny then the core doesn't reply anything + user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Invalid nickname: %s", newnick.c_str(), xline->reason.c_str()); + return MOD_RES_DENY; + } + Version GetVersion() CXX11_OVERRIDE { return Version("Provides the ELINE, GLINE, KLINE, QLINE, and ZLINE commands", VF_VENDOR|VF_CORE);