Browse Source

Use our listening Host/IP for outgoing connections also (#226)

Explicitely set the local IP for outgoing connections, if we're listening
on only one Hostname or IP (of a multi-IP machine). This makes sure our
peers see our outgoing connections coming from the same IP that we're
listening on when we have a specific HOST= configured.

For machines with more than one IP this avoids source-destination
mismatch errors when advertizing our peer. Resolves kyuupichan/electrumx#225
master
mmouse- 8 years ago
committed by Neil
parent
commit
69c1535d13
  1. 4
      server/peers.py

4
server/peers.py

@ -560,9 +560,11 @@ class PeerManager(util.LoggedClass):
create_connection = self.proxy.create_connection
else:
create_connection = self.loop.create_connection
local_addr = (self.env.host, None) if self.env.host else None
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, ssl=sslc, local_addr=local_addr)
callback = partial(self.connection_done, peer, port_pairs)
self.ensure_future(coro, callback)

Loading…
Cancel
Save