diff options
author | Glyph <glyph@twistedmatrix.com> | 2016-12-11 01:44:02 -0800 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2016-12-11 11:10:32 +0100 |
commit | 6e18805ac2906ea52d2374024392332af1a603b7 (patch) | |
tree | 317d4b44e55b4a1467f24b1a390699337b44cf7d /synapse | |
parent | Merge pull request #1684 from matrix-org/rav/no_run_tox_from_setup (diff) | |
download | synapse-6e18805ac2906ea52d2374024392332af1a603b7.tar.xz |
IPv6 support for client.py
This is an (untested) general sketch of how to use wrapClientTLS to implement TLS over IPv6, as well as faster connections over IPv4.
Diffstat (limited to '')
-rw-r--r-- | synapse/http/client.py | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py index 3ec9bc7faf..c60e3c2ac0 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -386,26 +386,21 @@ class SpiderEndpointFactory(object): def endpointForURI(self, uri): logger.info("Getting endpoint for %s", uri.toBytes()) + if uri.scheme == "http": - return SpiderEndpoint( - reactor, uri.host, uri.port, self.blacklist, self.whitelist, - endpoint=TCP4ClientEndpoint, - endpoint_kw_args={ - 'timeout': 15 - }, - ) + endpoint_factory = HostnameEndpoint elif uri.scheme == "https": - tlsPolicy = self.policyForHTTPS.creatorForNetloc(uri.host, uri.port) - return SpiderEndpoint( - reactor, uri.host, uri.port, self.blacklist, self.whitelist, - endpoint=SSL4ClientEndpoint, - endpoint_kw_args={ - 'sslContextFactory': tlsPolicy, - 'timeout': 15 - }, - ) + tlsCreator = self.policyForHTTPS.creatorForNetloc(uri.host, uri.port) + def endpoint_factory(reactor, host, port, **kw): + return wrapClientTLS(tlsCreator, HostnameEndpoint(reactor, host, port, **kw) else: logger.warn("Can't get endpoint for unrecognised scheme %s", uri.scheme) + return None + return SpiderEndpoint( + reactor, uri.host, uri.port, self.blacklist, self.whitelist, + endpoint=endpoint_factory, endpoint_kw_args=dict(timeout=15), + ) + class SpiderHttpClient(SimpleHttpClient): |