Allow disabling LIST completely for unregistered users.

This commit is contained in:
Sadie Powell 2023-10-03 22:04:44 +01:00
parent f1b04a918c
commit e86a159293
2 changed files with 16 additions and 7 deletions

View File

@ -2221,8 +2221,10 @@
# Defaults to no. #
# #
# waittime - The time period that a user must be connected for before #
# they can use the /LIST command. #
# Defaults to 1 minute. #
# they can use the /LIST command. If exemptregistered is #
# enabled you can set this to 0 to disable unauthenticated #
# users from viewing the channel list. #
# Defaults to 1 minute. #
# #
#<securelist exemptregistered="yes"
# fakechans="5"

View File

@ -98,7 +98,7 @@ public:
fakechantopic = tag->getString("fakechantopic", "Fake channel for confusing spambots", 1, ServerInstance->Config->Limits.MaxTopic - 1);
hidesmallchans = tag->getNum<size_t>("hidesmallchans", 0);
showmsg = tag->getBool("showmsg", true);
waittime = tag->getDuration("waittime", 60, 1, 60*60*24);
waittime = tag->getDuration("waittime", 60, !exemptregistered, 60*60*24);
allowlist.swap(newallows);
}
@ -111,15 +111,22 @@ public:
// Allow if the wait time has passed.
time_t maxwaittime = user->signon + waittime;
if (ServerInstance->Time() > maxwaittime)
if (waittime && ServerInstance->Time() > maxwaittime)
return MOD_RES_PASSTHRU;
// If <securehost:showmsg> is set then tell the user that they need to wait.
if (showmsg)
{
user->WriteNotice(INSP_FORMAT("*** You cannot view the channel list right now. Please {}try again in {}.",
exemptregistered ? "log in to an account or " : "",
Duration::ToString(maxwaittime - ServerInstance->Time())));
if (waittime)
{
user->WriteNotice(INSP_FORMAT("*** You cannot view the channel list right now. Please {}try again in {}.",
exemptregistered ? "log in to an account or " : "",
Duration::ToString(maxwaittime - ServerInstance->Time())));
}
else
{
user->WriteNotice("*** You must be logged into an account to view the channel list.");
}
}
// The client might be waiting on a response to do something so send them an