Add exit watch
This commit is contained in:
parent
487f531a8c
commit
d518805770
|
@ -9,8 +9,11 @@ url = "https://onionoo.torproject.org/details"
|
|||
r = requests.get(url)
|
||||
relays = json.loads(r.content)["relays"]
|
||||
|
||||
email = "From: relay status <relaystatus@encryptionin.space>\nTo: relaywatch@lists.encryptionin.space\nSubject: Relay Status " + datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H') + "\n\n"
|
||||
status = ""
|
||||
relayWatchEmail = "From: relay status <relaystatus@encryptionin.space>\nTo: relaywatch@lists.encryptionin.space\nSubject: Relay Status " + datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H') + "\n\n"
|
||||
relayStatus = ""
|
||||
|
||||
exitWatchEmail = "From: relay status <relaystatus@encryptionin.space>\nTo: exitwatch@lists.encryptionin.space\nSubject: Exit Status " + datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H') + "\n\n"
|
||||
exitStatus = ""
|
||||
|
||||
newVersions = 0
|
||||
|
||||
|
@ -19,15 +22,24 @@ for new_relay in relays:
|
|||
exit = "no"
|
||||
if new_relay["exit_policy"][0] != "reject *:*":
|
||||
exit = "yes"
|
||||
status += "New relay: \"" + new_relay["nickname"] + "\", fingerprint: " + new_relay["fingerprint"] + ", potential exit: " + exit + ", effective family size: " + str(len(new_relay["effective_family"])-1) + "; https://metrics.torproject.org/rs.html#search/" + new_relay["fingerprint"] + "\n"
|
||||
exitStatus += "New exit: \"" + new_relay["nickname"] + "\", fingerprint: " + new_relay["fingerprint"] + ", effective family size: " + str(len(new_relay["effective_family"])-1) + "; https://metrics.torproject.org/rs.html#search/" + new_relay["fingerprint"] + "\n"
|
||||
relayStatus += "New relay: \"" + new_relay["nickname"] + "\", fingerprint: " + new_relay["fingerprint"] + ", potential exit: " + exit + ", effective family size: " + str(len(new_relay["effective_family"])-1) + "; https://metrics.torproject.org/rs.html#search/" + new_relay["fingerprint"] + "\n"
|
||||
|
||||
if re.search("0.3.5.17|0.4.5.11", new_relay["platform"], re.IGNORECASE):
|
||||
newVersions += 1
|
||||
|
||||
if status:
|
||||
email += status + "\nTotal new versions: " + str(newVersions) + "\n"
|
||||
if relayStatus:
|
||||
relayWatchEmail += relayStatus + "\nTotal new versions: " + str(newVersions) + "\n"
|
||||
try:
|
||||
smtp = smtplib.SMTP('localhost')
|
||||
smtp.sendmail('relaystatus@encryptionin.space', ['relaywatch@lists.encryptionin.space'], email)
|
||||
smtp.sendmail('relaystatus@encryptionin.space', ['relaywatch@lists.encryptionin.space'], relayWatchEmail)
|
||||
except:
|
||||
print("couldn't send")
|
||||
|
||||
if exitStatus:
|
||||
exitWatchEmail += exitStatus
|
||||
try:
|
||||
smtp = smtplib.SMTP('localhost')
|
||||
smtp.sendmail('relaystatus@encryptionin.space', ['exitwatch@lists.encryptionin.space'], exitWatchEmail)
|
||||
except:
|
||||
print("couldn't send")
|
||||
|
|
Loading…
Reference in a new issue