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

Commit

Permalink
don't apply blacklist to proxy connections
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Hoffmann <bubu@bubu1.eu>
  • Loading branch information
Bubu committed Jan 12, 2021
1 parent fa6deb2 commit 39c34f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/9084.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't blacklist connections to the configured proxy. Contributed by @Bubu.
1 change: 1 addition & 0 deletions synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def __init__(

self.agent = ProxyAgent(
self.reactor,
hs.get_reactor(),
connectTimeout=15,
contextFactory=self.hs.get_http_client_context_factory(),
pool=pool,
Expand Down
16 changes: 13 additions & 3 deletions synapse/http/proxyagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class ProxyAgent(_AgentBase):
reactor: twisted reactor to place outgoing
connections.
proxy_reactor: twisted reactor to use for connections to the proxy server
reactor might have some blacklisting applied (i.e. for DNS queries),
but we need unblocked access to the proxy.
contextFactory (IPolicyForHTTPS): A factory for TLS contexts, to control the
verification parameters of OpenSSL. The default is to use a
`BrowserLikePolicyForHTTPS`, so unless you have special
Expand All @@ -59,6 +63,7 @@ class ProxyAgent(_AgentBase):
def __init__(
self,
reactor,
proxy_reactor=None,
contextFactory=BrowserLikePolicyForHTTPS(),
connectTimeout=None,
bindAddress=None,
Expand All @@ -68,18 +73,23 @@ def __init__(
):
_AgentBase.__init__(self, reactor, pool)

if proxy_reactor is None:
self.proxy_reactor = reactor
else:
self.proxy_reactor = proxy_reactor

self._endpoint_kwargs = {}
if connectTimeout is not None:
self._endpoint_kwargs["timeout"] = connectTimeout
if bindAddress is not None:
self._endpoint_kwargs["bindAddress"] = bindAddress

self.http_proxy_endpoint = _http_proxy_endpoint(
http_proxy, reactor, **self._endpoint_kwargs
http_proxy, self.proxy_reactor, **self._endpoint_kwargs
)

self.https_proxy_endpoint = _http_proxy_endpoint(
https_proxy, reactor, **self._endpoint_kwargs
https_proxy, self.proxy_reactor, **self._endpoint_kwargs
)

self._policy_for_https = contextFactory
Expand Down Expand Up @@ -137,7 +147,7 @@ def request(self, method, uri, headers=None, bodyProducer=None):
request_path = uri
elif parsed_uri.scheme == b"https" and self.https_proxy_endpoint:
endpoint = HTTPConnectProxyEndpoint(
self._reactor,
self.proxy_reactor,
self.https_proxy_endpoint,
parsed_uri.host,
parsed_uri.port,
Expand Down

0 comments on commit 39c34f2

Please sign in to comment.