From 8d20578991934d69e04011c950d742d720dd2421 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 27 Sep 2020 03:43:16 +0100 Subject: [PATCH 1/1] Add a shun option for cleaning problematic allowed commands. --- src/modules/m_shun.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 6be91ce67..307e6a694 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -154,6 +154,7 @@ class ModuleShun : public Module, public Stats::EventListener private: CommandShun cmd; ShunFactory shun; + insp::flat_set cleanedcommands; insp::flat_set enabledcommands; bool affectopers; bool allowtags; @@ -210,6 +211,11 @@ class ModuleShun : public Module, public Stats::EventListener { ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); + cleanedcommands.clear(); + irc::spacesepstream cleanedcmds(tag->getString("cleanedcommands", "AWAY PART QUIT")); + for (std::string cleanedcmd; cleanedcmds.GetToken(cleanedcmd); ) + cleanedcommands.insert(cleanedcmd); + enabledcommands.clear(); irc::spacesepstream enabledcmds(tag->getString("enabledcommands", "ADMIN OPER PING PONG QUIT", 1)); for (std::string enabledcmd; enabledcmds.GetToken(enabledcmd); ) @@ -244,18 +250,26 @@ class ModuleShun : public Module, public Stats::EventListener tag++; } } - if (command == "QUIT") - { - /* Allow QUIT but dont show any quit message */ - parameters.clear(); - } - else if ((command == "PART") && (parameters.size() > 1)) + + if (cleanedcommands.count(command)) { - /* same for PART */ - parameters.pop_back(); + if (command == "AWAY" && !parameters.empty()) + { + // Allow away but only for unsetting. + parameters.clear(); + } + else if (command == "PART" && parameters.size() > 1) + { + // Allow part but strip the message. + parameters.pop_back(); + } + else if (command == "QUIT" && !parameters.empty()) + { + // Allow quit but strip the message. + parameters.clear(); + } } - /* if we're here, allow the command. */ return MOD_RES_PASSTHRU; } -- 2.39.5