summary refs log tree commit diff
path: root/synapse/http/endpoint.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-05-18 11:38:24 +0100
committerErik Johnston <erik@matrix.org>2016-05-18 11:38:24 +0100
commit5941346c5b8b0847a0adc643e80ba6ba8669c149 (patch)
tree0f7bd386246268177ca45ee4b6ddd992b333e085 /synapse/http/endpoint.py
parentCorrectly order recents (diff)
parentAdd desc to get_presence_for_users (diff)
downloadsynapse-5941346c5b8b0847a0adc643e80ba6ba8669c149.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/paginate_sync
Diffstat (limited to 'synapse/http/endpoint.py')
-rw-r--r--synapse/http/endpoint.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/synapse/http/endpoint.py b/synapse/http/endpoint.py

index a456dc19da..442696d393 100644 --- a/synapse/http/endpoint.py +++ b/synapse/http/endpoint.py
@@ -79,12 +79,13 @@ class SpiderEndpoint(object): """An endpoint which refuses to connect to blacklisted IP addresses Implements twisted.internet.interfaces.IStreamClientEndpoint. """ - def __init__(self, reactor, host, port, blacklist, + def __init__(self, reactor, host, port, blacklist, whitelist, endpoint=TCP4ClientEndpoint, endpoint_kw_args={}): self.reactor = reactor self.host = host self.port = port self.blacklist = blacklist + self.whitelist = whitelist self.endpoint = endpoint self.endpoint_kw_args = endpoint_kw_args @@ -93,10 +94,13 @@ class SpiderEndpoint(object): address = yield self.reactor.resolve(self.host) from netaddr import IPAddress - if IPAddress(address) in self.blacklist: - raise ConnectError( - "Refusing to spider blacklisted IP address %s" % address - ) + ip_address = IPAddress(address) + + if ip_address in self.blacklist: + if self.whitelist is None or ip_address not in self.whitelist: + raise ConnectError( + "Refusing to spider blacklisted IP address %s" % address + ) logger.info("Connecting to %s:%s", address, self.port) endpoint = self.endpoint(