summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-02-27 20:32:22 +0000
committerSadie Powell <sadie@witchery.services>2024-02-27 20:33:43 +0000
commit5f735b2570979592f61c866396f11c169b3ffb85 (patch)
treecd35cb10239d4241aae061101bdd869667b71761
parent4ea2bc5e46cdca5fc791adb8397d025059037943 (diff)
Fix matching extbans on InspIRCd and implement missing matchers.
-rw-r--r--modules/protocol/inspircd20.cpp4
-rw-r--r--modules/protocol/inspircd3.cpp38
2 files changed, 37 insertions, 5 deletions
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 361d9bf6a..9dbaf69c0 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -139,7 +139,7 @@ namespace InspIRCdExtban
bool Matches(User *u, const Entry *e) anope_override
{
const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(3);
+ Anope::string real_mask = mask.substr(2);
return Entry(this->name, real_mask).Matches(u);
}
@@ -156,7 +156,7 @@ namespace InspIRCdExtban
{
const Anope::string &mask = e->GetMask();
- Anope::string channel = mask.substr(3);
+ Anope::string channel = mask.substr(2);
ChannelMode *cm = NULL;
if (channel[0] != '#')
diff --git a/modules/protocol/inspircd3.cpp b/modules/protocol/inspircd3.cpp
index 55bf50735..9c11f98c5 100644
--- a/modules/protocol/inspircd3.cpp
+++ b/modules/protocol/inspircd3.cpp
@@ -539,6 +539,12 @@ class InspIRCdAutoOpMode : public ChannelModeList
}
};
+// NOTE: matchers for the following extbans have not been implemented:
+//
+// * class(n): data not available
+// * country(G): data not available
+// * gateway(w): data not available in v3
+// * realmask(a): todo
class InspIRCdExtBan : public ChannelModeVirtual<ChannelModeList>
{
char ext;
@@ -577,7 +583,7 @@ namespace InspIRCdExtban
bool Matches(User *u, const Entry *e) anope_override
{
const Anope::string &mask = e->GetMask();
- Anope::string real_mask = mask.substr(3);
+ Anope::string real_mask = mask.substr(2);
return Entry(this->name, real_mask).Matches(u);
}
@@ -594,7 +600,7 @@ namespace InspIRCdExtban
{
const Anope::string &mask = e->GetMask();
- Anope::string channel = mask.substr(3);
+ Anope::string channel = mask.substr(2);
ChannelMode *cm = NULL;
if (channel[0] != '#')
@@ -694,6 +700,25 @@ namespace InspIRCdExtban
return !u->Account() && Entry("BAN", real_mask).Matches(u);
}
};
+
+ class OperTypeMatcher : public InspIRCdExtBan
+ {
+ public:
+ OperTypeMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c)
+ {
+ }
+
+ bool Matches(User *u, const Entry *e) anope_override
+ {
+ Anope::string *opertype = u->GetExt<Anope::string>("opertype");
+ if (!opertype)
+ return false; // Not an operator.
+
+ const Anope::string &mask = e->GetMask();
+ Anope::string real_mask = mask.substr(2);
+ return Anope::Match(opertype->replace_all_cs(' ', '_'), real_mask);
+ }
+ };
}
class ColonDelimitedParamMode : public ChannelModeParam
@@ -1012,7 +1037,10 @@ struct IRCDMessageCapab : Message::Capab
else if (mode.name.equals_cs("op"))
cm = new ChannelModeStatus("OP", mode.letter, mode.symbol, mode.level);
else if (mode.name.equals_cs("operonly"))
+ {
cm = new ChannelModeOperOnly("OPERONLY", mode.letter);
+ ModeManager::AddChannelMode(new InspIRCdExtban::OperTypeMatcher("OPERTYPEBAN", "BAN", 'O'));
+ }
else if (mode.name.equals_cs("operprefix"))
cm = new ChannelModeStatus("OPERPREFIX", mode.letter, mode.symbol, mode.level);
else if (mode.name.equals_cs("permanent"))
@@ -1702,7 +1730,9 @@ struct IRCDMessageNick : IRCDMessage
struct IRCDMessageOperType : IRCDMessage
{
- IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
+ PrimitiveExtensibleItem<Anope::string> opertype;
+
+ IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 1), opertype(creator, "opertype") { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
@@ -1711,6 +1741,8 @@ struct IRCDMessageOperType : IRCDMessage
User *u = source.GetUser();
if (!u->HasMode("OPER"))
u->SetModesInternal(source, "+o");
+
+ opertype.Set(u, params[0]);
}
};