diff --git a/docs/conf/inspircd.example.conf b/docs/conf/inspircd.example.conf index 0b229cb99..db4f3f4cc 100644 --- a/docs/conf/inspircd.example.conf +++ b/docs/conf/inspircd.example.conf @@ -665,9 +665,13 @@ # %type% - The type of X-line which was matched. xlinequit="%fulltype%: %reason%" - # modesinlist: If enabled then the current channel modes will be shown - # in the /LIST response. Defaults to yes. - modesinlist="no" + # modesinlist: Whether to show the current channel modes in the /LIST + # output. Can be set to any one of: + # - yes Show the current channel modes to all users. + # - opers Show the current channel modes to server operators with the + # channels/auspex privilege. This is the default. + # - no Do not show the current channel modes in /LIST. + modesinlist="opers" # extbanformat: The method to use for normalising extbans. Can be set # to one of: diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 7d88c93c3..ec242ea36 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -27,6 +27,14 @@ #include "inspircd.h" #include "modules/isupport.h" +enum class ShowModes + : uint8_t +{ + NOBODY, + OPERS, + ALL, +}; + class CommandList final : public Command { @@ -48,7 +56,7 @@ private: public: // Whether to show modes in the LIST response. - bool showmodes; + ShowModes showmodes; CommandList(Module* parent) : Command(parent, "LIST") @@ -129,6 +137,7 @@ CmdResult CommandList::Handle(User* user, const Params& parameters) } const bool has_privs = user->HasPrivPermission("channels/auspex"); + const bool show_modes = (showmodes == ShowModes::ALL) || (showmodes == ShowModes::OPERS && has_privs); user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name"); @@ -168,7 +177,7 @@ CmdResult CommandList::Handle(User* user, const Params& parameters) // Channel is private (+p) and user is outside/not privileged user->WriteNumeric(RPL_LIST, '*', users, ""); } - else if (showmodes) + else if (show_modes) { // Show the list response with the modes and topic. user->WriteNumeric(RPL_LIST, chan->name, users, INSP_FORMAT("[+{}] {}", chan->ChanModes(n), chan->topic)); @@ -203,7 +212,11 @@ public: void ReadConfig(ConfigStatus& status) override { const auto& tag = ServerInstance->Config->ConfValue("options"); - cmd.showmodes = tag->getBool("modesinlist"); + cmd.showmodes = tag->getEnum("showmodes", ShowModes::OPERS, { + { "no", ShowModes::NOBODY }, + { "opers", ShowModes::OPERS }, + { "yes", ShowModes::ALL }, + }); } void OnBuildISupport(ISupport::TokenMap& tokens) override