|
@ -517,6 +517,11 @@ class PeerManager(util.LoggedClass): |
|
|
kind, port = port_pairs[0] |
|
|
kind, port = port_pairs[0] |
|
|
sslc = ssl.SSLContext(ssl.PROTOCOL_TLS) if kind == 'SSL' else None |
|
|
sslc = ssl.SSLContext(ssl.PROTOCOL_TLS) if kind == 'SSL' else None |
|
|
|
|
|
|
|
|
|
|
|
host = self.env.cs_host(for_rpc=False) |
|
|
|
|
|
if isinstance(host, list): |
|
|
|
|
|
host = host[0] |
|
|
|
|
|
|
|
|
|
|
|
kwargs = {'ssl': sslc} |
|
|
if self.env.force_proxy or peer.is_tor: |
|
|
if self.env.force_proxy or peer.is_tor: |
|
|
# Only attempt a proxy connection if the proxy is up |
|
|
# Only attempt a proxy connection if the proxy is up |
|
|
if not self.proxy: |
|
|
if not self.proxy: |
|
@ -524,17 +529,13 @@ class PeerManager(util.LoggedClass): |
|
|
create_connection = self.proxy.create_connection |
|
|
create_connection = self.proxy.create_connection |
|
|
else: |
|
|
else: |
|
|
create_connection = self.loop.create_connection |
|
|
create_connection = self.loop.create_connection |
|
|
|
|
|
# Use our listening Host/IP for outgoing connections so |
|
|
# Use our listening Host/IP for outgoing connections so our |
|
|
# our peers see the correct source. |
|
|
# peers see the correct source. |
|
|
if host: |
|
|
host = self.env.cs_host(for_rpc=False) |
|
|
kwargs['local_addr'] = (host, None) |
|
|
if isinstance(host, list): |
|
|
|
|
|
host = host[0] |
|
|
|
|
|
local_addr = (host, None) if host else None |
|
|
|
|
|
|
|
|
|
|
|
protocol_factory = partial(PeerSession, peer, self, kind) |
|
|
protocol_factory = partial(PeerSession, peer, self, kind) |
|
|
coro = create_connection(protocol_factory, peer.host, port, ssl=sslc, |
|
|
coro = create_connection(protocol_factory, peer.host, port, **kwargs) |
|
|
local_addr=local_addr) |
|
|
|
|
|
callback = partial(self.connection_done, peer, port_pairs) |
|
|
callback = partial(self.connection_done, peer, port_pairs) |
|
|
self.ensure_future(coro, callback) |
|
|
self.ensure_future(coro, callback) |
|
|
|
|
|
|
|
|