Don't connect to myself
- track local IP+port of incoming connections and don't connect to them in the future
This commit is contained in:
parent
fa9811f426
commit
f23c169eec
|
@ -134,6 +134,9 @@ class BMConnectionPool(object):
|
||||||
continue
|
continue
|
||||||
if chosen.host in self.inboundConnections:
|
if chosen.host in self.inboundConnections:
|
||||||
continue
|
continue
|
||||||
|
# don't connect to self
|
||||||
|
if chosen.host in state.ownAddresses:
|
||||||
|
continue
|
||||||
|
|
||||||
#for c in self.outboundConnections:
|
#for c in self.outboundConnections:
|
||||||
# if chosen == c.destination:
|
# if chosen == c.destination:
|
||||||
|
|
|
@ -205,6 +205,7 @@ class TCPServer(AdvancedDispatcher):
|
||||||
pair = self.accept()
|
pair = self.accept()
|
||||||
if pair is not None:
|
if pair is not None:
|
||||||
sock, addr = pair
|
sock, addr = pair
|
||||||
|
state.ownAddresses[state.Peer(sock.getsockname()[0], sock.getsockname()[1])] = True
|
||||||
try:
|
try:
|
||||||
network.connectionpool.BMConnectionPool().addConnection(TCPConnection(sock=sock))
|
network.connectionpool.BMConnectionPool().addConnection(TCPConnection(sock=sock))
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
|
|
@ -25,6 +25,8 @@ maximumNumberOfHalfOpenConnections = 0
|
||||||
|
|
||||||
invThread = None
|
invThread = None
|
||||||
|
|
||||||
|
ownAddresses = {}
|
||||||
|
|
||||||
# If the trustedpeer option is specified in keys.dat then this will
|
# If the trustedpeer option is specified in keys.dat then this will
|
||||||
# contain a Peer which will be connected to instead of using the
|
# contain a Peer which will be connected to instead of using the
|
||||||
# addresses advertised by other peers. The client will only connect to
|
# addresses advertised by other peers. The client will only connect to
|
||||||
|
|
Reference in New Issue
Block a user