From 97a87bdca8307c0f5684bf05405e64664d116bd1 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 13 Jul 2025 10:16:06 +0200 Subject: [PATCH] Fix reputation score not expiring after 30 days of inactivity. We now expire after 30d if score is <12 (so 1 hour of being online) and we expire after 90d regardless of score. Note that for this to work, all servers would need to be running UnrealIRCd 6.2.0+ because when a score for an IP is still present on any of the servers on a network, and a user with that IP connects, then the score will be broadcasted from the server that still has the score and it will be re-added by all servers with that score. But eventually it should be like this... :D Reported by armyn in https://bugs.unrealircd.org/view.php?id=6536 --- src/modules/reputation.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/modules/reputation.c b/src/modules/reputation.c index ac26cc65f..5d1695cf0 100644 --- a/src/modules/reputation.c +++ b/src/modules/reputation.c @@ -263,16 +263,19 @@ void reputation_config_setdefaults(struct cfgstruct *cfg) /* <=2 points after 1 hour */ cfg->expire_score[0] = 2; #ifndef TEST - cfg->expire_time[0] = 3600; + cfg->expire_time[0] = 3600; #else - cfg->expire_time[0] = 36; + cfg->expire_time[0] = 36; #endif /* <=6 points after 7 days */ cfg->expire_score[1] = 6; - cfg->expire_time[1] = 86400*7; - /* ANY result that has not been seen for 30 days */ - cfg->expire_score[2] = -1; - cfg->expire_time[2] = 86400*30; + cfg->expire_time[1] = 86400*7; + /* <=12 points after 30 days */ + cfg->expire_score[2] = 12; + cfg->expire_time[2] = 86400*30; + /* ANY result that has not been seen for 90 days */ + cfg->expire_score[3] = -1; + cfg->expire_time[3] = 86400*90; /* The 'require' settings */ cfg->require_minimum_channel_members = 3; @@ -940,8 +943,16 @@ static inline int is_reputation_expired(ReputationEntry *e) { if (cfg.expire_time[i] == 0) break; /* end of all entries */ - if ((e->score <= cfg.expire_score[i]) && (TStime() - e->last_seen > cfg.expire_time[i])) - return 1; + if (cfg.expire_score[i] == -1) + { + /* For -1 it means ANY score will expire after this time.. */ + if (TStime() - e->last_seen > cfg.expire_time[i]) + return 1; + } else { + /* Otherwise we only expire if the score is less than */ + if ((e->score <= cfg.expire_score[i]) && (TStime() - e->last_seen > cfg.expire_time[i])) + return 1; + } } return 0; }