[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [depictor/master] Indicate Fallback Directory mirrors
commit feb0d6b24d1f1081e8ffb8935a04dbf456a7e7b1
Author: Tom Ritter <tom@xxxxxxxxx>
Date: Sat Oct 15 23:31:58 2016 -0400
Indicate Fallback Directory mirrors
---
website.py | 15 +++++++++++++++
write_website.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/website.py b/website.py
index 23d48e1..b0eb68c 100755
--- a/website.py
+++ b/website.py
@@ -17,6 +17,7 @@ from Crypto.PublicKey import RSA
class WebsiteWriter:
consensus = None
votes = None
+ fallback_dirs = None
known_authorities = []
consensus_expirey = datetime.timedelta(hours=3)
directory_key_warning_time = datetime.timedelta(days=14)
@@ -58,6 +59,8 @@ class WebsiteWriter:
def set_config(self, config):
self.known_params = config['known_params']
self.bandwidth_authorities = config['bandwidth_authorities']
+ def set_fallback_dirs(self, fallback_dirs):
+ self.fallback_dirs = fallback_dirs
def get_consensus_time(self):
return self.consensus.valid_after
@@ -937,6 +940,7 @@ class WebsiteWriter:
if vote.routers[relay_fp].measured >= 0L:
self.site.write(" <br />" if flagsWritten > 0 else "")
self.site.write("bw=" + str(vote.routers[relay_fp].measured))
+ flagsWritten += 1
self.site.write("</td>\n");
else:
@@ -956,6 +960,14 @@ class WebsiteWriter:
if self.consensus.routers[relay_fp].bandwidth >= 0L:
self.site.write(" <br />" if flagsWritten > 0 else "")
self.site.write("bw=" + str(self.consensus.routers[relay_fp].bandwidth))
+ flagsWritten += 1
+
+ if relay_fp in self.fallback_dirs:
+ self.site.write(" <br />" if flagsWritten > 0 else "")
+ self.site.write("FallbackDir")
+ if 'disappeared_version' in self.fallback_dirs[relay_fp]:
+ self.site.write('(<' + self.fallback_dirs[relay_fp]['disappeared_version'] + ')')
+ flagsWritten += 1
self.site.write("</td>\n")
else:
@@ -998,6 +1010,9 @@ if __name__ == '__main__':
w.set_consensuses(c)
v = pickle.load(open('votes.p', 'rb'))
w.set_votes(v)
+ f = pickle.load(open('fallback_dirs.p', 'rb'))
+ w.set_fallback_dirs(f)
+
CONFIG = stem.util.conf.config_dict('consensus', {
'ignored_authorities': [],
diff --git a/write_website.py b/write_website.py
index ddb5a47..8fca41e 100755
--- a/write_website.py
+++ b/write_website.py
@@ -63,6 +63,49 @@ def main():
f.write("%s,%i,%i\n" % (ds, time.time() * 1000, int(consensus_fetching_runtimes[ds] * 1000)))
f.close()
+ # Calculate the fallback directory info
+ import re
+ import urllib
+
+ GITWEB_FALLBACK_DIR_URL = 'https://gitweb.torproject.org/tor.git/plain/src/or/fallback_dirs.inc'
+ fallback_lines = urllib.urlopen(GITWEB_FALLBACK_DIR_URL).read()
+
+ fallback_dirs, attr = {}, {}
+ for line in fallback_lines.splitlines():
+ if line.startswith('"') or line.startswith('/*') or line.startswith(' *'):
+ if line.startswith('"'):
+ info_line_match = False
+ addr_line_match = re.match('"([\d\.]+):(\d+) orport=(\d+) id=([\dA-F]{40}).*', line)
+ ipv6_line_match = re.match('" ipv6=\[([\da-f:]+)\]:(\d+)"', line)
+ else:
+ info_line_match = re.match('\/\* Fallback was on (.+) list, but (.*) before (.+)', line)
+ addr_line_match = re.match(' * "([\d\.]+):(\d+) orport=(\d+) id=([\dA-F]{40}).*', line)
+ ipv6_line_match = re.match(' * " ipv6=\[([\da-f:]+)\]:(\d+)"', line)
+
+ if info_line_match:
+ appeared_version, removed_reason, disappeared_version = info_line_match.groups()
+
+ attr['appeared_version'] = appeared_version
+ attr['removed_reason'] = removed_reason
+ attr['disappeared_version'] = disappeared_version
+ elif addr_line_match:
+ address, dir_port, or_port, fingerprint = addr_line_match.groups()
+
+ attr['address'] = address
+ attr['or_port'] = int(or_port)
+ attr['dir_port'] = int(dir_port)
+ attr['fingerprint'] = fingerprint
+ elif ipv6_line_match:
+ address, port = ipv6_line_match.groups()
+
+ attr['orport_v6'] = (address, int(port))
+ elif '" weight=' in line and 'fingerprint' in attr:
+ fallback_dirs[attr.get('fingerprint')] = attr
+
+ attr = {}
+ # great for debugging
+ #import pickle
+ #pickle.dump(fallback_dirs, open('fallback_dirs.p', 'wb'))
# Calculate the number of known and measured relays for each dirauth and insert it into the database
databaseDirAuths = "faravahar, gabelmoo, dizum, moria1, urras, maatuska, longclaw, tor26, dannenberg, turtles".split(", ")
@@ -117,6 +160,7 @@ def main():
w = WebsiteWriter()
w.set_consensuses(consensuses)
w.set_votes(votes)
+ w.set_fallback_dirs(fallback_dirs)
w.set_config(CONFIG)
w.write_website(os.path.join(os.path.dirname(__file__), 'out', 'consensus-health.html'), True)
w.write_website(os.path.join(os.path.dirname(__file__), 'out', 'index.html'), False)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits