summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-08-24 13:40:15 +0100
committerPeter Powell <petpow@saberuk.com>2018-08-24 13:52:23 +0100
commit9d1b92d927028dfd89acb5c71f671c9d7f203494 (patch)
tree2b6abe395c73265d7e0f70f0862dc0a61f0a5fba /src
parent5a30926e2b3b54e1ee3562dea6119d9237814e9f (diff)
Improve the snotices sent out by the filter module.
- Switch to a module-specific snotice character (f). - Redo the format of the message to be easier to read and include the filter that the user matched. Closes #490. Closes #841.
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_filter.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 984a88559..2d0657c99 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -184,6 +184,7 @@ class ModuleFilter : public Module, public ServerEventListener, public Stats::Ev
ExemptTargetSet exemptednicks;
ModuleFilter();
+ void init() CXX11_OVERRIDE;
CullResult cull() CXX11_OVERRIDE;
ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE;
FilterResult* FilterMatch(User* user, const std::string &text, int flags);
@@ -213,7 +214,7 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters)
if (static_cast<ModuleFilter *>(me)->DeleteFilter(parameters[0]))
{
user->WriteNotice("*** Removed filter '" + parameters[0] + "'");
- ServerInstance->SNO->WriteToSnoMask(IS_LOCAL(user) ? 'a' : 'A', "FILTER: "+user->nick+" removed filter '"+parameters[0]+"'");
+ ServerInstance->SNO->WriteToSnoMask(IS_LOCAL(user) ? 'f' : 'F', "FILTER: "+user->nick+" removed filter '"+parameters[0]+"'");
return CMD_SUCCESS;
}
else
@@ -268,7 +269,7 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters)
(duration ? ", duration " + parameters[3] : "") + ", flags '" + flags + "', reason: '" +
parameters[reasonindex] + "'");
- ServerInstance->SNO->WriteToSnoMask(IS_LOCAL(user) ? 'a' : 'A', "FILTER: "+user->nick+" added filter '"+freeform+"', type '"+parameters[1]+"', "+(duration ? "duration "+parameters[3]+", " : "")+"flags '"+flags+"', reason: "+parameters[reasonindex]);
+ ServerInstance->SNO->WriteToSnoMask(IS_LOCAL(user) ? 'f' : 'F', "FILTER: "+user->nick+" added filter '"+freeform+"', type '"+parameters[1]+"', "+(duration ? "duration "+parameters[3]+", " : "")+"flags '"+flags+"', reason: "+parameters[reasonindex]);
return CMD_SUCCESS;
}
@@ -311,6 +312,11 @@ ModuleFilter::ModuleFilter()
{
}
+void ModuleFilter::init()
+{
+ ServerInstance->SNO->EnableSnomask('f', "FILTER");
+}
+
CullResult ModuleFilter::cull()
{
FreeFilters();
@@ -356,7 +362,8 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
}
if (f->action == FA_BLOCK)
{
- ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason);
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s had their message to %s filtered as it matched %s (%s)",
+ user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str()));
if (notifyuser)
{
if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
@@ -381,13 +388,15 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
}
else if (f->action == FA_KILL)
{
- ServerInstance->SNO->WriteGlobalSno('a', "FILTER: " + user->nick + " had their message filtered and was killed, target was " + target + ": " + f->reason);
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s was killed because their message to %s matched %s (%s)",
+ user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str()));
ServerInstance->Users->QuitUser(user, "Filtered: " + f->reason);
}
else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN")))
{
Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), user->GetIPString());
- ServerInstance->SNO->WriteGlobalSno('a', "FILTER: " + user->nick + " had their message filtered and was shunned, target was " + target + ": " + f->reason);
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s was shunned because their message to %s matched %s (%s)",
+ user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str()));
if (ServerInstance->XLines->AddLine(sh, NULL))
{
ServerInstance->XLines->ApplyLines();
@@ -398,7 +407,8 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
else if (f->action == FA_GLINE)
{
GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), "*", user->GetIPString());
- ServerInstance->SNO->WriteGlobalSno('a', "FILTER: " + user->nick + " had their message filtered and was G-Lined, target was " + target + ": " + f->reason);
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s was glined because their message to %s matched %s (%s)",
+ user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str()));
if (ServerInstance->XLines->AddLine(gl,NULL))
{
ServerInstance->XLines->ApplyLines();
@@ -472,7 +482,9 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
{
/* Note: We gline *@IP so that if their host doesnt resolve the gline still applies. */
GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), "*", user->GetIPString());
- ServerInstance->SNO->WriteGlobalSno('a', "FILTER: " + user->nick + " had their " + command + " message filtered and was G-Lined: " + f->reason);
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s was glined because their %s message matched %s (%s)",
+ user->nick.c_str(), command.c_str(), f->freeform.c_str(), f->reason.c_str()));
+
if (ServerInstance->XLines->AddLine(gl,NULL))
{
ServerInstance->XLines->ApplyLines();
@@ -484,7 +496,8 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params&
{
/* Note: We shun *!*@IP so that if their host doesnt resolve the shun still applies. */
Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName.c_str(), f->reason.c_str(), user->GetIPString());
- ServerInstance->SNO->WriteGlobalSno('a', "FILTER: " + user->nick + " had their " + command + " message filtered and was shunned: " + f->reason);
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s was shunned because their %s message matched %s (%s)",
+ user->nick.c_str(), command.c_str(), f->freeform.c_str(), f->reason.c_str()));
if (ServerInstance->XLines->AddLine(sh, NULL))
{
ServerInstance->XLines->ApplyLines();
@@ -533,9 +546,9 @@ void ModuleFilter::ReadConfig(ConfigStatus& status)
if (!RegexEngine)
{
if (newrxengine.empty())
- ServerInstance->SNO->WriteGlobalSno('a', "WARNING: No regex engine loaded - Filter functionality disabled until this is corrected.");
+ ServerInstance->SNO->WriteGlobalSno('f', "WARNING: No regex engine loaded - Filter functionality disabled until this is corrected.");
else
- ServerInstance->SNO->WriteGlobalSno('a', "WARNING: Regex engine '%s' is not loaded - Filter functionality disabled until this is corrected.", newrxengine.c_str());
+ ServerInstance->SNO->WriteGlobalSno('f', "WARNING: Regex engine '%s' is not loaded - Filter functionality disabled until this is corrected.", newrxengine.c_str());
initing = false;
FreeFilters();
@@ -544,7 +557,7 @@ void ModuleFilter::ReadConfig(ConfigStatus& status)
if ((!initing) && (RegexEngine.operator->() != factory))
{
- ServerInstance->SNO->WriteGlobalSno('a', "Dumping all filters due to regex engine change");
+ ServerInstance->SNO->WriteGlobalSno('f', "Dumping all filters due to regex engine change");
FreeFilters();
}