Skip to content

Instantly share code, notes, and snippets.

@xoriole
Created June 20, 2019 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xoriole/77a149a321b50bd57b5b88e99721b194 to your computer and use it in GitHub Desktop.
Save xoriole/77a149a321b50bd57b5b88e99721b194 to your computer and use it in GitHub Desktop.
Generates Tribler community version file
import base64
import json
from binascii import unhexlify
import requests
from ipv8.keyvault.crypto import default_eccrypto
def get_version():
events_url = "http://localhost:8085/events"
stream = requests.get(events_url, stream=True)
return json.loads(stream.iter_content(256).next())['event']['version']
def write_community_id_to_file(filename):
with open(filename, 'wb') as file:
overlay_url = "http://localhost:8085/ipv8/overlays"
response_json = requests.get(overlay_url).json()
for overlay in response_json['overlays']:
community_id = base64.b64encode(default_eccrypto.key_from_public_bin(unhexlify(overlay['master_peer'])).key_to_hash())
file.write("%s:%s\n" % (overlay["overlay_name"], community_id))
if __name__ == '__main__':
version = get_version()
version_file = "%s.txt" % version
write_community_id_to_file(version_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment