ratelimit: switch to token-based rate limiting

allows for N actions per minute

Changelog-Changed: Switched to token-based ratelimiting
Closes: https://github.com/damus-io/noteguard/issues/2
This commit is contained in:
William Casarin 2024-07-08 14:12:38 -07:00
parent c951f0abb2
commit ddff59a20a
4 changed files with 57 additions and 27 deletions

View file

@ -18,7 +18,7 @@ The `pipeline` config specifies the order in which filters are run. When the fir
pipeline = ["ratelimit"]
[filters.ratelimit]
delay_seconds = 1
notes_per_minute = 8
whitelist = ["127.0.0.1"]
```
@ -34,7 +34,7 @@ The ratelimit filter limits the rate at which notes are written to the relay per
Settings:
- `delay_seconds`: the delay in seconds between accepted notes. 1 means only one note can be written per second. 2 means only 1 note can be written every 2 seconds, etc.
- `notes_per_minute`: the number of notes per minute which are allowed to be written per ip.
- `whitelist`: a list of IP4 or IP6 addresses that are allowed to bypass the ratelimit.