dont probe and ignore bad peers

This commit is contained in:
Victor Shyba 2022-01-25 17:00:37 -03:00
parent dd5b9ca81b
commit f274562c92

View file

@ -142,6 +142,8 @@ class IterativeFinder:
return not self.closest_peer or self.distance.is_closer(peer.node_id, self.closest_peer.node_id)
def _add_active(self, peer):
if self.peer_manager.peer_is_good(peer) is False:
return
if peer not in self.active and peer.node_id and peer.node_id != self.protocol.node_id:
self.active.add(peer)
if self._is_closer(peer):
@ -193,6 +195,9 @@ class IterativeFinder:
continue
if origin_address == (self.protocol.external_ip, self.protocol.udp_port):
continue
if self.peer_manager.peer_is_good(peer) is False:
self.active.discard(peer)
continue
self._schedule_probe(peer)
added += 1
log.debug("running %d probes for key %s", len(self.running_probes), self.key.hex()[:8])