Skip to content

Commit

Permalink
Reputation was synced correctly on IP basis (and thus the databases)
Browse files Browse the repository at this point in the history
across servers if they differed, however the individual IP of users
was not updated until next add_scores() run. So, there would be an
up to 5 minute delay during which scores for individual users were
possibly too low, with all the effects that it could possibly have
nowadays such as restrict-commands, more stringent flood limits, etc.

If your servers are all linked all the time then you would not have
noticed this issue. It mostly matters if you are linking in a new
server or if the server has been delinked or out of order for days
or weeks.
  • Loading branch information
syzop committed May 25, 2022
1 parent 9ed38c4 commit ce6be5d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/RELEASE-NOTES.md
Expand Up @@ -89,6 +89,8 @@ about UnrealIRCd 6.
* [`set::modes-on-join`](https://www.unrealircd.org/docs/Set_block#set::modes-on-join)
did not work with `+f` + timed bans properly, eg `[3t#b1]:10`
* Several log messages were missing some information.
* Reputation syncing across servers had a small glitch. Fix is mostly
useful for servers that were not linked to the network for days or weeks.

### Changes:
* Clarified that UnrealIRCd is licensed as "GPLv2 or later"
Expand Down
20 changes: 20 additions & 0 deletions src/modules/reputation.c
Expand Up @@ -918,6 +918,24 @@ static inline int is_reputation_expired(ReputationEntry *e)
return 0;
}

/** If the reputation changed (due to server syncing) then update the
* individual users reputation score as well.
*/
void reputation_changed_update_users(ReputationEntry *e)
{
Client *client;

list_for_each_entry(client, &client_list, client_node)
{
if (client->ip && !strcmp(e->ip, client->ip))
{
/* With some (possibly unneeded) care to only go forward */
if (Reputation(client) < e->score)
Reputation(client) = e->score;
}
}
}

EVENT(delete_old_records)
{
int i;
Expand Down Expand Up @@ -1279,6 +1297,7 @@ CMD_FUNC(reputation_server_cmd)
log_data_integer("score", e->score));
#endif
e->score = score;
reputation_changed_update_users(e);
}

/* If we don't have any entry for this IP, add it now. */
Expand All @@ -1296,6 +1315,7 @@ CMD_FUNC(reputation_server_cmd)
e->score = score;
e->last_seen = TStime();
add_reputation_entry(e);
reputation_changed_update_users(e);
}

/* Propagate to the non-client direction (score may be updated) */
Expand Down

0 comments on commit ce6be5d

Please sign in to comment.