mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 00:54:57 -04:00
Fix a long-standing bug which meant that rate limiting was not restrictive enough in some cases. (#13018)
This commit is contained in:
parent
417f4cf40b
commit
0dbdc39940
3 changed files with 45 additions and 12 deletions
|
@ -128,6 +128,9 @@ class Ratelimiter:
|
|||
performed_count = action_count - time_delta * rate_hz
|
||||
if performed_count < 0:
|
||||
performed_count = 0
|
||||
|
||||
# Reset the start time and forgive all actions
|
||||
action_count = 0
|
||||
time_start = time_now_s
|
||||
|
||||
# This check would be easier read as performed_count + n_actions > burst_count,
|
||||
|
@ -140,7 +143,7 @@ class Ratelimiter:
|
|||
else:
|
||||
# We haven't reached our limit yet
|
||||
allowed = True
|
||||
action_count = performed_count + n_actions
|
||||
action_count = action_count + n_actions
|
||||
|
||||
if update:
|
||||
self.actions[key] = (action_count, time_start, rate_hz)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue