From e84e2b30d2fa5ec96188e0c0016efd34410038b3 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 12 Nov 2023 17:29:35 +0100 Subject: [PATCH] Forward SPAMREPORT command to the server that the target user is on. That is, if a nick is specified. For an IP address obviously we won't. This is needed later for when unrealircd api SPAMREPORT becomes available, since remote servers don't have all the info. Side-effect is that, if you only configured one server to do spamreporting, that won't work anymore. But that is an unusual case anyway, and now unsupported :D. --- src/modules/spamreport.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/modules/spamreport.c b/src/modules/spamreport.c index 9324d6409..b8f1744ca 100644 --- a/src/modules/spamreport.c +++ b/src/modules/spamreport.c @@ -103,6 +103,12 @@ int tkl_config_test_spamreport(ConfigFile *cf, ConfigEntry *ce, int type, int *e config_error("%s:%i: spamreport block has no name, should be like: spamfilter { }", ce->file->filename, ce->line_number); errors++; + } else + if (!strcasecmp(ce->value, "unrealircd")) + { + config_error("%s:%i: spamreport block cannot be named 'unrealircd', is a reserved name.", + ce->file->filename, ce->line_number); + errors++; } for (cep = ce->items; cep; cep = cep->next) @@ -492,6 +498,32 @@ CMD_FUNC(cmd_spamreport) ip = parv[1]; + if ((target = find_user(parv[1], NULL))) + { + if (!MyUser(target)) + { + /* Forward it to other server */ + if (parc > 2) + { + sendto_one(target, NULL, ":%s SPAMREPORT %s %s", + client->id, parv[1], parv[2]); + } else { + sendto_one(target, NULL, ":%s SPAMREPORT %s", + client->id, parv[1]); + } + return; + } + /* It's for us */ + if (target->ip) + ip = target->ip; + } + + if (!is_valid_ip(ip)) + { + sendnotice(client, "Not a valid nick/IP: %s", ip); + return; + } + if ((parc > 2) && !BadPtr(parv[2])) { to = find_spamreport_block(parv[2]); @@ -502,15 +534,6 @@ CMD_FUNC(cmd_spamreport) } } - if ((target = find_user(parv[1], NULL)) && target->ip) - ip = target->ip; - - if (!is_valid_ip(ip)) - { - sendnotice(client, "Not a valid IP: %s", ip); - return; - } - if (!((n = spamreport(target, ip, NULL, to ? to->name : NULL)))) sendnotice(client, "Could not report spam. No spamreport { } blocks configured, or all filtered out/exempt."); else