Skip to content

Commit 3c68c0c

Browse files
committed
run spamfilters against NICK
1 parent 48a06ae commit 3c68c0c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

extensions/filter.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static const char filter_desc[] = "Filter messages using a precompiled Hyperscan
5656
static void filter_msg_user(void *data);
5757
static void filter_msg_channel(void *data);
5858
static void filter_client_quit(void *data);
59+
static void filter_client_nick(void *data);
5960
static void on_client_exit(void *data);
6061

6162
static void mo_setfilter(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
@@ -93,6 +94,7 @@ mapi_hfn_list_av1 filter_hfnlist[] = {
9394
{ "privmsg_user", filter_msg_user },
9495
{ "privmsg_channel", filter_msg_channel },
9596
{ "client_quit", filter_client_quit },
97+
{ "local_nick_change", filter_client_nick },
9698
{ "client_exit", on_client_exit },
9799
{ NULL, NULL }
98100
};
@@ -483,6 +485,29 @@ filter_client_quit(void *data_)
483485
/* No point in doing anything with ACT_KILL */
484486
}
485487

488+
void
489+
filter_client_nick(void *data_)
490+
{
491+
hook_cdata *data = data_;
492+
struct Client *s = data->client;
493+
if (IsOper(s)) {
494+
return;
495+
}
496+
497+
unsigned r = match_message("0", s, "NICK", NULL, data->arg2);
498+
if (r & ACT_DROP) {
499+
data->arg2 = NULL;
500+
}
501+
if (r & ACT_ALARM) {
502+
sendto_realops_snomask(SNO_GENERAL, L_ALL | L_NETWIDE,
503+
"FILTER: %s!%s@%s [%s]",
504+
s->name, s->username, s->host, s->sockhost);
505+
}
506+
if (r & ACT_KILL) {
507+
exit_client(NULL, s, s, FILTER_EXIT_MSG);
508+
}
509+
}
510+
486511
void
487512
on_client_exit(void *data_)
488513
{

modules/core/m_nick.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,12 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
673673
hook_info.arg2 = nick;
674674
call_hook(h_local_nick_change, &hook_info);
675675

676+
if (!hook_info.arg2) {
677+
sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
678+
me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
679+
return;
680+
}
681+
676682
sendto_realops_snomask(SNO_NCHANGE, L_ALL,
677683
"Nick change: From %s to %s [%s@%s]",
678684
source_p->name, nick, source_p->username, source_p->host);

0 commit comments

Comments
 (0)