diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2019-05-15 12:06:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-15 12:06:04 -0500 |
commit | f1e5b413886ba4d9d0a16b028dba89c4a5cb56ac (patch) | |
tree | 590ed475c14dc2e17007a240ab3a0e3ceb9928d7 /synapse/rest/client/v2_alpha | |
parent | Drop support for v2_alpha API prefix (#5190) (diff) | |
download | synapse-f1e5b413886ba4d9d0a16b028dba89c4a5cb56ac.tar.xz |
Make all the rate limiting options more consistent (#5181)
Diffstat (limited to 'synapse/rest/client/v2_alpha')
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index dc3e265bcd..3d045880b9 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -31,6 +31,7 @@ from synapse.api.errors import ( SynapseError, UnrecognizedRequestError, ) +from synapse.config.ratelimiting import FederationRateLimitConfig from synapse.config.server import is_threepid_reserved from synapse.http.servlet import ( RestServlet, @@ -153,16 +154,18 @@ class UsernameAvailabilityRestServlet(RestServlet): self.registration_handler = hs.get_registration_handler() self.ratelimiter = FederationRateLimiter( hs.get_clock(), - # Time window of 2s - window_size=2000, - # Artificially delay requests if rate > sleep_limit/window_size - sleep_limit=1, - # Amount of artificial delay to apply - sleep_msec=1000, - # Error with 429 if more than reject_limit requests are queued - reject_limit=1, - # Allow 1 request at a time - concurrent_requests=1, + FederationRateLimitConfig( + # Time window of 2s + window_size=2000, + # Artificially delay requests if rate > sleep_limit/window_size + sleep_limit=1, + # Amount of artificial delay to apply + sleep_msec=1000, + # Error with 429 if more than reject_limit requests are queued + reject_limit=1, + # Allow 1 request at a time + concurrent_requests=1, + ) ) @defer.inlineCallbacks |