1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 13:13:13 +02:00

Improve the usability of adding hostmasks to access lists.

* When adding a user by their nickname check for their account
  instead of just adding their hostmask.

* Allow opting out of cleaning up of malformed hostmasks.
This commit is contained in:
Sadie Powell
2026-01-28 19:44:49 +00:00
parent 48bb6089fa
commit c3e62d3772
6 changed files with 73 additions and 17 deletions
+20 -5
View File
@@ -94,9 +94,10 @@ class CommandCSFlags final
const ChanAccess *highest = u_access.Highest();
const NickAlias *na = NULL;
const auto &csconf = Config->GetModule("chanserv");
if (IRCD->IsChannelValid(mask))
{
if (Config->GetModule("chanserv").Get<bool>("disallow_channel_access"))
if (csconf.Get<bool>("disallow_channel_access"))
{
source.Reply(_("Channels may not be on access lists."));
return;
@@ -131,7 +132,7 @@ class CommandCSFlags final
}
else
{
if (Config->GetModule("chanserv").Get<bool>("disallow_hostmask_access"))
if (csconf.Get<bool>("disallow_hostmask_access"))
{
source.Reply(_("Masks and unregistered users may not be on access lists."));
return;
@@ -142,18 +143,32 @@ class CommandCSFlags final
auto *targ = User::Find(mask, true);
if (!targ)
{
source.Reply(NICK_X_NOT_REGISTERED, mask.c_str());
source.Reply(NICK_X_NOT_IN_USE, mask.c_str());
return;
}
mask = "*!*@" + targ->GetDisplayedHost();
auto *targnc = targ->Account();
if (!targnc)
{
source.Reply(NICK_X_NOT_REGISTERED, targ->nick.c_str());
return;
}
mask = targnc->display;
if (description.empty())
description = targ->nick;
}
else
{
// Normalize the entry mask.
mask = Entry(mask).GetCleanMask();
const auto cleanmask = Entry(mask).GetCleanMask();
if (csconf.Get<bool>("disallow_malformed_hostmask") && cleanmask != mask)
{
source.Reply(CHAN_ACCESS_MALFORMED, cleanmask.c_str());
return;
}
mask = cleanmask;
}
}
}