From 1788e55713e9124f880dd77075024fa8cce4c05d Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Mon, 18 Oct 2021 18:26:05 +0100 Subject: [PATCH] Support *mask* and !*mask* in LIST --- include/client.h | 2 +- modules/m_list.c | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/client.h b/include/client.h index fa736bd3..6a50f533 100644 --- a/include/client.h +++ b/include/client.h @@ -308,7 +308,7 @@ struct PreClient struct ListClient { - char *chname; + char *chname, *mask, *nomask; unsigned int users_min, users_max; time_t created_min, created_max, topic_min, topic_max; int operspy; diff --git a/modules/m_list.c b/modules/m_list.c index 59026e90..03d05f35 100644 --- a/modules/m_list.c +++ b/modules/m_list.c @@ -100,7 +100,7 @@ static int _modinit(void) * T = topic search (T> T<) */ add_isupport("SAFELIST", isupport_string, ""); - add_isupport("ELIST", isupport_string, "CTU"); + add_isupport("ELIST", isupport_string, "CMNTU"); return 0; } @@ -191,7 +191,7 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ } /* Single channel. */ - if (args && IsChannelName(args)) + if (args && IsChannelName(args) && !strchr(args, ',')) { safelist_channel_named(source_p, args, operspy); return; @@ -205,6 +205,8 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ params->operspy = operspy; params->created_min = params->topic_min = params->created_max = params->topic_max = 0; + params->mask = NULL; + params->nomask = NULL; if (args && !EmptyString(args)) { @@ -280,6 +282,17 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ } } } + else if (*args == '!') + { + args++; + rb_free(params->nomask); + params->nomask = rb_strdup(args); + } + else if (*args == '?' || *args == '*' || IsChanPrefix(*args)) + { + rb_free(params->mask); + params->mask = rb_strdup(args); + } if (EmptyString(p)) break; @@ -376,6 +389,8 @@ static void safelist_client_release(struct Client *client_p) rb_dlinkFindDestroy(client_p, &safelisting_clients); rb_free(client_p->localClient->safelist_data->chname); + rb_free(client_p->localClient->safelist_data->mask); + rb_free(client_p->localClient->safelist_data->nomask); rb_free(client_p->localClient->safelist_data); client_p->localClient->safelist_data = NULL; @@ -459,6 +474,12 @@ static void safelist_one_channel(struct Client *source_p, struct Channel *chptr, if (params->created_max && chptr->channelts > params->created_max) return; + if (params->mask && !match(params->mask, chptr->chname)) + return; + + if (params->nomask && match(params->nomask, chptr->chname)) + return; + list_one_channel(source_p, chptr, visible); }