1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 03:23:13 +02:00

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
This commit is contained in:
Bram Matthys
2025-07-13 10:16:06 +02:00
parent 369f55063a
commit 97a87bdca8
+19 -8
View File
@@ -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 <X> */
if ((e->score <= cfg.expire_score[i]) && (TStime() - e->last_seen > cfg.expire_time[i]))
return 1;
}
}
return 0;
}