- PCREFilter(pcre* r, const std::string &rea, const std::string &act, long gline_time, const std::string &pat, const std::string &flags)
- : FilterResult(pat, rea, act, gline_time, flags), regexp(r)
- {
- }
+ /** Create a R-Line.
+ * @param s_time The set time
+ * @param d The duration of the xline
+ * @param src The sender of the xline
+ * @param re The reason of the xline
+ * @param regex Pattern to match with
+ * @
+ */
+ RLine(time_t s_time, long d, std::string src, std::string re, std::string regexs, dynamic_reference<RegexFactory>& rxfactory)
+ : XLine(s_time, d, src, re, "R")
+ {
+ matchtext = regexs;
+
+ /* This can throw on failure, but if it does we DONT catch it here, we catch it and display it
+ * where the object is created, we might not ALWAYS want it to output stuff to snomask x all the time
+ */
+ regex = rxfactory->Create(regexs);
+ }
+
+ /** Destructor
+ */
+ ~RLine()
+ {
+ delete regex;
+ }
+
+ bool Matches(User *u)
+ {
+ 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);
+ }
+
+ bool Matches(const std::string &compare)
+ {
+ return regex->Matches(compare);
+ }
+
+ void Apply(User* u)
+ {
+ 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);
+ 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;
+ }
+ else
+ delete zl;
+ }
+ DefaultApply(u, "R", false);
+ }
+
+ const char* Displayable()
+ {
+ return matchtext.c_str();
+ }
+
+ std::string matchtext;