]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_shun.cpp
Optimize some behaviour in the core (#1476).
[user/henk/code/inspircd.git] / src / modules / m_shun.cpp
index d68f58dd463657d3d27a3057bfb5f5accaec4afc..92c0b0bd0d36b1a2f01e042d8af254aa734c8d6b 100644 (file)
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/shun.h"
+#include "modules/stats.h"
 
-class Shun : public XLine
-{
-public:
-       std::string matchtext;
-
-       Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask)
-               : XLine(s_time, d, src, re, "SHUN")
-               , matchtext(shunmask)
-       {
-       }
-
-       bool Matches(User* u) CXX11_OVERRIDE
-       {
-               // E: overrides shun
-               LocalUser* lu = IS_LOCAL(u);
-               if (lu && lu->exempt)
-                       return false;
-
-               if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext))
-                       return true;
-
-               if (InspIRCd::MatchCIDR(u->GetIPString(), matchtext, ascii_case_insensitive_map))
-                       return true;
-
-               return false;
-       }
-
-       bool Matches(const std::string& s) CXX11_OVERRIDE
-       {
-               if (matchtext == s)
-                       return true;
-               return false;
-       }
-
-       const std::string& Displayable() CXX11_OVERRIDE
-       {
-               return matchtext;
-       }
-};
 
 /** An XLineFactory specialized to generate shun pointers
  */
@@ -171,7 +134,7 @@ class CommandShun : public Command
        }
 };
 
-class ModuleShun : public Module
+class ModuleShun : public Module, public Stats::EventListener
 {
        CommandShun cmd;
        ShunFactory f;
@@ -180,7 +143,9 @@ class ModuleShun : public Module
        bool affectopers;
 
  public:
-       ModuleShun() : cmd(this)
+       ModuleShun()
+               : Stats::EventListener(this)
+               , cmd(this)
        {
        }