public:
pcre* regexp;
- PCREFilter(pcre* r, const std::string &rea, const std::string &act, long gline_time, const std::string &pat)
- : FilterResult::FilterResult(pat, rea, act, gline_time), regexp(r)
+ PCREFilter(pcre* r, const std::string &rea, const std::string &act, long gline_time, const std::string &pat, bool operex)
+ : FilterResult::FilterResult(pat, rea, act, gline_time, operex), regexp(r)
{
}
}
}
- virtual std::pair<bool, std::string> AddFilter(const std::string &freeform, const std::string &type, const std::string &reason, long duration)
+ virtual std::pair<bool, std::string> AddFilter(const std::string &freeform, const std::string &type, const std::string &reason, long duration, bool operexception)
{
for (std::vector<PCREFilter>::iterator i = filters.begin(); i != filters.end(); i++)
{
}
else
{
- filters.push_back(PCREFilter(re, reason, type, duration, freeform));
+ filters.push_back(PCREFilter(re, reason, type, duration, freeform, operexception));
return std::make_pair(true, "");
}
}
std::string pattern = MyConf.ReadValue("keyword", "pattern", index);
std::string reason = MyConf.ReadValue("keyword", "reason", index);
std::string action = MyConf.ReadValue("keyword", "action", index);
+ // = MyConf.ReadFlag("keyword", "flags")
+ bool operexception = false;
long gline_time = ServerInstance->Duration(MyConf.ReadValue("keyword", "duration", index).c_str());
re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL);
}
else
{
- filters.push_back(PCREFilter(re, reason, action, gline_time, pattern));
+ filters.push_back(PCREFilter(re, reason, action, gline_time, pattern, operexception));
ServerInstance->Log(DEFAULT,"Regular expression %s loaded.", pattern.c_str());
}
}
std::string reason;
std::string action;
long gline_time;
+ bool opers_exempt;
- FilterResult(const std::string free, const std::string &rea, const std::string &act, long gt) : freeform(free), reason(rea), action(act), gline_time(gt)
+ FilterResult(const std::string free, const std::string &rea, const std::string &act, long gt, bool operex = false) : freeform(free), reason(rea),
+ action(act), gline_time(gt), opers_exempt(operex)
{
}
virtual bool DeleteFilter(const std::string &freeform) = 0;
virtual void SyncFilters(Module* proto, void* opaque) = 0;
virtual void SendFilter(Module* proto, void* opaque, FilterResult* iter);
- virtual std::pair<bool, std::string> AddFilter(const std::string &freeform, const std::string &type, const std::string &reason, long duration) = 0;
+ virtual std::pair<bool, std::string> AddFilter(const std::string &freeform, const std::string &type, const std::string &reason, long duration, bool operexempt) = 0;
virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list);
virtual void OnRehash(userrec* user, const std::string ¶meter);
virtual Version GetVersion();
cmd_filter(FilterBase* f, InspIRCd* Me, const std::string &source) : command_t(Me, "FILTER", 'o', 1), Base(f)
{
this->source = source;
- this->syntax = "<filter-definition> <type> [<gline-duration>] :<reason>";
+ this->syntax = "<filter-definition> <type> <flags> [<gline-duration>] :<reason>";
}
CmdResult Handle(const char** parameters, int pcnt, userrec *user)
else
{
/* Adding a filter */
- if (pcnt >= 3)
+ if (pcnt >= 4)
{
std::string freeform = parameters[0];
std::string type = parameters[1];
+ std::string flags = parameters[2];
std::string reason;
long duration = 0;
+ bool operexempt = false;
+
+ for (std::string::const_iterator n = flags.begin(); n != flags.end(); ++n)
+ {
+ switch (*n)
+ {
+ case 'o':
+ operexempt = true;
+ break;
+ }
+ }
if ((type != "gline") && (type != "none") && (type != "block") && (type != "kill") && (type != "silent"))
{
if (type == "gline")
{
- if (pcnt >= 4)
+ if (pcnt >= 5)
{
- duration = ServerInstance->Duration(parameters[2]);
- reason = parameters[3];
+ duration = ServerInstance->Duration(parameters[3]);
+ reason = parameters[4];
}
else
{
}
else
{
- reason = parameters[2];
+ reason = parameters[3];
}
- std::pair<bool, std::string> result = Base->AddFilter(freeform, type, reason, duration);
+ std::pair<bool, std::string> result = Base->AddFilter(freeform, type, reason, duration, operexempt);
if (result.first)
{
user->WriteServ("NOTICE %s :*** Added filter '%s', type '%s'%s%s, reason: '%s'", user->nick, freeform.c_str(),
- type.c_str(), (duration ? " duration: " : ""), (duration ? parameters[2] : ""),
+ type.c_str(), (duration ? " duration: " : ""), (duration ? parameters[3] : ""),
reason.c_str());
return CMD_SUCCESS;
}
if (*n == ' ')
*n = '\7';
- stream << x << " " << filter->action << " " << filter->gline_time << " " << filter->reason;
+ stream << x << " " << filter->action << " " << filter->opers_exempt << " " << filter->gline_time << " " << filter->reason;
return stream.str();
}
stream >> res.freeform;
stream >> res.action;
+ stream >> res.opers_exempt;
stream >> res.gline_time;
res.reason = stream.str();
if ((target_type == TYPE_OTHER) && (extname == "filter"))
{
FilterResult data = DecodeFilter(extdata);
- this->AddFilter(data.freeform, data.action, data.reason, data.gline_time);
+ this->AddFilter(data.freeform, data.action, data.reason, data.gline_time, data.opers_exempt);
}
}