Accept only 30 peers on pex

This commit is contained in:
ZeroNet 2016-08-10 12:44:00 +02:00
parent 122ef02605
commit 07a6bd523c

View file

@ -280,9 +280,9 @@ class Peer(object):
if not res or "error" in res: if not res or "error" in res:
return False return False
# Unpack IP4 # Unpack IP4
back = {key: map(helper.unpackAddress, val) for key, val in res["peers"].iteritems()} back = {key: map(helper.unpackAddress, val) for key, val in res["peers"].items()[0:30]}
# Unpack onion # Unpack onion
for hash, onion_peers in res.get("peers_onion", {}).iteritems(): for hash, onion_peers in res.get("peers_onion", {}).items()[0:30]:
if not hash in back: if not hash in back:
back[hash] = [] back[hash] = []
back[hash] += map(helper.unpackOnionAddress, onion_peers) back[hash] += map(helper.unpackOnionAddress, onion_peers)