Don't try to connect to onion addresses if not supported by the client
This commit is contained in:
parent
bf10cdef63
commit
88f2b39576
2 changed files with 10 additions and 3 deletions
|
@ -823,7 +823,7 @@ class Site(object):
|
||||||
self.log.debug("Need connections: %s, Current: %s, Total: %s" % (need, connected, len(self.peers)))
|
self.log.debug("Need connections: %s, Current: %s, Total: %s" % (need, connected, len(self.peers)))
|
||||||
|
|
||||||
if connected < need: # Need more than we have
|
if connected < need: # Need more than we have
|
||||||
for peer in list(self.peers.values()):
|
for peer in self.getRecentPeers(30):
|
||||||
if not peer.connection or not peer.connection.connected: # No peer connection or disconnected
|
if not peer.connection or not peer.connection.connected: # No peer connection or disconnected
|
||||||
peer.pex() # Initiate peer exchange
|
peer.pex() # Initiate peer exchange
|
||||||
if peer.connection and peer.connection.connected:
|
if peer.connection and peer.connection.connected:
|
||||||
|
@ -849,6 +849,8 @@ class Site(object):
|
||||||
continue # Not connectable
|
continue # Not connectable
|
||||||
if not peer.connection:
|
if not peer.connection:
|
||||||
continue # No connection
|
continue # No connection
|
||||||
|
if peer.ip.endswith(".onion") and not self.connection_server.tor_manager.enabled:
|
||||||
|
continue # Onion not supported
|
||||||
if peer.key in ignore:
|
if peer.key in ignore:
|
||||||
continue # The requester has this peer
|
continue # The requester has this peer
|
||||||
if time.time() - peer.connection.last_recv_time > 60 * 60 * 2: # Last message more than 2 hours ago
|
if time.time() - peer.connection.last_recv_time > 60 * 60 * 2: # Last message more than 2 hours ago
|
||||||
|
@ -884,8 +886,13 @@ class Site(object):
|
||||||
|
|
||||||
# Add random peers
|
# Add random peers
|
||||||
need_more = need_num - len(found)
|
need_more = need_num - len(found)
|
||||||
|
if not self.connection_server.tor_manager.enabled:
|
||||||
|
peers = [peer for peer in self.peers.values() if not peer.ip.endswith(".onion")]
|
||||||
|
else:
|
||||||
|
peers = list(self.peers.values())
|
||||||
|
|
||||||
found_more = sorted(
|
found_more = sorted(
|
||||||
list(self.peers.values())[0:need_more * 50],
|
peers[0:need_more * 50],
|
||||||
key=lambda peer: peer.reputation,
|
key=lambda peer: peer.reputation,
|
||||||
reverse=True
|
reverse=True
|
||||||
)[0:need_more * 2]
|
)[0:need_more * 2]
|
||||||
|
|
|
@ -260,7 +260,7 @@ class SiteAnnouncer(object):
|
||||||
peers = self.site.getConnectedPeers()
|
peers = self.site.getConnectedPeers()
|
||||||
|
|
||||||
if len(peers) == 0: # Small number of connected peers for this site, connect to any
|
if len(peers) == 0: # Small number of connected peers for this site, connect to any
|
||||||
peers = list(self.site.peers.values())
|
peers = list(self.site.getRecentPeers(20))
|
||||||
need_num = 10
|
need_num = 10
|
||||||
|
|
||||||
random.shuffle(peers)
|
random.shuffle(peers)
|
||||||
|
|
Loading…
Reference in a new issue