X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_filter.h;h=b31a032717a70a1472169356382320989efcd7c1;hb=7f00015727fab50e37de46aa90d218b31c852c87;hp=d21c8fc9cf3ef8f67e36451cc72a05cf6b4c694a;hpb=52c02f79a1bc7806b5a664031780d2e10e953db9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index d21c8fc9c..b31a03271 100644 --- a/src/modules/m_filter.h +++ b/src/modules/m_filter.h @@ -50,7 +50,7 @@ class FilterBase : public Module virtual void SendFilter(Module* proto, void* opaque, FilterResult* iter); virtual std::pair AddFilter(const std::string &freeform, const std::string &type, const std::string &reason, long duration) = 0; virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); - virtual void OnRehash(const std::string ¶meter); + virtual void OnRehash(userrec* user, const std::string ¶meter); virtual Version GetVersion(); std::string EncodeFilter(FilterResult* filter); FilterResult DecodeFilter(const std::string &data); @@ -96,9 +96,9 @@ class cmd_filter : public command_t std::string reason; long duration = 0; - if ((type != "gline") && (type != "none") && (type != "block") && (type != "kill")) + if ((type != "gline") && (type != "none") && (type != "block") && (type != "kill") && (type != "silent")) { - user->WriteServ("NOTICE %s :*** Invalid filter type '%s'. Supported types are 'gline', 'none', 'block', and 'kill'.", user->nick, freeform.c_str()); + user->WriteServ("NOTICE %s :*** Invalid filter type '%s'. Supported types are 'gline', 'none', 'block', 'silent' and 'kill'.", user->nick, freeform.c_str()); return CMD_FAILURE; } @@ -190,10 +190,13 @@ int FilterBase::OnUserPreNotice(userrec* user,void* dest,int target_type, std::s } if (f->action == "block") { - ServerInstance->WriteOpers(std::string("FILTER: ")+user->nick+" had their notice filtered, target was "+target+": "+f->reason); - user->WriteServ("NOTICE "+std::string(user->nick)+" :Your notice has been filtered and opers notified: "+f->reason); + ServerInstance->WriteOpers(std::string("FILTER: ")+user->nick+" had their message filtered, target was "+target+": "+f->reason); + user->WriteServ("NOTICE "+std::string(user->nick)+" :Your message has been filtered and opers notified: "+f->reason); + } + if (f->action == "silent") + { + user->WriteServ("NOTICE "+std::string(user->nick)+" :Your message has been filtered: "+f->reason); } - ServerInstance->Log(DEFAULT,"FILTER: "+std::string(user->nick)+std::string(" had their notice filtered, target was ")+target+": "+f->reason+" Action: "+f->action); if (f->action == "kill") { userrec::QuitUser(ServerInstance,user,"Filtered: "+f->reason); @@ -206,6 +209,8 @@ int FilterBase::OnUserPreNotice(userrec* user,void* dest,int target_type, std::s FOREACH_MOD(I_OnAddGLine,OnAddGLine(f->gline_time, NULL, f->reason, user->MakeHostIP())); } } + + ServerInstance->Log(DEFAULT,"FILTER: "+std::string(user->nick)+std::string(" had their message filtered, target was ")+target+": "+f->reason+" Action: "+f->action); return 1; } return 0; @@ -249,14 +254,10 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters /* PART or QUIT reason doesnt match a filter */ return 0; - ServerInstance->Log(DEBUG,"Match block text"); - /* We cant block a part or quit, so instead we change the reason to 'Reason filtered' */ command_t* c = ServerInstance->Parser->GetHandler(command); if (c) { - ServerInstance->Log(DEBUG,"Found handler"); - const char* params[127]; for (int item = 0; item < pcnt; item++) params[item] = parameters[item]; @@ -265,7 +266,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters /* We're blocking, OR theyre quitting and its a KILL action * (we cant kill someone whos already quitting, so filter them anyway) */ - if ((f->action == "block") || (((!parting) && (f->action == "kill")))) + if ((f->action == "block") || (((!parting) && (f->action == "kill"))) || (f->action == "silent")) { c->Handle(params, pcnt, user); return 1; @@ -284,7 +285,11 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters } if (f->action == "gline") { - if (ServerInstance->XLines->add_gline(f->gline_time, ServerInstance->Config->ServerName, f->reason.c_str(), user->MakeHostIP())) + /* Note: We gline *@IP so that if their host doesnt resolve the gline still applies. */ + std::string wild = "*@"; + wild.append(user->GetIPString()); + + if (ServerInstance->XLines->add_gline(f->gline_time, ServerInstance->Config->ServerName, f->reason.c_str(), wild.c_str())) { ServerInstance->XLines->apply_lines(APPLY_GLINES); FOREACH_MOD(I_OnAddGLine,OnAddGLine(f->gline_time, NULL, f->reason, user->MakeHostIP())); @@ -298,7 +303,7 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters return 0; } -void FilterBase::OnRehash(const std::string ¶meter) +void FilterBase::OnRehash(userrec* user, const std::string ¶meter) { } @@ -311,7 +316,13 @@ Version FilterBase::GetVersion() std::string FilterBase::EncodeFilter(FilterResult* filter) { std::ostringstream stream; - stream << filter->freeform << " " << filter->action << " " << filter->gline_time << " " << filter->reason; + std::string x = filter->freeform; + + for (std::string::iterator n = x.begin(); n != x.end(); n++) + if (*n == ' ') + *n = '\7'; + + stream << x << " " << filter->action << " " << filter->gline_time << " " << filter->reason; return stream.str(); } @@ -319,10 +330,16 @@ FilterResult FilterBase::DecodeFilter(const std::string &data) { FilterResult res; std::istringstream stream(data); + stream >> res.freeform; stream >> res.action; stream >> res.gline_time; res.reason = stream.str(); + + for (std::string::iterator n = res.freeform.begin(); n != res.freeform.end(); n++) + if (*n == '\7') + *n = ' '; + return res; }