diff options
author | Peter Powell <petpow@saberuk.com> | 2018-12-19 09:02:09 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-12-19 09:02:09 +0000 |
commit | 36da0833c5512a72cbf500a2f5faef5a26ed8dae (patch) | |
tree | 1ed37a2bb3f768ec7f48aec31aa0ddc5c95956a1 /src | |
parent | 4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (diff) |
Add the <maxlist> tag and switch ListModeBase to always use it.
The old method of doing this was:
1. Extremely inconsistently used. Some list modes used <banlist>
and some used their own config tag.
2. Not documented in the slightest. There was a small reference to
<maxbans> for the ban mode but nothing else.
3. In some cases conflicting with other config tags. The chanfilter
module defined a <chanfilter> tag for general config whilst also
using it for the max list settings.
The new <maxlist> tag avoids these issues entirely.
Diffstat (limited to 'src')
-rw-r--r-- | src/coremods/core_channel/core_channel.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_channel/core_channel.h | 2 | ||||
-rw-r--r-- | src/listmode.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_autoop.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_banexception.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_chanfilter.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_exemptchanops.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_inviteexception.cpp | 5 |
8 files changed, 37 insertions, 19 deletions
diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp index 76e220765..bf51bd4b2 100644 --- a/src/coremods/core_channel/core_channel.cpp +++ b/src/coremods/core_channel/core_channel.cpp @@ -181,7 +181,7 @@ class CoreModChannel : public Module, public CheckExemption::EventListener // Config is valid, apply it - // Validates and applies <banlist> tags, so do it first + // Validates and applies <maxlist> tags, so do it first banmode.DoRehash(); exemptions.swap(exempts); diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h index 59a417790..6e11275df 100644 --- a/src/coremods/core_channel/core_channel.h +++ b/src/coremods/core_channel/core_channel.h @@ -164,7 +164,7 @@ class ModeChannelBan : public ListModeBase { public: ModeChannelBan(Module* Creator) - : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true, "maxbans") + : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true) { } }; diff --git a/src/listmode.cpp b/src/listmode.cpp index 6b5fb13c5..c11790aea 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -19,10 +19,12 @@ #include "inspircd.h" #include "listmode.h" -ListModeBase::ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string &eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy, const std::string &ctag) - : ModeHandler(Creator, Name, modechar, PARAM_ALWAYS, MODETYPE_CHANNEL, MC_LIST), - listnumeric(lnum), endoflistnumeric(eolnum), endofliststring(eolstr), tidy(autotidy), - configtag(ctag) +ListModeBase::ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string& eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy) + : ModeHandler(Creator, Name, modechar, PARAM_ALWAYS, MODETYPE_CHANNEL, MC_LIST) + , listnumeric(lnum) + , endoflistnumeric(eolnum) + , endofliststring(eolstr) + , tidy(autotidy) , extItem("listbase_mode_" + name + "_list", ExtensionItem::EXT_CHANNEL, Creator) { list = true; @@ -60,21 +62,23 @@ void ListModeBase::RemoveMode(Channel* channel, Modes::ChangeList& changelist) void ListModeBase::DoRehash() { - ConfigTagList tags = ServerInstance->Config->ConfTags(configtag); - + ConfigTagList tags = ServerInstance->Config->ConfTags("maxlist"); limitlist newlimits; - for (ConfigIter i = tags.first; i != tags.second; i++) { - // For each <banlist> tag ConfigTag* c = i->second; - ListLimit limit(c->getString("chan"), c->getUInt("limit", 0)); + + const std::string mname = c->getString("mode"); + if (!mname.empty() && !stdalgo::string::equalsci(mname, name) && !(mname.length() == 1 && GetModeChar() == mname[0])) + continue; + + ListLimit limit(c->getString("chan", "*"), c->getUInt("limit", 0)); if (limit.mask.empty()) - throw ModuleException(InspIRCd::Format("<%s:chan> is empty at %s", configtag.c_str(), c->getTagLocation().c_str())); + throw ModuleException(InspIRCd::Format("<maxlist:chan> is empty, at %s", c->getTagLocation().c_str())); if (limit.limit <= 0) - throw ModuleException(InspIRCd::Format("<%s:limit> must be greater than 0, at %s", configtag.c_str(), c->getTagLocation().c_str())); + throw ModuleException(InspIRCd::Format("<maxlist:limit> must be non-zero, at %s", c->getTagLocation().c_str())); newlimits.push_back(limit); } diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp index a09d0d9e4..ffad7e0f1 100644 --- a/src/modules/m_autoop.cpp +++ b/src/modules/m_autoop.cpp @@ -26,7 +26,8 @@ class AutoOpList : public ListModeBase { public: - AutoOpList(Module* Creator) : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", 910, 911, true) + AutoOpList(Module* Creator) + : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", 910, 911, true) { ranktoset = ranktounset = OP_VALUE; tidy = false; diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp index 3905cdf6a..d9ceeaab1 100644 --- a/src/modules/m_banexception.cpp +++ b/src/modules/m_banexception.cpp @@ -38,7 +38,10 @@ class BanException : public ListModeBase { public: - BanException(Module* Creator) : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", 348, 349, true) { } + BanException(Module* Creator) + : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", 348, 349, true) + { + } }; diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 42f43a767..051b8c60d 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -34,7 +34,10 @@ class ChanFilter : public ListModeBase public: unsigned long maxlen; - ChanFilter(Module* Creator) : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false, "chanfilter") { } + ChanFilter(Module* Creator) + : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false) + { + } bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE { diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index 058a16e6c..a7f86cdb5 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -26,9 +26,13 @@ class ExemptChanOps : public ListModeBase { public: - ExemptChanOps(Module* Creator) : ListModeBase(Creator, "exemptchanops", 'X', "End of channel exemptchanops list", 954, 953, false, "exemptchanops") { } + ExemptChanOps(Module* Creator) + : ListModeBase(Creator, "exemptchanops", 'X', "End of channel exemptchanops list", 954, 953, false) + { + } - bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE { + bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE + { std::string::size_type p = word.find(':'); if (p == std::string::npos) { diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp index bae8f7184..3f9459d19 100644 --- a/src/modules/m_inviteexception.cpp +++ b/src/modules/m_inviteexception.cpp @@ -39,7 +39,10 @@ class InviteException : public ListModeBase { public: - InviteException(Module* Creator) : ListModeBase(Creator, "invex", 'I', "End of Channel Invite Exception List", 346, 347, true) { } + InviteException(Module* Creator) + : ListModeBase(Creator, "invex", 'I', "End of Channel Invite Exception List", 346, 347, true) + { + } }; class ModuleInviteException : public Module |