[tor-commits] [depictor/master] Add the ReachableIPv6 pseudoflag. Closes 24287

tom at torproject.org tom at torproject.org
Fri Nov 17 17:51:17 UTC 2017


commit 5a8e4af0d4a1b7ea62a79d37eda63b3a5c6bcd6c
Author: Tom Ritter <tom at ritter.vg>
Date:   Fri Nov 17 11:49:35 2017 -0600

    Add the ReachableIPv6 pseudoflag. Closes 24287
---
 website.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/website.py b/website.py
index ded0fce..c71e486 100755
--- a/website.py
+++ b/website.py
@@ -29,7 +29,10 @@ class WebsiteWriter:
 	directory_key_warning_time = datetime.timedelta(days=14)
 	config = {}
 	known_params = []
+	already_added_pseudoflags = False
 	def write_website(self, filename, include_relay_info=True):
+		if not self.already_added_pseudoflags:
+			self._add_pseudo_flags()
 		self.site = open(filename, 'w')
 		self._write_page_header(include_relay_info)
 		self._write_valid_after_time()
@@ -76,6 +79,29 @@ class WebsiteWriter:
 		return self.consensus.valid_after
 
 	#-----------------------------------------------------------------------------------------
+	def _add_pseudo_flags(self):
+		"""
+		Add any calculated or otherwise pseudoflags to the data structures
+		"""
+		self.already_added_pseudoflags = True
+
+		# Add the ReachableIPv6 flag
+		for dirauth_nickname in self.known_authorities:
+			if dirauth_nickname in self.votes:
+				vote = self.votes[dirauth_nickname]
+				has_ipv6 = False
+				for r in vote.routers:
+					if len([a for a in vote.routers[r].or_addresses if a[2] == True]):
+						has_ipv6 = True
+						vote.routers[r].flags.append('ReachableIPv6')
+				if has_ipv6:
+					vote.known_flags.append('ReachableIPv6')
+		for r in self.consensus.routers:
+			if len([a for a in self.consensus.routers[r].or_addresses if a[2] == True]):
+				self.consensus.routers[r].flags.append('ReachableIPv6')
+		self.consensus.known_flags.append('ReachableIPv6')
+
+	#-----------------------------------------------------------------------------------------
 	def _write_page_header(self, include_relay_info):
 		"""
 		Write the HTML page header including the metrics website navigation.



More information about the tor-commits mailing list