]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_rline.cpp
Rename User::fullname to realname and make it private.
[user/henk/code/inspircd.git] / src / modules / m_rline.cpp
index e77a00b6db313fb5dca924049508045edd8a91fd..bf6a64d84ce3398ff62d4d13575d54489b172a4a 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "inspircd.h"
 #include "modules/regex.h"
+#include "modules/stats.h"
 #include "xline.h"
 
 static bool ZlineOnMatch = false;
@@ -56,22 +57,23 @@ class RLine : public XLine
                delete regex;
        }
 
-       bool Matches(User *u)
+       bool Matches(User* u) CXX11_OVERRIDE
        {
                LocalUser* lu = IS_LOCAL(u);
                if (lu && lu->exempt)
                        return false;
 
-               std::string compare = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname;
-               return regex->Matches(compare);
+               const std::string host = u->nick + "!" + u->ident + "@" + u->GetRealHost() + " " + u->GetRealName();
+               const std::string ip = u->nick + "!" + u->ident + "@" + u->GetIPString() + " " + u->GetRealName();
+               return (regex->Matches(host) || regex->Matches(ip));
        }
 
-       bool Matches(const std::string &compare)
+       bool Matches(const std::string& compare) CXX11_OVERRIDE
        {
                return regex->Matches(compare);
        }
 
-       void Apply(User* u)
+       void Apply(User* u) CXX11_OVERRIDE
        {
                if (ZlineOnMatch)
                {
@@ -89,7 +91,7 @@ class RLine : public XLine
                DefaultApply(u, "R", false);
        }
 
-       const std::string& Displayable()
+       const std::string& Displayable() CXX11_OVERRIDE
        {
                return matchtext;
        }
@@ -112,7 +114,7 @@ class RLineFactory : public XLineFactory
 
        /** Generate a RLine
         */
-       XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask)
+       XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) CXX11_OVERRIDE
        {
                if (!rxfactory)
                {
@@ -138,7 +140,7 @@ class CommandRLine : public Command
                flags_needed = 'o'; this->syntax = "<regex> [<rline-duration>] :<reason>";
        }
 
-       CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
 
                if (parameters.size() >= 3)
@@ -196,7 +198,7 @@ class CommandRLine : public Command
                return CMD_SUCCESS;
        }
 
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                if (IS_LOCAL(user))
                        return ROUTE_LOCALONLY; // spanningtree will send ADDLINE
@@ -205,7 +207,7 @@ class CommandRLine : public Command
        }
 };
 
-class ModuleRLine : public Module
+class ModuleRLine : public Module, public Stats::EventListener
 {
        dynamic_reference<RegexFactory> rxfactory;
        RLineFactory f;
@@ -216,7 +218,10 @@ class ModuleRLine : public Module
 
  public:
        ModuleRLine()
-               : rxfactory(this, "regex"), f(rxfactory), r(this, f)
+               : Stats::EventListener(this)
+               , rxfactory(this, "regex")
+               , f(rxfactory)
+               , r(this, f)
                , initing(true)
        {
        }