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.pull/1696/head
parent
77692b52b5
commit
6e18805ac2
|
@ -386,26 +386,21 @@ class SpiderEndpointFactory(object):
|
||||||
|
|
||||||
def endpointForURI(self, uri):
|
def endpointForURI(self, uri):
|
||||||
logger.info("Getting endpoint for %s", uri.toBytes())
|
logger.info("Getting endpoint for %s", uri.toBytes())
|
||||||
|
|
||||||
if uri.scheme == "http":
|
if uri.scheme == "http":
|
||||||
return SpiderEndpoint(
|
endpoint_factory = HostnameEndpoint
|
||||||
reactor, uri.host, uri.port, self.blacklist, self.whitelist,
|
|
||||||
endpoint=TCP4ClientEndpoint,
|
|
||||||
endpoint_kw_args={
|
|
||||||
'timeout': 15
|
|
||||||
},
|
|
||||||
)
|
|
||||||
elif uri.scheme == "https":
|
elif uri.scheme == "https":
|
||||||
tlsPolicy = self.policyForHTTPS.creatorForNetloc(uri.host, uri.port)
|
tlsCreator = self.policyForHTTPS.creatorForNetloc(uri.host, uri.port)
|
||||||
return SpiderEndpoint(
|
def endpoint_factory(reactor, host, port, **kw):
|
||||||
reactor, uri.host, uri.port, self.blacklist, self.whitelist,
|
return wrapClientTLS(tlsCreator, HostnameEndpoint(reactor, host, port, **kw)
|
||||||
endpoint=SSL4ClientEndpoint,
|
|
||||||
endpoint_kw_args={
|
|
||||||
'sslContextFactory': tlsPolicy,
|
|
||||||
'timeout': 15
|
|
||||||
},
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
logger.warn("Can't get endpoint for unrecognised scheme %s", uri.scheme)
|
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):
|
class SpiderHttpClient(SimpleHttpClient):
|
||||||
|
|
Loading…
Reference in New Issue