aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_operchans.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2019-08-09 03:57:55 +0100
committerGravatar Sadie Powell2019-08-09 04:07:33 +0100
commit7c7de81b6d513330984bb328de7599bb1328f989 (patch)
tree1cd62b0d3419fcb93c488911f6ef8e5048f4bb99 /src/modules/m_operchans.cpp
parentMerge branch 'insp3' into master. (diff)
parentFix waitpong referring to registration timeouts as ping timeouts. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_operchans.cpp')
-rw-r--r--src/modules/m_operchans.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index d04ed4e5c..13a453515 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -40,9 +40,16 @@ class OperChans : public SimpleChannelModeHandler
class ModuleOperChans : public Module
{
+ private:
OperChans oc;
+ std::string space;
+ std::string underscore;
+
public:
- ModuleOperChans() : oc(this)
+ ModuleOperChans()
+ : oc(this)
+ , space(" ")
+ , underscore("_")
{
}
@@ -56,13 +63,27 @@ class ModuleOperChans : public Module
return MOD_RES_PASSTHRU;
}
- ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) override
+ ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) override
{
- if ((mask.length() > 2) && (mask[0] == 'O') && (mask[1] == ':'))
- {
- if (user->IsOper() && InspIRCd::Match(user->oper->name, mask.substr(2)))
- return MOD_RES_DENY;
- }
+ // Check whether the entry is an extban.
+ if (mask.length() <= 2 || mask[0] != 'O' || mask[1] != ':')
+ return MOD_RES_PASSTHRU;
+
+ // If the user is not an oper they can't match this.
+ if (!user->IsOper())
+ return MOD_RES_PASSTHRU;
+
+ // Check whether the oper's type matches the ban.
+ const std::string submask = mask.substr(2);
+ if (InspIRCd::Match(user->oper->name, submask))
+ return MOD_RES_DENY;
+
+ // If the oper's type contains spaces recheck with underscores.
+ std::string opername(user->oper->name);
+ stdalgo::string::replace_all(opername, space, underscore);
+ if (InspIRCd::Match(opername, submask))
+ return MOD_RES_DENY;
+
return MOD_RES_PASSTHRU;
}