Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Share configuration for local and federation.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Dec 18, 2020
1 parent e05b4fd commit d36c7b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
9 changes: 0 additions & 9 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,6 @@ log_config: "CONFDIR/SERVERNAME.log.config"
# remote:
# per_second: 0.01
# burst_count: 3
#
#rc_key_requests:
# per_second: 0.1
# burst_count: 3
#
#rc_federation:
# room_key_request:
# per_second: 0.1
# burst_count: 3


# Ratelimiting settings for incoming federation
Expand Down
19 changes: 5 additions & 14 deletions synapse/config/ratelimiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ def read_config(self, config, **kwargs):
defaults={"per_second": 0.01, "burst_count": 3},
)

# Ratelimit cross-user key requests:
# * For locacl requests this is done by the sending devie.
# * For requests received over federation this is done by the origin.
#
# Note that this isn't exposed in the configuration as it is obscure.
self.rc_key_requests = RateLimitConfig(
config.get("rc_key_requests", {}),
defaults={"per_second": 0.1, "burst_count": 3},
)

self.rc_federation_room_key_request = RateLimitConfig(
config.get("rc_federation", {}).get("room_key_request", {}),
defaults={"per_second": 0.1, "burst_count": 3},
)

def generate_config_section(self, **kwargs):
return """\
## Ratelimiting ##
Expand Down Expand Up @@ -177,15 +177,6 @@ def generate_config_section(self, **kwargs):
# remote:
# per_second: 0.01
# burst_count: 3
#
#rc_key_requests:
# per_second: 0.1
# burst_count: 3
#
#rc_federation:
# room_key_request:
# per_second: 0.1
# burst_count: 3
# Ratelimiting settings for incoming federation
Expand Down
4 changes: 2 additions & 2 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ def __init__(self, hs: "HomeServer"):
# A rate limiter for incoming room key requests per origin.
self._room_key_request_rate_limiter = Ratelimiter(
clock=self.clock,
rate_hz=self.config.rc_federation_room_key_request.per_second,
burst_count=self.config.rc_federation_room_key_request.burst_count,
rate_hz=self.config.rc_key_requests.per_second,
burst_count=self.config.rc_key_requests.burst_count,
)

def register_edu_handler(
Expand Down

0 comments on commit d36c7b0

Please sign in to comment.