|
|
@ -148,6 +148,10 @@ class PeerManager(object): |
|
|
|
self.logger.error(f'could not retrieve blacklist from {url}: {e}') |
|
|
|
await sleep(600) |
|
|
|
|
|
|
|
def _is_blacklisted(self, host): |
|
|
|
return any(item in self.blacklist |
|
|
|
for item in (host, '*.' + '.'.join(host.split('.')[-2:]))) |
|
|
|
|
|
|
|
async def _detect_proxy(self): |
|
|
|
'''Detect a proxy if we don't have one and some time has passed since |
|
|
|
the last attempt. |
|
|
@ -296,6 +300,9 @@ class PeerManager(object): |
|
|
|
return False |
|
|
|
|
|
|
|
async def _verify_peer(self, session, peer): |
|
|
|
if self._is_blacklisted(peer.host): |
|
|
|
raise BadPeerError('blacklisted') |
|
|
|
|
|
|
|
if not peer.is_tor: |
|
|
|
address = session.peer_address() |
|
|
|
if address: |
|
|
@ -479,7 +486,7 @@ class PeerManager(object): |
|
|
|
|
|
|
|
return permit |
|
|
|
|
|
|
|
def on_peers_subscribe(self, is_tor, is_peer): |
|
|
|
def on_peers_subscribe(self, is_tor): |
|
|
|
'''Returns the server peers as a list of (ip, host, details) tuples. |
|
|
|
|
|
|
|
We return all peers we've connected to in the last day. |
|
|
@ -492,12 +499,7 @@ class PeerManager(object): |
|
|
|
not peer.bad and peer.is_public] |
|
|
|
onion_peers = [] |
|
|
|
|
|
|
|
def is_blacklisted(host): |
|
|
|
return any(item in self.blacklist |
|
|
|
for item in (host, '*.' + '.'.join(host.split('.')[-2:]))) |
|
|
|
|
|
|
|
if not is_peer: |
|
|
|
recent = [peer for peer in recent if not is_blacklisted(peer.host)] |
|
|
|
recent = [peer for peer in recent if not self._is_blacklisted(peer.host)] |
|
|
|
|
|
|
|
# Always report ourselves if valid (even if not public) |
|
|
|
peers = set(myself for myself in self.myselves |
|
|
|