X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_filter.h;h=896c75dc25732b361c84d53b0c915fc3553680dd;hb=7c197db72eab03321e4f3e847054e13126520504;hp=ba52ce70b69345d4e47973149bddb8268b63608d;hpb=8982ea4cf5adc493340e602e2c3290210c7bf110;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index ba52ce70b..896c75dc2 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); @@ -221,12 +221,20 @@ int FilterBase::OnPreCommand(const std::string &command, const char** parameters if (command == "QUIT") { + /* QUIT with no reason: nothing to do */ + if (pcnt < 1) + return 0; + checkline = parameters[0]; replacepoint = 0; parting = false; } else if (command == "PART") { + /* PART with no reason: nothing to do */ + if (pcnt < 2) + return 0; + checkline = parameters[1]; replacepoint = 1; parting = true; @@ -276,7 +284,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())); @@ -290,7 +302,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) { } @@ -303,7 +315,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(); } @@ -311,10 +329,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; }