Don't send private ip addresses on pex

This commit is contained in:
shortcutme 2018-01-30 13:58:01 +01:00
parent a6f86329c5
commit c2edbb30b5
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
5 changed files with 28 additions and 5 deletions

View file

@ -103,5 +103,16 @@ class TestFileRequest:
assert peer_file_server.pex()
assert "1.2.3.4:11337" in site_temp.peers
# Should not exchange private peers from local network
fake_peer_private = site.addPeer("192.168.0.1", 11337, return_peer=True)
assert fake_peer_private not in site.getConnectablePeers(allow_private=False)
fake_peer_private.connection = Connection(file_server, "192.168.0.1", 11337)
fake_peer_private.connection.last_recv_time = time.time()
assert "192.168.0.1:11337" not in site_temp.peers
assert not peer_file_server.pex()
assert "192.168.0.1:11337" not in site_temp.peers
connection.close()
client.stop()