X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_filter.cpp;h=34d0bebb3cce91d865a14cde6f912b69ee4175b6;hb=9d72ec55ae98960bf996dd3d92c29598a5e3c825;hp=e594160f497f002b37b15512e4f851843028aa9b;hpb=07c783c8b043f482b86912b816fdd9db3c41539c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index e594160f4..34d0bebb3 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -156,7 +156,7 @@ class CommandFilter : public Command class ModuleFilter : public Module { - typedef std::set ExemptTargetSet; + typedef insp::flat_set ExemptTargetSet; bool initing; RegexFactory* factory; @@ -172,6 +172,9 @@ class ModuleFilter : public Module // List of channel names excluded from filtering. ExemptTargetSet exemptedchans; + // List of target nicknames excluded from filtering. + ExemptTargetSet exemptednicks; + ModuleFilter(); CullResult cull(); ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; @@ -322,6 +325,10 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type if (target_type == TYPE_USER) { User* t = (User*)dest; + // Check if the target nick is exempted, if yes, ignore this message + if (exemptednicks.count(t->nick)) + return MOD_RES_PASSTHRU; + target = t->nick; } else if (target_type == TYPE_CHANNEL) @@ -370,7 +377,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) { - if (validated && IS_LOCAL(user)) + if (validated) { flags = 0; bool parting; @@ -444,11 +451,21 @@ void ModuleFilter::ReadConfig(ConfigStatus& status) { ConfigTagList tags = ServerInstance->Config->ConfTags("exemptfromfilter"); exemptedchans.clear(); + exemptednicks.clear(); + for (ConfigIter i = tags.first; i != tags.second; ++i) { - std::string chan = i->second->getString("channel"); - if (!chan.empty()) - exemptedchans.insert(chan); + ConfigTag* tag = i->second; + + // If "target" is not found, try the old "channel" key to keep compatibility with 2.0 configs + const std::string target = tag->getString("target", tag->getString("channel")); + if (!target.empty()) + { + if (target[0] == '#') + exemptedchans.insert(target); + else + exemptednicks.insert(target); + } } std::string newrxengine = ServerInstance->Config->ConfValue("filteropts")->getString("engine"); @@ -688,6 +705,10 @@ ModResult ModuleFilter::OnStats(char symbol, User* user, string_list &results) { results.push_back("223 "+user->nick+" :EXEMPT "+(*i)); } + for (ExemptTargetSet::const_iterator i = exemptednicks.begin(); i != exemptednicks.end(); ++i) + { + results.push_back("223 "+user->nick+" :EXEMPT "+(*i)); + } } return MOD_RES_PASSTHRU; }