summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-07-27 13:13:16 +0100
committerGitHub <noreply@github.com>2017-07-27 13:13:16 +0100
commitff3b706b2506d7614bce5e54bc88657bd62ebd4d (patch)
treedbfbe3df3df3668f0e1ac531229b4e15ff240754
parentbb4aa10ed82612624da45d0c9592ddf7f2f51ab5 (diff)
parent81027f3a0888ac4c8e3fb6ea90081492defce946 (diff)
Merge pull request #1271 from SaberUK/master+exemption
Move the OnCheckExemption hook out of the core.
-rw-r--r--include/inspircd.h9
-rw-r--r--include/modules/exemption.h58
-rw-r--r--src/coremods/core_channel/cmd_topic.cpp12
-rw-r--r--src/coremods/core_channel/core_channel.cpp45
-rw-r--r--src/coremods/core_channel/core_channel.h2
-rw-r--r--src/helperfuncs.cpp25
-rw-r--r--src/inspircd.cpp3
-rw-r--r--src/modules/m_auditorium.cpp12
-rw-r--r--src/modules/m_blockcaps.cpp9
-rw-r--r--src/modules/m_blockcolor.cpp9
-rw-r--r--src/modules/m_censor.cpp12
-rw-r--r--src/modules/m_chanfilter.cpp8
-rw-r--r--src/modules/m_exemptchanops.cpp23
-rw-r--r--src/modules/m_messageflood.cpp9
-rw-r--r--src/modules/m_nickflood.cpp9
-rw-r--r--src/modules/m_noctcp.cpp8
-rw-r--r--src/modules/m_nonicks.cpp9
-rw-r--r--src/modules/m_nonotice.cpp7
-rw-r--r--src/modules/m_repeat.cpp12
-rw-r--r--src/modules/m_services_account.cpp6
-rw-r--r--src/modules/m_stripcolor.cpp21
21 files changed, 220 insertions, 88 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 303d24745..a1a828994 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -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
index 000000000..2f4ee02fc
--- /dev/null
+++ b/include/modules/exemption.h
@@ -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")
+ {
+ }
+};
diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp
index 6d99edcc6..ec6ed9744 100644
--- a/src/coremods/core_channel/cmd_topic.cpp
+++ b/src/coremods/core_channel/cmd_topic.cpp
@@ -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;
+ }
}
}
diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp
index 6fe6199db..3af809645 100644
--- a/src/coremods/core_channel/core_channel.cpp
+++ b/src/coremods/core_channel/core_channel.cpp
@@ -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);
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index 0dafde8cb..19a984827 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -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;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index c9135679c..8bb81481e 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -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;
-}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 0c9b67910..5b9ee670a 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -230,8 +230,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
GenRandom(&HandleGenRandom),
IsChannel(&HandleIsChannel),
IsNick(&HandleIsNick),
- IsIdent(&HandleIsIdent),
- OnCheckExemption(&HandleOnCheckExemption)
+ IsIdent(&HandleIsIdent)
{
ServerInstance = this;
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp
index 6f9eeb252..cd257eff3 100644
--- a/src/modules/m_auditorium.cpp
+++ b/src/modules/m_auditorium.cpp
@@ -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;
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index cd7698d69..6e67cb309 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -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;
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index 567bdb249..7c961d96a 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -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;
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index d2a60275a..56639b298 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -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;
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index a7bc21557..b642cb933 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -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;
diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp
index 2884385fb..0c67037f0 100644
--- a/src/modules/m_exemptchanops.cpp
+++ b/src/modules/m_exemptchanops.cpp
@@ -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);
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index d89de49eb..9d119b6c3 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -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);
diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp
index abb3cdfaf..a4a87f691 100644
--- a/src/modules/m_nickflood.cpp
+++ b/src/modules/m_nickflood.cpp
@@ -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;
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index 49b53ee95..9dd9bf852 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -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;
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index d4da3e951..c6de17e89 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -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;
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index 3d6d0bb09..ec5be9517 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -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
diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp
index 21bca0f3f..9715fcf6f 100644
--- a/src/modules/m_repeat.cpp
+++ b/src/modules/m_repeat.cpp
@@ -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))
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index e97e1b02f..1ff206ed1 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -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)
{
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 592aeda90..6ad32bfc1 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -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);
}
}