]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_rline.cpp
Fix disabling the GeoIP extban in m_geoip.
[user/henk/code/inspircd.git] / src / modules / m_rline.cpp
index 0bfdc35653b9229cd5dd7755a94eef02902a605c..9bb1167f51810caad7d410989dc97e616a794d79 100644 (file)
@@ -56,29 +56,30 @@ 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->fullname;
+               const std::string ip = u->nick + "!" + u->ident + "@" + u->GetIPString() + " " + u->fullname;
+               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)
                {
                        ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString());
                        if (ServerInstance->XLines->AddLine(zl, NULL))
                        {
-                               std::string timestr = ServerInstance->TimeString(zl->expiry);
+                               std::string timestr = InspIRCd::TimeString(zl->expiry);
                                ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on *@%s%s%s: %s",
                                        zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? timestr.c_str() : "", zl->reason.c_str());
                                added_zline = true;
@@ -89,7 +90,7 @@ class RLine : public XLine
                DefaultApply(u, "R", false);
        }
 
-       const std::string& Displayable()
+       const std::string& Displayable() CXX11_OVERRIDE
        {
                return matchtext;
        }
@@ -112,7 +113,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 +139,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(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
        {
 
                if (parameters.size() >= 3)
@@ -154,7 +155,7 @@ class CommandRLine : public Command
                        }
                        catch (ModuleException &e)
                        {
-                               ServerInstance->SNO->WriteToSnoMask('a',"Could not add RLINE: %s", e.GetReason());
+                               ServerInstance->SNO->WriteToSnoMask('a',"Could not add RLINE: " + e.GetReason());
                        }
 
                        if (r)
@@ -168,7 +169,7 @@ class CommandRLine : public Command
                                        else
                                        {
                                                time_t c_requires_crap = duration + ServerInstance->Time();
-                                               std::string timestr = ServerInstance->TimeString(c_requires_crap);
+                                               std::string timestr = InspIRCd::TimeString(c_requires_crap);
                                                ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s to expire on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str());
                                        }
 
@@ -196,7 +197,7 @@ class CommandRLine : public Command
                return CMD_SUCCESS;
        }
 
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE
        {
                if (IS_LOCAL(user))
                        return ROUTE_LOCALONLY; // spanningtree will send ADDLINE
@@ -284,12 +285,12 @@ class ModuleRLine : public Module
                initing = false;
        }
 
-       ModResult OnStats(char symbol, User* user, string_list &results) CXX11_OVERRIDE
+       ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE
        {
-               if (symbol != 'R')
+               if (stats.GetSymbol() != 'R')
                        return MOD_RES_PASSTHRU;
 
-               ServerInstance->XLines->InvokeStats("R", 223, user, results);
+               ServerInstance->XLines->InvokeStats("R", 223, stats);
                return MOD_RES_DENY;
        }
 
@@ -333,7 +334,7 @@ class ModuleRLine : public Module
                }
        }
 
-       void Prioritize()
+       void Prioritize() CXX11_OVERRIDE
        {
                Module* mod = ServerInstance->Modules->Find("m_cgiirc.so");
                ServerInstance->Modules->SetPriority(this, I_OnUserRegister, PRIORITY_AFTER, mod);