diff --git a/synapse/config/server.py b/synapse/config/server.py index 395daa3c01..23c3d14013 100644 --- a/synapse/config/server.py +++ b/synapse/config/server.py @@ -108,17 +108,17 @@ class ServerConfig(Config): "federation_domain_whitelist", None ) - # Optional proxy address for federation traffic - self.federation_request_gateway_addr = config.get( - "federation_request_gateway_addr", None - ) - # turn the whitelist into a hash for speed of lookup if federation_domain_whitelist is not None: self.federation_domain_whitelist = {} for domain in federation_domain_whitelist: self.federation_domain_whitelist[domain] = True + # Optional proxy address for federation traffic + self.federation_request_gateway_addr = config.get( + "federation_request_gateway_addr", None + ) + if self.federation_request_gateway_addr is not None: # Ensure proxy address is correctly formatted if len(self.federation_request_gateway_addr.split(':')) != 2: diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 048bfa1870..92c70e3f0c 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -69,10 +69,11 @@ class ProxyMatrixFederationEndpointFactory(object): def __init__(self, hs): self.reactor = hs.get_reactor() self.tls_client_options_factory = hs.tls_client_options_factory + self.gateway_addr = hs.config.federation_request_gateway_addr def endpointForURI(self, uri): return matrix_federation_endpoint( - self.reactor, self.hs.config.federation_request_gateway_addr, timeout=10, + self.reactor, self.gateway_addr, timeout=10, tls_client_options_factory=None ) diff --git a/tests/utils.py b/tests/utils.py index 08d6faa0a6..ed386f91cd 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -115,6 +115,7 @@ def default_config(name): config.email_enable_notifs = False config.block_non_admin_invites = False config.federation_domain_whitelist = None + config.federation_request_gateway_addr = None config.federation_rc_reject_limit = 10 config.federation_rc_sleep_limit = 10 config.federation_rc_sleep_delay = 100