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

Fix 'ip_range_whitelist' not working for federation servers #10115

Merged
merged 8 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/10115.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a bug that prevented the 'ip_range_whitelist' configuration to work for federation and identity servers.
mikure marked this conversation as resolved.
Show resolved Hide resolved
Notice that this change will not be applied, if your configuration still uses 'federation_ip_range_blacklist', to allow backwards-compatibility.
mikure marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ def read_config(self, config, **kwargs):
["0.0.0.0", "::"],
config_path=("federation_ip_range_blacklist",),
)
# The federation_ip_range_whitelist is used to provide
# backwards-compatibility, if federation_ip_range_blacklist is set.
richvdh marked this conversation as resolved.
Show resolved Hide resolved
self.federation_ip_range_whitelist = None
if "federation_ip_range_blacklist" not in config:
self.federation_ip_range_whitelist = self.ip_range_whitelist

# (undocumented) option for torturing the worker-mode replication a bit,
# for testing. The value defines the number of milliseconds to pause before
Expand Down
4 changes: 3 additions & 1 deletion synapse/http/matrixfederationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ def __init__(self, hs, tls_client_options_factory):
# We need to use a DNS resolver which filters out blacklisted IP
# addresses, to prevent DNS rebinding.
self.reactor = BlacklistingReactorWrapper(
hs.get_reactor(), None, hs.config.federation_ip_range_blacklist
hs.get_reactor(),
hs.config.federation_ip_range_whitelist,
hs.config.federation_ip_range_blacklist,
) # type: ISynapseReactor

user_agent = hs.version_string
Expand Down