]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #1271 from SaberUK/master+exemption
authorPeter Powell <petpow@saberuk.com>
Thu, 27 Jul 2017 12:13:16 +0000 (13:13 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Jul 2017 12:13:16 +0000 (13:13 +0100)
Move the OnCheckExemption hook out of the core.

21 files changed:
include/inspircd.h
include/modules/exemption.h [new file with mode: 0644]
src/coremods/core_channel/cmd_topic.cpp
src/coremods/core_channel/core_channel.cpp
src/coremods/core_channel/core_channel.h
src/helperfuncs.cpp
src/inspircd.cpp
src/modules/m_auditorium.cpp
src/modules/m_blockcaps.cpp
src/modules/m_blockcolor.cpp
src/modules/m_censor.cpp
src/modules/m_chanfilter.cpp
src/modules/m_exemptchanops.cpp
src/modules/m_messageflood.cpp
src/modules/m_nickflood.cpp
src/modules/m_noctcp.cpp
src/modules/m_nonicks.cpp
src/modules/m_nonotice.cpp
src/modules/m_repeat.cpp
src/modules/m_services_account.cpp
src/modules/m_stripcolor.cpp

index 303d24745664ef2936e7c145e4ad17b1cf24a809..a1a82899478d4a7bed1621aa29d6c50a75f287bb 100644 (file)
@@ -169,7 +169,6 @@ DEFINE_HANDLER1(IsNickHandler, bool, const std::string&);
 DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t);
 DEFINE_HANDLER1(IsIdentHandler, bool, const std::string&);
 DEFINE_HANDLER1(IsChannelHandler, bool, const std::string&);
-DEFINE_HANDLER3(OnCheckExemptionHandler, ModResult, User*, Channel*, const std::string&);
 
 /** The main class of the irc server.
  * This class contains instances of all the other classes in this software.
@@ -217,7 +216,6 @@ class CoreExport InspIRCd
 
        IsNickHandler HandleIsNick;
        IsIdentHandler HandleIsIdent;
-       OnCheckExemptionHandler HandleOnCheckExemption;
        IsChannelHandler HandleIsChannel;
        GenRandomHandler HandleGenRandom;
 
@@ -521,13 +519,6 @@ class CoreExport InspIRCd
         */
        InspIRCd(int argc, char** argv);
 
-       /** Called to check whether a channel restriction mode applies to a user
-        * @param User that is attempting some action
-        * @param Channel that the action is being performed on
-        * @param Action name
-        */
-       caller3<ModResult, User*, Channel*, const std::string&> OnCheckExemption;
-
        /** Prepare the ircd for restart or shutdown.
         * This function unloads all modules which can be unloaded,
         * closes all open sockets, and closes the logfile.
diff --git a/include/modules/exemption.h b/include/modules/exemption.h
new file mode 100644 (file)
index 0000000..2f4ee02
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2016-2017 Peter Powell <petpow@saberuk.com>
+ *
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "event.h"
+
+namespace CheckExemption
+{
+       class EventListener;
+       class EventProvider;
+}
+
+class CheckExemption::EventListener
+       : public Events::ModuleEventListener
+{
+ protected:
+       EventListener(Module* mod)
+               : ModuleEventListener(mod, "event/exemption")
+       {
+       }
+
+ public:
+       /** Called when checking if a user is exempt from something.
+        * @param user The user to check exemption for.
+        * @param chan The channel to check exemption on.
+        * @param restriction The restriction to check for.
+        * @return Either MOD_RES_ALLOW to confirm an exemption, MOD_RES_DENY to deny an exemption,
+        *         or MOD_RES_PASSTHRU to let another module handle the event.
+        */
+       virtual ModResult OnCheckExemption(User* user, Channel* chan, const std::string& restriction) = 0;
+};
+
+class CheckExemption::EventProvider
+       : public Events::ModuleEventProvider
+{
+ public:
+       EventProvider(Module* mod)
+               : ModuleEventProvider(mod, "event/exemption")
+       {
+       }
+};
index 6d99edcc6eeb1176880312bf2d7b0ee6cd3c21e5..ec6ed974490dadc4499eef374a140a9202c19af7 100644 (file)
@@ -25,6 +25,7 @@
 
 CommandTopic::CommandTopic(Module* parent)
        : SplitCommand(parent, "TOPIC", 1, 2)
+       , exemptionprov(parent)
        , secretmode(parent, "secret")
        , topiclockmode(parent, "topiclock")
 {
@@ -73,10 +74,15 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters,
                        user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!");
                        return CMD_FAILURE;
                }
-               if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE))
+               if (c->IsModeSet(topiclockmode))
                {
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel");
-                       return CMD_FAILURE;
+                       ModResult MOD_RESULT;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, MOD_RESULT, (user, c, "topiclock"));
+                       if (!MOD_RESULT.check(c->GetPrefixValue(user) >= HALFOP_VALUE))
+                       {
+                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel");
+                               return CMD_FAILURE;
+                       }
                }
        }
 
index 6fe6199dbd7ff321225797a2989a0ff036f128af..3af809645e8fbb4fa8110d4b4aa218ae18a0c27b 100644 (file)
@@ -22,7 +22,7 @@
 #include "invite.h"
 #include "listmode.h"
 
-class CoreModChannel : public Module
+class CoreModChannel : public Module, public CheckExemption::EventListener
 {
        Invite::APIImpl invapi;
        CommandInvite cmdinvite;
@@ -30,6 +30,7 @@ class CoreModChannel : public Module
        CommandKick cmdkick;
        CommandNames cmdnames;
        CommandTopic cmdtopic;
+       insp::flat_map<std::string, char> exemptions;
 
        ModResult IsInvited(User* user, Channel* chan)
        {
@@ -41,8 +42,13 @@ class CoreModChannel : public Module
 
  public:
        CoreModChannel()
-               : invapi(this)
-               , cmdinvite(this, invapi), cmdjoin(this), cmdkick(this), cmdnames(this), cmdtopic(this)
+               : CheckExemption::EventListener(this)
+               , invapi(this)
+               , cmdinvite(this, invapi)
+               , cmdjoin(this)
+               , cmdkick(this)
+               , cmdnames(this)
+               , cmdtopic(this)
        {
        }
 
@@ -57,6 +63,23 @@ class CoreModChannel : public Module
                        for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++)
                                ServerInstance->Modules.Detach(events[i], this);
                }
+
+               std::string current;
+               irc::spacesepstream defaultstream(optionstag->getString("exemptchanops"));
+               insp::flat_map<std::string, char> exempts;
+               while (defaultstream.GetToken(current))
+               {
+                       std::string::size_type pos = current.find(':');
+                       if (pos == std::string::npos || (pos + 2) > current.size())
+                               throw ModuleException("Invalid exemptchanops value '" + current + "' at " + optionstag->getTagLocation());
+
+                       const std::string restriction = current.substr(0, pos);
+                       const char prefix = current[pos + 1];
+
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Exempting prefix %c from %s", prefix, restriction.c_str());
+                       exempts[restriction] = prefix;
+               }
+               exemptions.swap(exempts);
        }
 
        void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
@@ -135,6 +158,22 @@ class CoreModChannel : public Module
                invapi.RemoveAll(chan);
        }
 
+       ModResult OnCheckExemption(User* user, Channel* chan, const std::string& restriction) CXX11_OVERRIDE
+       {
+               if (!exemptions.count(restriction))
+                       return MOD_RES_PASSTHRU;
+
+               unsigned int mypfx = chan->GetPrefixValue(user);
+               char minmode = exemptions[restriction];
+
+               PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(minmode);
+               if (mh && mypfx >= mh->GetPrefixRank())
+                       return MOD_RES_ALLOW;
+               if (mh || minmode == '*')
+                       return MOD_RES_DENY;
+               return MOD_RES_PASSTHRU;
+       }
+
        void Prioritize() CXX11_OVERRIDE
        {
                ServerInstance->Modules.SetPriority(this, I_OnPostJoin, PRIORITY_FIRST);
index 0dafde8cbcf278c001b5852a31482ec7ec94560e..19a98482767e84f7ad015e8940306b8532287c80 100644 (file)
@@ -20,6 +20,7 @@
 #pragma once
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 namespace Topic
 {
@@ -72,6 +73,7 @@ class CommandJoin : public SplitCommand
  */
 class CommandTopic : public SplitCommand
 {
+       CheckExemption::EventProvider exemptionprov;
        ChanModeReference secretmode;
        ChanModeReference topiclockmode;
 
index c9135679cfd0e8d6a31d4aeab4b484d1ee0685dd..8bb81481ef6807d3e22ada43f290c9db434388a4 100644 (file)
@@ -430,28 +430,3 @@ void GenRandomHandler::Call(char *output, size_t max)
                output[i] = random();
 #endif
 }
-
-ModResult OnCheckExemptionHandler::Call(User* user, Channel* chan, const std::string& restriction)
-{
-       unsigned int mypfx = chan->GetPrefixValue(user);
-       char minmode = 0;
-       std::string current;
-
-       irc::spacesepstream defaultstream(ServerInstance->Config->ConfValue("options")->getString("exemptchanops"));
-
-       while (defaultstream.GetToken(current))
-       {
-               std::string::size_type pos = current.find(':');
-               if (pos == std::string::npos)
-                       continue;
-               if (!current.compare(0, pos, restriction))
-                       minmode = current[pos+1];
-       }
-
-       PrefixMode* mh = ServerInstance->Modes->FindPrefixMode(minmode);
-       if (mh && mypfx >= mh->GetPrefixRank())
-               return MOD_RES_ALLOW;
-       if (mh || minmode == '*')
-               return MOD_RES_DENY;
-       return MOD_RES_PASSTHRU;
-}
index 0c9b67910be0635a3075daa8ce25d1cb77dcb7a7..5b9ee670ac7edd27f666edfc03814011190ad342 100644 (file)
@@ -230,8 +230,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
         GenRandom(&HandleGenRandom),
         IsChannel(&HandleIsChannel),
         IsNick(&HandleIsNick),
-        IsIdent(&HandleIsIdent),
-        OnCheckExemption(&HandleOnCheckExemption)
+        IsIdent(&HandleIsIdent)
 {
        ServerInstance = this;
 
index 6f9eeb2522dd833c60e2a1f23390b20c81f3d7aa..cd257eff3237ebb1c294e4fb0be881f6c80d9aa0 100644 (file)
@@ -21,6 +21,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 class AuditoriumMode : public SimpleChannelModeHandler
 {
@@ -33,13 +34,16 @@ class AuditoriumMode : public SimpleChannelModeHandler
 
 class ModuleAuditorium : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        AuditoriumMode aum;
        bool OpsVisible;
        bool OpsCanSee;
        bool OperCanSee;
 
  public:
-       ModuleAuditorium() : aum(this)
+       ModuleAuditorium()
+               : exemptionprov(this)
+               , aum(this)
        {
        }
 
@@ -62,7 +66,8 @@ class ModuleAuditorium : public Module
                if (!memb->chan->IsModeSet(&aum))
                        return true;
 
-               ModResult res = ServerInstance->OnCheckExemption(memb->user, memb->chan, "auditorium-vis");
+               ModResult res;
+               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (memb->user, memb->chan, "auditorium-vis"));
                return res.check(OpsVisible && memb->getRank() >= OP_VALUE);
        }
 
@@ -78,7 +83,8 @@ class ModuleAuditorium : public Module
                        return true;
 
                // Can you see the list by permission?
-               ModResult res = ServerInstance->OnCheckExemption(issuer,memb->chan,"auditorium-see");
+               ModResult res;
+               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (issuer, memb->chan, "auditorium-see"));
                if (res.check(OpsCanSee && memb->chan->GetPrefixValue(issuer) >= OP_VALUE))
                        return true;
 
index cd7698d69564d2104650e8710d701798d8c20ef2..6e67cb3095efc6c3610326553b0389ae2f172b1f 100644 (file)
@@ -21,6 +21,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 
 /** Handles the +B channel mode
@@ -33,13 +34,16 @@ class BlockCaps : public SimpleChannelModeHandler
 
 class ModuleBlockCAPS : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        BlockCaps bc;
        unsigned int percent;
        unsigned int minlen;
        char capsmap[256];
 
 public:
-       ModuleBlockCAPS() : bc(this)
+       ModuleBlockCAPS()
+               : exemptionprov(this)
+               , bc(this)
        {
        }
 
@@ -56,7 +60,8 @@ public:
                                return MOD_RES_PASSTHRU;
 
                        Channel* c = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcaps");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "blockcaps"));
 
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
index 567bdb24951e961f1ee304a9062ed6706faace86..7c961d96aab49f2bfd902d5e00dcac03638fd5f9 100644 (file)
@@ -22,6 +22,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 /** Handles the +c channel mode
  */
@@ -33,10 +34,13 @@ class BlockColor : public SimpleChannelModeHandler
 
 class ModuleBlockColor : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        BlockColor bc;
  public:
 
-       ModuleBlockColor() : bc(this)
+       ModuleBlockColor()
+               : exemptionprov(this)
+               , bc(this)
        {
        }
 
@@ -50,7 +54,8 @@ class ModuleBlockColor : public Module
                if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
                {
                        Channel* c = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"blockcolor");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "blockcolor"));
 
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
index d2a60275a8705ee43c101ee90fc9644a70e045cd..56639b2984f4352c8678000fc8704c887e4e0860 100644 (file)
@@ -21,6 +21,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 typedef insp::flat_map<irc::string, irc::string> censor_t;
 
@@ -42,12 +43,18 @@ class CensorChannel : public SimpleChannelModeHandler
 
 class ModuleCensor : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        censor_t censors;
        CensorUser cu;
        CensorChannel cc;
 
  public:
-       ModuleCensor() : cu(this), cc(this) { }
+       ModuleCensor()
+               : exemptionprov(this)
+               , cu(this)
+               , cc(this)
+       {
+       }
 
        // format of a config entry is <badword text="shit" replace="poo">
        ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
@@ -63,7 +70,8 @@ class ModuleCensor : public Module
                {
                        Channel* c = (Channel*)dest;
                        active = c->IsModeSet(cc);
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"censor");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "censor"));
 
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
index a7bc215570c221e54e6419ff2a623d55b8d99c33..b642cb9334c44e5250a80a59f8c7ed5487cbe989 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "inspircd.h"
 #include "listmode.h"
+#include "modules/exemption.h"
 
 /** Handles channel mode +g
  */
@@ -62,13 +63,15 @@ class ChanFilter : public ListModeBase
 
 class ModuleChanFilter : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        ChanFilter cf;
        bool hidemask;
 
  public:
 
        ModuleChanFilter()
-               : cf(this)
+               : exemptionprov(this)
+               , cf(this)
        {
        }
 
@@ -84,7 +87,8 @@ class ModuleChanFilter : public Module
                        return MOD_RES_PASSTHRU;
 
                Channel* chan = static_cast<Channel*>(dest);
-               ModResult res = ServerInstance->OnCheckExemption(user,chan,"filter");
+               ModResult res;
+               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, chan, "filter"));
 
                if (!IS_LOCAL(user) || res == MOD_RES_ALLOW)
                        return MOD_RES_PASSTHRU;
index 2884385fb6cec18b068640277791e928b56ee31c..0c67037f0ee01228f2b36e14ad9f1179c53d2d9f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "inspircd.h"
 #include "listmode.h"
+#include "modules/exemption.h"
 
 /** Handles channel mode +X
  */
@@ -68,11 +69,15 @@ class ExemptChanOps : public ListModeBase
        }
 };
 
-class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std::string&>
+class ExemptHandler : public CheckExemption::EventListener
 {
  public:
        ExemptChanOps ec;
-       ExemptHandler(Module* me) : ec(me) {}
+       ExemptHandler(Module* me)
+               : CheckExemption::EventListener(me)
+               , ec(me)
+       {
+       }
 
        PrefixMode* FindMode(const std::string& mid)
        {
@@ -83,7 +88,7 @@ class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std:
                return mh ? mh->IsPrefixMode() : NULL;
        }
 
-       ModResult Call(User* user, Channel* chan, const std::string& restriction)
+       ModResult OnCheckExemption(User* user, Channel* chan, const std::string& restriction) CXX11_OVERRIDE
        {
                unsigned int mypfx = chan->GetPrefixValue(user);
                std::string minmode;
@@ -108,7 +113,7 @@ class ExemptHandler : public HandlerBase3<ModResult, User*, Channel*, const std:
                if (mh || minmode == "*")
                        return MOD_RES_DENY;
 
-               return ServerInstance->HandleOnCheckExemption.Call(user, chan, restriction);
+               return MOD_RES_PASSTHRU;
        }
 };
 
@@ -121,16 +126,6 @@ class ModuleExemptChanOps : public Module
        {
        }
 
-       void init() CXX11_OVERRIDE
-       {
-               ServerInstance->OnCheckExemption = &eh;
-       }
-
-       ~ModuleExemptChanOps()
-       {
-               ServerInstance->OnCheckExemption = &ServerInstance->HandleOnCheckExemption;
-       }
-
        Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides the ability to allow channel operators to be exempt from certain modes.",VF_VENDOR);
index d89de49eb0d0802098e41adfdb840952dcfb2da4..9d119b6c37cfc679e52315670acddb443ae7f70e 100644 (file)
@@ -24,6 +24,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 /** Holds flood settings and state for mode +f
  */
@@ -103,12 +104,14 @@ class MsgFlood : public ParamMode<MsgFlood, SimpleExtItem<floodsettings> >
 
 class ModuleMsgFlood : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        MsgFlood mf;
 
  public:
 
        ModuleMsgFlood()
-               : mf(this)
+               : exemptionprov(this)
+               , mf(this)
        {
        }
 
@@ -121,7 +124,9 @@ class ModuleMsgFlood : public Module
                if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf))
                        return MOD_RES_PASSTHRU;
 
-               if (ServerInstance->OnCheckExemption(user,dest,"flood") == MOD_RES_ALLOW)
+               ModResult res;
+               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, dest, "flood"));
+               if (res == MOD_RES_ALLOW)
                        return MOD_RES_PASSTHRU;
 
                floodsettings *f = mf.ext.get(dest);
index abb3cdfafa4a1f4889cf103c3970a4d5802318f7..a4a87f6916d72a9722f7c3089239770593598036 100644 (file)
@@ -19,6 +19,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 // The number of seconds nickname changing will be blocked for.
 static unsigned int duration;
@@ -121,11 +122,13 @@ class NickFlood : public ParamMode<NickFlood, SimpleExtItem<nickfloodsettings> >
 
 class ModuleNickFlood : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        NickFlood nf;
 
  public:
        ModuleNickFlood()
-               : nf(this)
+               : exemptionprov(this)
+               , nf(this)
        {
        }
 
@@ -145,7 +148,7 @@ class ModuleNickFlood : public Module
                        nickfloodsettings *f = nf.ext.get(channel);
                        if (f)
                        {
-                               res = ServerInstance->OnCheckExemption(user,channel,"nickflood");
+                               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "nickflood"));
                                if (res == MOD_RES_ALLOW)
                                        continue;
 
@@ -184,7 +187,7 @@ class ModuleNickFlood : public Module
                        nickfloodsettings *f = nf.ext.get(channel);
                        if (f)
                        {
-                               res = ServerInstance->OnCheckExemption(user,channel,"nickflood");
+                               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "nickflood"));
                                if (res == MOD_RES_ALLOW)
                                        return;
 
index 49b53ee950f93af1eccfc93fede8f4f96b0e51e8..9dd9bf852d25e1dd3da1e4ed88079ad2f1aba315 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 class NoCTCP : public SimpleChannelModeHandler
 {
@@ -29,11 +30,13 @@ class NoCTCP : public SimpleChannelModeHandler
 
 class ModuleNoCTCP : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        NoCTCP nc;
 
  public:
        ModuleNoCTCP()
-               : nc(this)
+               : exemptionprov(this)
+               , nc(this)
        {
        }
 
@@ -50,7 +53,8 @@ class ModuleNoCTCP : public Module
                        if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ",8)))
                                return MOD_RES_PASSTHRU;
 
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"noctcp");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "noctcp"));
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
 
index d4da3e95139b251dc5f8b7add2321d5c55579c6c..c6de17e891e962e5ad3967daddb49c17d0254f33 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 class NoNicks : public SimpleChannelModeHandler
 {
@@ -29,10 +30,13 @@ class NoNicks : public SimpleChannelModeHandler
 
 class ModuleNoNickChange : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        NoNicks nn;
        bool override;
  public:
-       ModuleNoNickChange() : nn(this)
+       ModuleNoNickChange()
+               : exemptionprov(this)
+               , nn(this)
        {
        }
 
@@ -52,7 +56,8 @@ class ModuleNoNickChange : public Module
                {
                        Channel* curr = (*i)->chan;
 
-                       ModResult res = ServerInstance->OnCheckExemption(user,curr,"nonick");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, curr, "nonick"));
 
                        if (res == MOD_RES_ALLOW)
                                continue;
index 3d6d0bb099422808e9f8af07c8fe385e50fbc2db..ec5be951735ad68231ec059d1f62c8d48eb186b3 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 class NoNotice : public SimpleChannelModeHandler
 {
@@ -29,11 +30,13 @@ class NoNotice : public SimpleChannelModeHandler
 
 class ModuleNoNotice : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        NoNotice nt;
  public:
 
        ModuleNoNotice()
-               : nt(this)
+               : exemptionprov(this)
+               , nt(this)
        {
        }
 
@@ -50,7 +53,7 @@ class ModuleNoNotice : public Module
                        Channel* c = (Channel*)dest;
                        if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet(nt)))
                        {
-                               res = ServerInstance->OnCheckExemption(user,c,"nonotice");
+                               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "nonotice"));
                                if (res == MOD_RES_ALLOW)
                                        return MOD_RES_PASSTHRU;
                                else
index 21bca0f3fd323a537f3b22c9f64870534297c8c1..9715fcf6f8b05fa0c7df533a547d5b1f9f9e68ad 100644 (file)
@@ -18,6 +18,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 class ChannelSettings
 {
@@ -339,10 +340,15 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >
 
 class RepeatModule : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        RepeatMode rm;
 
  public:
-       RepeatModule() : rm(this) {}
+       RepeatModule()
+               : exemptionprov(this)
+               , rm(this)
+       {
+       }
 
        void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
@@ -363,7 +369,9 @@ class RepeatModule : public Module
                if (!memb)
                        return MOD_RES_PASSTHRU;
 
-               if (ServerInstance->OnCheckExemption(user, chan, "repeat") == MOD_RES_ALLOW)
+               ModResult res;
+               FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, chan, "repeat"));
+               if (res == MOD_RES_ALLOW)
                        return MOD_RES_PASSTHRU;
 
                if (rm.MatchLine(memb, settings, text))
index e97e1b02f82c60a2d8de790e8097051ae210256d..1ff206ed1427ad4f62c93ead86d1d2d54b04cd10 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "inspircd.h"
 #include "modules/account.h"
+#include "modules/exemption.h"
 
 /** Channel mode +r - mark a channel as identified
  */
@@ -139,6 +140,7 @@ class AccountExtItemImpl : public AccountExtItem
 
 class ModuleServicesAccount : public Module, public Whois::EventListener
 {
+       CheckExemption::EventProvider exemptionprov;
        AChannel_R m1;
        AChannel_M m2;
        AUser_R m3;
@@ -149,6 +151,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
  public:
        ModuleServicesAccount()
                : Whois::EventListener(this)
+               , exemptionprov(this)
                , m1(this), m2(this), m3(this), m4(this), m5(this)
                , accountname(this)
                , checking_ban(false)
@@ -196,7 +199,8 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
                if (target_type == TYPE_CHANNEL)
                {
                        Channel* c = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,c,"regmoderated");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, c, "regmoderated"));
 
                        if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW)
                        {
index 592aeda906407076a3262949331bd789e847abbc..6ad32bfc1010207530b46b36c976b3fa857f50ce 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "inspircd.h"
+#include "modules/exemption.h"
 
 /** Handles channel mode +S
  */
@@ -40,11 +41,15 @@ class UserStripColor : public SimpleUserModeHandler
 
 class ModuleStripColor : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        ChannelStripColor csc;
        UserStripColor usc;
 
  public:
-       ModuleStripColor() : csc(this), usc(this)
+       ModuleStripColor()
+               : exemptionprov(this)
+               , csc(this)
+               , usc(this)
        {
        }
 
@@ -67,7 +72,8 @@ class ModuleStripColor : public Module
                else if (target_type == TYPE_CHANNEL)
                {
                        Channel* t = (Channel*)dest;
-                       ModResult res = ServerInstance->OnCheckExemption(user,t,"stripcolor");
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, t, "stripcolor"));
 
                        if (res == MOD_RES_ALLOW)
                                return MOD_RES_PASSTHRU;
@@ -91,12 +97,13 @@ class ModuleStripColor : public Module
                if (!IS_LOCAL(user))
                        return;
 
-               bool active = channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc))
-                       && ServerInstance->OnCheckExemption(user, channel, "stripcolor") != MOD_RES_ALLOW;
-
-               if (active)
+               if (channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc)))
                {
-                       InspIRCd::StripColor(partmessage);
+                       ModResult res;
+                       FIRST_MOD_RESULT_CUSTOM(exemptionprov, CheckExemption::EventListener, OnCheckExemption, res, (user, channel, "stripcolor"));
+
+                       if (res != MOD_RES_ALLOW)
+                               InspIRCd::StripColor(partmessage);
                }
        }