mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 01:29:03 -05:00
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:
parent
f5564849d2
commit
25e4a63305
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user