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
|
||||
if chosen.host in self.inboundConnections:
|
||||
continue
|
||||
# don't connect to self
|
||||
if chosen.host in state.ownAddresses:
|
||||
continue
|
||||
|
||||
#for c in self.outboundConnections:
|
||||
# if chosen == c.destination:
|
||||
|
|
|
@ -205,6 +205,7 @@ class TCPServer(AdvancedDispatcher):
|
|||
pair = self.accept()
|
||||
if pair is not None:
|
||||
sock, addr = pair
|
||||
state.ownAddresses[state.Peer(sock.getsockname()[0], sock.getsockname()[1])] = True
|
||||
try:
|
||||
network.connectionpool.BMConnectionPool().addConnection(TCPConnection(sock=sock))
|
||||
except socket.error:
|
||||
|
|
|
@ -25,6 +25,8 @@ maximumNumberOfHalfOpenConnections = 0
|
|||
|
||||
invThread = None
|
||||
|
||||
ownAddresses = {}
|
||||
|
||||
# If the trustedpeer option is specified in keys.dat then this will
|
||||
# contain a Peer which will be connected to instead of using the
|
||||
# addresses advertised by other peers. The client will only connect to
|
||||
|
|
Reference in New Issue
Block a user