Hash bridge fingerprints the Tor way so Onionoo will find them

parent 72cfbe69
#!/usr/bin/env python3
import requests
import sys
import hashlib
import json
import os
import re
import json
import sys
from binascii import a2b_hex
import requests
URL_DETAILS = "https://onionoo.torproject.org/details?"
......@@ -49,7 +51,8 @@ def get_fingerprints(torrc):
def print_health_check(fingerprint):
print("Checking bridge %s..." % fingerprint)
# Search Onionoo for bridge
url = URL_DETAILS + "fingerprint=%s" % fingerprint
hashed_fingerprint = get_tor_sha1(fingerprint)
url = URL_DETAILS + "lookup=%s" % hashed_fingerprint
response = requests.get(url)
bridges = json.loads(response.content)['bridges']
if len(bridges) != 1:
......@@ -84,6 +87,12 @@ def print_health_check(fingerprint):
return True
def get_tor_sha1(to_hash):
sha1 = hashlib.sha1()
sha1.update(a2b_hex(to_hash))
return sha1.hexdigest()
def fail(msg=""):
sys.stderr.write("Error: %s\n" % msg)
sys.exit(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment