From 3eb0bc24ead91a869aa1028369bc1ffe0faa78ec Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 30 May 2021 19:30:36 +0200 Subject: [PATCH] Add log::flags "flood" to log flood messages --- doc/conf/examples/example.conf | 3 ++- include/struct.h | 1 + src/conf.c | 1 + src/user.c | 7 +++++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/conf/examples/example.conf b/doc/conf/examples/example.conf index 931285c7b..3930dd9cf 100644 --- a/doc/conf/examples/example.conf +++ b/doc/conf/examples/example.conf @@ -265,7 +265,7 @@ drpass { * See also https://www.unrealircd.org/docs/Log_block */ -/* This is a good default, it logs almost everything */ +/* This is a good default, it logs everything */ log "ircd.log" { flags { oper; @@ -273,6 +273,7 @@ log "ircd.log" { server-connects; kills; errors; + flood; sadmin-commands; chg-commands; oper-override; diff --git a/include/struct.h b/include/struct.h index df2f89536..2e1e33ece 100644 --- a/include/struct.h +++ b/include/struct.h @@ -212,6 +212,7 @@ typedef OperPermission (*OperClassEntryEvalCallback)(OperClassACLEntryVar* varia #define LOG_CHGCMDS 0x0100 #define LOG_OVERRIDE 0x0200 #define LOG_SPAMFILTER 0x0400 +#define LOG_FLOOD 0x0800 /* ** 'offsetof' is defined in ANSI-C. The following definition diff --git a/src/conf.c b/src/conf.c index 7f6c1fd8b..8401a9c11 100644 --- a/src/conf.c +++ b/src/conf.c @@ -163,6 +163,7 @@ static NameValue _LogFlags[] = { { LOG_CHGCMDS, "chg-commands" }, { LOG_CLIENT, "connects" }, { LOG_ERROR, "errors" }, + { LOG_FLOOD, "flood" }, { LOG_KILL, "kills" }, { LOG_KLINE, "kline" }, { LOG_OPER, "oper" }, diff --git a/src/user.c b/src/user.c index 6848e5dd3..77cb5b238 100644 --- a/src/user.c +++ b/src/user.c @@ -942,18 +942,21 @@ char *get_connect_extinfo(Client *client) /** Log a message that flood protection kicked in for the client. * This sends to the +f snomask at the moment. - * FIXME: we should provide an option to log this too? * @param client The client to check flood for (local user) * @param opt The flood option (eg FLD_AWAY) */ void flood_limit_exceeded_log(Client *client, char *floodname) { - sendto_snomask_global(SNO_FLOOD, "Flood blocked (%s) from %s!%s@%s [%s]", + char buf[1024]; + + snprintf(buf, sizeof(buf), "Flood blocked (%s) from %s!%s@%s [%s]", floodname, client->name, client->user->username, client->user->realhost, GetIP(client)); + ircd_log(LOG_FLOOD, "%s", buf); + sendto_snomask_global(SNO_FLOOD, "%s", buf); } /** Is the flood limit exceeded for an option? eg for away-flood.