diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-11-10 17:04:06 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-11-10 17:04:06 +0000 |
commit | 6692d15462003157768a15c86192399b5b73e3c2 (patch) | |
tree | 9384ea59f85dfddb5bc372d067b0022b24883948 | |
parent | 74d2f929455e316ab69fcf620b7f9bc792f5e716 (diff) |
Add gline type, and <filter:duration> value to say how long to ban for.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5666 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/extra/m_filter_pcre.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.h | 14 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 48 |
4 files changed, 54 insertions, 27 deletions
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index 5df48cb05..e03d27b59 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -37,8 +37,8 @@ class PCREFilter : public FilterResult public: pcre* regexp; - PCREFilter(pcre* r, const std::string &rea, const std::string &act) - : FilterResult::FilterResult(rea, act), regexp(r) + PCREFilter(pcre* r, const std::string &rea, const std::string &act, long gline_time) + : FilterResult::FilterResult(rea, act, gline_time), regexp(r) { } }; @@ -86,12 +86,13 @@ class ModuleFilterPCRE : public FilterBase for (int index = 0; index < MyConf.Enumerate("keyword"); index++) { - std::string pattern = MyConf.ReadValue("keyword","pattern",index); - std::string reason = MyConf.ReadValue("keyword","reason",index); - std::string action = MyConf.ReadValue("keyword","action",index); - + std::string pattern = MyConf.ReadValue("keyword", "pattern", index); + std::string reason = MyConf.ReadValue("keyword", "reason", index); + std::string action = MyConf.ReadValue("keyword", "action", index); + long gline_time = ServerInstance->Duration(MyConf.ReadValue("keyword", "duration", index).c_str()); + re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL); - + if (!re) { ServerInstance->Log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error); @@ -99,7 +100,7 @@ class ModuleFilterPCRE : public FilterBase } else { - filters.push_back(PCREFilter(re, reason, action)); + filters.push_back(PCREFilter(re, reason, action, gline_time)); ServerInstance->Log(DEFAULT,"Regular expression %s loaded.", pattern.c_str()); } } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 38b2ee7e1..97cc8af5f 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -81,11 +81,13 @@ class ModuleFilter : public FilterBase std::string pattern = MyConf->ReadValue("keyword","pattern",index); std::string reason = MyConf->ReadValue("keyword","reason",index); std::string do_action = MyConf->ReadValue("keyword","action",index); + long gline_time = ServerInstance->Duration(MyConf->ReadValue("keyword","duration",index).c_str()); if (do_action == "") do_action = "none"; FilterResult* x = new FilterResult; x->reason = reason; x->action = do_action; + x->gline_time = gline_time; filters[pattern] = x; } DELETE(MyConf); diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index 34e3d2513..b2c3816a8 100644 --- a/src/modules/m_filter.h +++ b/src/modules/m_filter.h @@ -14,13 +14,16 @@ * --------------------------------------------------- */ +#include "xline.h" + class FilterResult : public classbase { public: std::string reason; std::string action; + long gline_time; - FilterResult(const std::string &rea, const std::string &act) : reason(rea), action(act) + FilterResult(const std::string &rea, const std::string &act, long gt) : reason(rea), action(act), gline_time(gt) { } @@ -85,6 +88,15 @@ class FilterBase : public Module { userrec::QuitUser(ServerInstance,user,f->reason); } + + if (f->action == "gline") + { + if (ServerInstance->XLines->add_gline(f->gline_time, ServerInstance->Config->ServerName, f->reason.c_str(), user->MakeHostIP())) + { + ServerInstance->XLines->apply_lines(APPLY_GLINES); + FOREACH_MOD(I_OnAddGLine,OnAddGLine(f->gline_time, NULL, f->reason, user->MakeHostIP())); + } + } return 1; } return 0; diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 87b803600..d9bb93e3e 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -4932,26 +4932,38 @@ class ModuleSpanningTree : public Module void OnLine(userrec* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason) { - if (IS_LOCAL(source)) + if (!source) { - char type[8]; - snprintf(type,8,"%cLINE",linetype); - std::string stype = type; - if (adding) - { - char sduration[MAXBUF]; - snprintf(sduration,MAXBUF,"%ld",duration); - std::deque<std::string> params; - params.push_back(host); - params.push_back(sduration); - params.push_back(":"+reason); - Utils->DoOneToMany(source->nick,stype,params); - } - else + /* Server-set lines */ + char data[MAXBUF]; + snprintf(data,MAXBUF,"%c %s %s %lu %lu :%s", linetype, host.c_str(), ServerInstance->Config->ServerName, ServerInstance->Time(false), duration, reason.c_str()); + std::deque<std::string> params; + params.push_back(data); + Utils->DoOneToMany(ServerInstance->Config->ServerName, "ADDLINE", params); + } + else + { + if (IS_LOCAL(source)) { - std::deque<std::string> params; - params.push_back(host); - Utils->DoOneToMany(source->nick,stype,params); + char type[8]; + snprintf(type,8,"%cLINE",linetype); + std::string stype = type; + if (adding) + { + char sduration[MAXBUF]; + snprintf(sduration,MAXBUF,"%ld",duration); + std::deque<std::string> params; + params.push_back(host); + params.push_back(sduration); + params.push_back(":"+reason); + Utils->DoOneToMany(source->nick,stype,params); + } + else + { + std::deque<std::string> params; + params.push_back(host); + Utils->DoOneToMany(source->nick,stype,params); + } } } } |