diff options
-rw-r--r-- | docs/conf/inspircd.conf.example | 23 | ||||
-rw-r--r-- | include/listmode.h | 14 | ||||
-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 |
10 files changed, 60 insertions, 33 deletions
diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example index 713dc0cb8..91a0bdb15 100644 --- a/docs/conf/inspircd.conf.example +++ b/docs/conf/inspircd.conf.example @@ -498,18 +498,27 @@ #<pid file="/path/to/inspircd.pid"> -#-#-#-#-#-#-#-#-#-#-#-#-#- BANLIST LIMITS #-#-#-#-#-#-#-#-#-#-#-#-#-#-# +#-#-#-#-#-#-#-#-#-#-#-#-#- LIST MODE LIMITS #-#-#-#-#-#-#-#-#-#-#-#-#-# # # -# Use these tags to customise the ban limits on a per channel basis. # -# The tags are read from top to bottom, and any tag found which # -# matches the channels name applies the banlimit to that channel. # +# The <maxlist> tag is used customise the maximum number of each list # +# mode that can be set on a channel. # +# The tags are read from top to bottom and the list mode limit from # +# the first tag found which matches the channel name and mode type is # +# applied to that channel. # # It is advisable to put an entry with the channel as '*' at the # -# bottom of the list. If none are specified or no maxbans tag is # +# bottom of the list. If none are specified or no maxlist tag is # # matched, the banlist size defaults to 100 entries. # # # -<banlist chan="#largechan" limit="200"> -<banlist chan="*" limit="100"> +# Allows #largechan to have up to 200 ban entries. +#<maxlist mode="ban" chan="#largechan" limit="200"> + +# Allows #largechan to have up to 200 invex entries. +#<maxlist mode="e" chan="#largechan" limit="200"> + +# Allows all channels and list modes not previously matched to have +# up to 100 entries. +<maxlist chan="*" limit="100"> #-#-#-#-#-#-#-#-#-#-#- DISABLED FEATURES -#-#-#-#-#-#-#-#-#-#-#-#-#-# # # diff --git a/include/listmode.h b/include/listmode.h index 5eb77538f..febef0bd2 100644 --- a/include/listmode.h +++ b/include/listmode.h @@ -86,20 +86,21 @@ class CoreExport ListModeBase : public ModeHandler /** Numeric to use when outputting the list */ unsigned int listnumeric; + /** Numeric to indicate end of list */ unsigned int endoflistnumeric; + /** String to send for end of list */ std::string endofliststring; + /** Automatically tidy up entries */ bool tidy; - /** Config tag to check for max items per channel - */ - std::string configtag; - /** Limits on a per-channel basis read from the tag - * specified in ListModeBase::configtag + + /** Limits on a per-channel basis read from the <listmode> + * config tag. */ limitlist chanlimits; @@ -116,9 +117,8 @@ class CoreExport ListModeBase : public ModeHandler * @param lnum List numeric * @param eolnum End of list numeric * @param autotidy Automatically tidy list entries on add - * @param ctag Configuration tag to get limits from */ - 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 = "banlist"); + ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string& eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy); /** Get limit of this mode on a channel * @param channel The channel to inspect 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 |