Tweak <options:modesinlist> to allow only showing to opers.

This can help opers avoid accidentally invading a secret channel
that they can see because of their privileges.
This commit is contained in:
Sadie Powell 2024-10-11 22:05:25 +01:00
parent f5564849d2
commit 25e4a63305
2 changed files with 23 additions and 6 deletions

View File

@ -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:

View File

@ -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