#include "inspircd.h"
#include "modules/regex.h"
+#include "modules/stats.h"
#include "xline.h"
static bool ZlineOnMatch = false;
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)
{
DefaultApply(u, "R", false);
}
- const std::string& Displayable()
+ const std::string& Displayable() CXX11_OVERRIDE
{
return matchtext;
}
/** 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)
{
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)
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
}
};
-class ModuleRLine : public Module
+class ModuleRLine : public Module, public Stats::EventListener
{
dynamic_reference<RegexFactory> rxfactory;
RLineFactory f;
public:
ModuleRLine()
- : rxfactory(this, "regex"), f(rxfactory), r(this, f)
+ : Stats::EventListener(this)
+ , rxfactory(this, "regex")
+ , f(rxfactory)
+ , r(this, f)
, initing(true)
{
}
}
}
- void Prioritize()
+ void Prioritize() CXX11_OVERRIDE
{
Module* mod = ServerInstance->Modules->Find("m_cgiirc.so");
ServerInstance->Modules->SetPriority(this, I_OnUserRegister, PRIORITY_AFTER, mod);