X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_rline.cpp;h=c1eeb7b9a792d3818bba2e87ffa9211d99802feb;hb=8ec9a73a91ad1c7009fd3055fbad7c980b5e1732;hp=e77a00b6db313fb5dca924049508045edd8a91fd;hpb=7851faac62d7a83c94cd5d37e0109b5d0a152bf9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index e77a00b6d..c1eeb7b9a 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -22,6 +22,7 @@ #include "inspircd.h" #include "modules/regex.h" +#include "modules/stats.h" #include "xline.h" static bool ZlineOnMatch = false; @@ -39,7 +40,7 @@ class RLine : public XLine * @param regex Pattern to match with * @ */ - RLine(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference& rxfactory) + RLine(time_t s_time, unsigned long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference& rxfactory) : XLine(s_time, d, src, re, "R") , matchtext(regexs) { @@ -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, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) CXX11_OVERRIDE { if (!rxfactory) { @@ -138,7 +140,7 @@ class CommandRLine : public Command flags_needed = 'o'; this->syntax = " [] :"; } - CmdResult Handle (const std::vector& 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& 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 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) { }