Browse Source

first commit

master
HackerNCoder 2 months ago
commit
3c7fa571bb
  1. 1
      .gitconfig
  2. 8
      download_onionoo.py
  3. 34
      relaystatus.py

1
.gitconfig

@ -0,0 +1 @@
onionoo_details

8
download_onionoo.py

@ -0,0 +1,8 @@
import requests
import os
url = "https://onionoo.torproject.org/details"
r = requests.get(url)
with open("onionoo_details", "w") as output:
output.write(r.text)

34
relaystatus.py

@ -0,0 +1,34 @@
import requests
import os
import json
import jsondiff as jd
from jsondiff import diff
old_file = "onionoo_details"
url = "https://onionoo.torproject.org/details"
r = requests.get(url)
relays = json.loads(r.content)["relays"]
old_text = open(old_file, "r").read()
old_text = json.loads(old_text)["relays"]
diff1 = diff(old_text, relays, syntax='symmetric')
for new_relay in diff1[jd.insert]:
exit = "no"
if new_relay[1]["exit_policy"][0] != "reject *:*":
exit = "yes"
print("New relay: \"" + new_relay[1]["nickname"], "\", fingerpint: " + new_relay[1]["fingerprint"] + ", potential exit: " + exit + ", effective family size: " + str(len(new_relay[1]["effective_family"])))
for updated_relay in diff1:
if updated_relay != jd.insert and updated_relay != jd.delete:
if "flags" in diff1[updated_relay]:
relay = old_text[updated_relay]
new_flags = ""
for flag in diff1[updated_relay]["flags"][jd.insert]:
new_flags = new_flags+flag[1]+","
print("\"" + relay["nickname"] + "\" (" + relay["fingerprint"] + ") got new flag(s): \"" + new_flags + "\"")
with open(old_file, "w") as output:
output.write(r.text)
Loading…
Cancel
Save