]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_xline/core_xline.cpp
Add channel TS to server-to-server INVITE to detect and drop unauthorized invites
[user/henk/code/inspircd.git] / src / coremods / core_xline / core_xline.cpp
index dcd85b4f62a3026e15df572b9cc7dcefdaa0644d..7daa70b49ec964089145cc5eb7d2b45e019f950b 100644 (file)
 #include "inspircd.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;