diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-02-03 07:13:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-03 07:13:46 -0500 |
commit | 4ca054a4eaa714d0befb4fc30b19a1131e52c9cc (patch) | |
tree | ff8c8731b595cff9c59b1742137ba05d6837a9b6 /synapse/config/repository.py | |
parent | Honour ratelimit flag for application services for invite ratelimiting (#9302) (diff) | |
download | synapse-4ca054a4eaa714d0befb4fc30b19a1131e52c9cc.tar.xz |
Convert blacklisted IPv4 addresses to compatible IPv6 addresses. (#9240)
Also add a few more IP ranges to the default blacklist.
Diffstat (limited to 'synapse/config/repository.py')
-rw-r--r-- | synapse/config/repository.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/synapse/config/repository.py b/synapse/config/repository.py index 850ac3ebd6..fcaea8fb93 100644 --- a/synapse/config/repository.py +++ b/synapse/config/repository.py @@ -17,9 +17,7 @@ import os from collections import namedtuple from typing import Dict, List -from netaddr import IPSet - -from synapse.config.server import DEFAULT_IP_RANGE_BLACKLIST +from synapse.config.server import DEFAULT_IP_RANGE_BLACKLIST, generate_ip_set from synapse.python_dependencies import DependencyException, check_requirements from synapse.util.module_loader import load_module @@ -187,16 +185,17 @@ class ContentRepositoryConfig(Config): "to work" ) - self.url_preview_ip_range_blacklist = IPSet( - config["url_preview_ip_range_blacklist"] - ) - # we always blacklist '0.0.0.0' and '::', which are supposed to be # unroutable addresses. - self.url_preview_ip_range_blacklist.update(["0.0.0.0", "::"]) + self.url_preview_ip_range_blacklist = generate_ip_set( + config["url_preview_ip_range_blacklist"], + ["0.0.0.0", "::"], + config_path=("url_preview_ip_range_blacklist",), + ) - self.url_preview_ip_range_whitelist = IPSet( - config.get("url_preview_ip_range_whitelist", ()) + self.url_preview_ip_range_whitelist = generate_ip_set( + config.get("url_preview_ip_range_whitelist", ()), + config_path=("url_preview_ip_range_whitelist",), ) self.url_preview_url_blacklist = config.get("url_preview_url_blacklist", ()) |