[tor-commits] [depictor/master] Add a Protocol section for #20762

tom at torproject.org tom at torproject.org
Wed Jan 4 20:06:45 UTC 2017


commit 59cf04d4dc0211793764a4c5a8d860e1b7e87967
Author: Tom Ritter <tom at ritter.vg>
Date:   Wed Jan 4 14:05:44 2017 -0600

    Add a Protocol section for #20762
---
 website.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/website.py b/website.py
index 232c046..6bb3e6d 100755
--- a/website.py
+++ b/website.py
@@ -39,6 +39,7 @@ class WebsiteWriter:
 		self._write_recommended_versions()
 		self._write_consensus_parameters()
 		self._write_authority_keys()
+		self._write_protocols()
 		self._write_bandwidth_scanner_status(True)
 		self._write_fallback_directory_status(True)
 		self._write_authority_versions()
@@ -540,6 +541,98 @@ class WebsiteWriter:
 			+ "</p>\n")
 
 	#-----------------------------------------------------------------------------------------
+	def protocolsToString(self, keys, v, c=None):
+		s = ""
+		for k in keys:
+			s += k + "="
+			if c and c[k] != v[k]:
+				s += "<span class=\"oiv\">"
+			s += ",".join([str(i) for i in v[k]])
+			if c and c[k] != v[k]:
+				s += "</span>"
+			s += " "
+		return s
+	def _write_protocols(self):
+		"""
+		Write the recommended and required protocols
+		"""
+		self.site.write("<br>\n\n\n"
+		+ " <!-- ================================================================= -->"
+		+ "<a name=\"protocols\">\n"
+		+ "<h3><a href=\"#protocols\" class=\"anchor\">"
+		+ "Protocols</a></h3>\n"
+		+ "<br>\n"
+		+ "<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" summary=\"\">\n"
+		+ "  <colgroup>\n"
+		+ "    <col width=\"140\">\n"
+		+ "    <col width=\"180\">\n"
+		+ "    <col width=\"480\">\n"
+		+ "  </colgroup>\n")		
+		if not self.votes:
+			self.site.write("  <tr><td>(No votes.)</td><td></td></tr>\n")
+		else:
+			protocol_keys = set()
+			for dirauth_nickname in self.known_authorities:
+				if dirauth_nickname in self.votes:
+					vote = self.votes[dirauth_nickname]
+					protocol_keys = protocol_keys.union(vote.recommended_client_protocols.keys())
+					protocol_keys = protocol_keys.union(vote.required_client_protocols.keys())
+					protocol_keys = protocol_keys.union(vote.recommended_relay_protocols.keys())
+					protocol_keys = protocol_keys.union(vote.required_relay_protocols.keys())
+			protocol_keys = list(protocol_keys)
+			protocol_keys.sort()
+			for dirauth_nickname in self.known_authorities:
+				if dirauth_nickname in self.votes:
+					vote = self.votes[dirauth_nickname]
+
+					self.site.write("  <tr>\n"
+					+ "    <td>" + dirauth_nickname + "</td>\n"
+					+ "    <td>Recommended Client</td>\n"
+					+ "    <td>" + self.protocolsToString(protocol_keys, vote.recommended_client_protocols, self.consensus.recommended_client_protocols) + "</td>\n"
+					+ "  </tr>\n"
+					+ "  <tr>\n"
+					+ "    <td></td>\n"
+					+ "    <td>Required Client</td>\n"
+					+ "    <td>" + self.protocolsToString(protocol_keys, vote.required_client_protocols, self.consensus.required_client_protocols) + "</td>\n"
+					+ "  </tr>\n"
+					+ "  <tr>\n"
+					+ "    <td></td>\n"
+					+ "    <td>Recommended Relay</td>\n"
+					+ "    <td>" + self.protocolsToString(protocol_keys, vote.recommended_relay_protocols, self.consensus.recommended_relay_protocols) + "</td>\n"
+					+ "  </tr>\n"
+					+ "  <tr>\n"
+					+ "    <td></td>\n"
+					+ "    <td>Required Relay</td>\n"
+					+ "    <td>" + self.protocolsToString(protocol_keys, vote.required_relay_protocols, self.consensus.required_relay_protocols) + "</td>\n"
+					+ "  </tr>\n")
+				else:
+					self.site.write("  <tr>\n"
+					+ "    <td>" + dirauth_nickname + "</td>\n"
+					+ "    <td colspan=\"2\" class=\"oiv\">Vote Not Present</td>\n"	
+					+ "  </tr>\n")
+			self.site.write("  <tr>\n"
+			+ "    <td class=\"ic\">consensus</td>\n"
+			+ "    <td class=\"ic\">Recommended Client</td>\n"
+			+ "    <td class=\"ic\">" + self.protocolsToString(protocol_keys, self.consensus.recommended_client_protocols) + "</td>\n"
+			+ "  </tr>\n"
+			+ "  <tr>\n"
+			+ "    <td></td>\n"
+			+ "    <td class=\"ic\">Required Client</td>\n"
+			+ "    <td class=\"ic\">" + self.protocolsToString(protocol_keys, self.consensus.required_client_protocols) + "</td>\n"
+			+ "  </tr>\n"
+			+ "  <tr>\n"
+			+ "    <td></td>\n"
+			+ "    <td class=\"ic\">Recommended Relay</td>\n"
+			+ "    <td class=\"ic\">" + self.protocolsToString(protocol_keys, self.consensus.recommended_relay_protocols) + "</td>\n"
+			+ "  </tr>\n"
+			+ "  <tr>\n"
+			+ "    <td></td>\n"
+			+ "    <td class=\"ic\">Required Relay</td>\n"
+			+ "    <td class=\"ic\">" + self.protocolsToString(protocol_keys, self.consensus.required_relay_protocols) + "</td>\n"
+			+ "  </tr>\n"
+			+ "</table>\n")
+
+	#-----------------------------------------------------------------------------------------
 	def _write_bandwidth_scanner_status(self, linkToGraph):
 		"""
 		Write the status of bandwidth scanners and results being contained in votes.



More information about the tor-commits mailing list