X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_xline%2Fcore_xline.h;h=d4ad498a0a52f8fcb19cd36fcd519760cf8f59ae;hb=dbe5a1fc6f9e18765863f332a3e79d7c918d3e65;hp=c2e1714104d30a6db6d35bda362608863192875e;hpb=8de3635fab6d3de02b4a352380448316ebefe825;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_xline/core_xline.h b/src/coremods/core_xline/core_xline.h index c2e171410..d4ad498a0 100644 --- a/src/coremods/core_xline/core_xline.h +++ b/src/coremods/core_xline/core_xline.h @@ -21,6 +21,50 @@ #include "inspircd.h" +class InsaneBan +{ + public: + class MatcherBase + { + public: + virtual long Run(const std::string& mask) = 0; + }; + + template + class Matcher : public MatcherBase + { + public: + long Run(const std::string& mask) + { + long matches = 0; + const T* c = static_cast(this); + const user_hash& users = ServerInstance->Users->GetUsers(); + for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i) + { + if (c->Check(i->second, mask)) + matches++; + } + return matches; + } + }; + + class IPHostMatcher : public Matcher + { + public: + bool Check(User* user, const std::string& mask) const; + }; + + /** Check if the given mask matches too many users according to the config, send an announcement if yes + * @param mask A mask to match against + * @param test The test that determines if a user matches the mask or not + * @param user A user whose nick will be included in the announcement if one is made + * @param bantype Type of the ban being set, will be used in the announcement if one is made + * @param confkey Name of the config key (inside the insane tag) which if false disables any checking + * @return True if the given mask matches too many users, false if not + */ + static bool MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey); +}; + /** Handle /ELINE. */ class CommandEline : public Command @@ -76,6 +120,12 @@ class CommandKline : public Command */ class CommandQline : public Command { + class NickMatcher : public InsaneBan::Matcher + { + public: + bool Check(User* user, const std::string& mask) const; + }; + public: /** Constructor for qline. */ @@ -94,6 +144,12 @@ class CommandQline : public Command */ class CommandZline : public Command { + class IPMatcher : public InsaneBan::Matcher + { + public: + bool Check(User* user, const std::string& mask) const; + }; + public: /** Constructor for zline. */