mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Rate limit retries when fetching server keys.
This commit is contained in:
parent
1a989c436c
commit
5025305fb2
@ -87,8 +87,20 @@ class Keyring(object):
|
||||
return
|
||||
|
||||
# Try to fetch the key from the remote server.
|
||||
# TODO(markjh): Ratelimit requests to a given server.
|
||||
|
||||
retry_last_ts, retry_interval = (0, 0)
|
||||
retry_timings = yield self.store.get_destination_retry_timings(
|
||||
server_name
|
||||
)
|
||||
if retry_timings:
|
||||
retry_last_ts, retry_interval = (
|
||||
retry_timings.retry_last_ts, retry_timings.retry_interval
|
||||
)
|
||||
if retry_last_ts + retry_interval > int(self.clock.time_msec()):
|
||||
logger.info("%s not ready for retry", server_name)
|
||||
raise ValueError("No verification key found for given key ids")
|
||||
|
||||
try:
|
||||
(response, tls_certificate) = yield fetch_server_key(
|
||||
server_name, self.hs.tls_context_factory
|
||||
)
|
||||
@ -153,3 +165,7 @@ class Keyring(object):
|
||||
return
|
||||
|
||||
raise ValueError("No verification key found for given key ids")
|
||||
|
||||
except:
|
||||
self.set_retrying(server_name, retry_interval)
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user