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

Commit 39c34f2

Browse files
committed
don't apply blacklist to proxy connections
Signed-off-by: Marcus Hoffmann <[email protected]>
1 parent fa6deb2 commit 39c34f2

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

changelog.d/9084.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't blacklist connections to the configured proxy. Contributed by @Bubu.

synapse/http/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def __init__(
341341

342342
self.agent = ProxyAgent(
343343
self.reactor,
344+
hs.get_reactor(),
344345
connectTimeout=15,
345346
contextFactory=self.hs.get_http_client_context_factory(),
346347
pool=pool,

synapse/http/proxyagent.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class ProxyAgent(_AgentBase):
3939
reactor: twisted reactor to place outgoing
4040
connections.
4141
42+
proxy_reactor: twisted reactor to use for connections to the proxy server
43+
reactor might have some blacklisting applied (i.e. for DNS queries),
44+
but we need unblocked access to the proxy.
45+
4246
contextFactory (IPolicyForHTTPS): A factory for TLS contexts, to control the
4347
verification parameters of OpenSSL. The default is to use a
4448
`BrowserLikePolicyForHTTPS`, so unless you have special
@@ -59,6 +63,7 @@ class ProxyAgent(_AgentBase):
5963
def __init__(
6064
self,
6165
reactor,
66+
proxy_reactor=None,
6267
contextFactory=BrowserLikePolicyForHTTPS(),
6368
connectTimeout=None,
6469
bindAddress=None,
@@ -68,18 +73,23 @@ def __init__(
6873
):
6974
_AgentBase.__init__(self, reactor, pool)
7075

76+
if proxy_reactor is None:
77+
self.proxy_reactor = reactor
78+
else:
79+
self.proxy_reactor = proxy_reactor
80+
7181
self._endpoint_kwargs = {}
7282
if connectTimeout is not None:
7383
self._endpoint_kwargs["timeout"] = connectTimeout
7484
if bindAddress is not None:
7585
self._endpoint_kwargs["bindAddress"] = bindAddress
7686

7787
self.http_proxy_endpoint = _http_proxy_endpoint(
78-
http_proxy, reactor, **self._endpoint_kwargs
88+
http_proxy, self.proxy_reactor, **self._endpoint_kwargs
7989
)
8090

8191
self.https_proxy_endpoint = _http_proxy_endpoint(
82-
https_proxy, reactor, **self._endpoint_kwargs
92+
https_proxy, self.proxy_reactor, **self._endpoint_kwargs
8393
)
8494

8595
self._policy_for_https = contextFactory
@@ -137,7 +147,7 @@ def request(self, method, uri, headers=None, bodyProducer=None):
137147
request_path = uri
138148
elif parsed_uri.scheme == b"https" and self.https_proxy_endpoint:
139149
endpoint = HTTPConnectProxyEndpoint(
140-
self._reactor,
150+
self.proxy_reactor,
141151
self.https_proxy_endpoint,
142152
parsed_uri.host,
143153
parsed_uri.port,

0 commit comments

Comments
 (0)