[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [depictor/master] Do not color missing Reveal values in red unless they shouldn't be missing. Closes #22050
commit d23a06ca4ae5d8263828c3662347b733ae2b7fff
Author: Tom Ritter <tom@xxxxxxxxx>
Date: Fri May 12 00:52:05 2017 -0500
Do not color missing Reveal values in red unless they shouldn't be missing. Closes #22050
---
website.py | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/website.py b/website.py
index 8c32b66..b9f81ff 100755
--- a/website.py
+++ b/website.py
@@ -16,7 +16,7 @@ from Crypto.PublicKey import RSA
import stem.descriptor.remote
-from utility import get_dirauths, get_bwauths
+from utility import get_dirauths, get_bwauths, unix_time
class WebsiteWriter:
consensus = None
@@ -608,9 +608,31 @@ class WebsiteWriter:
s = "["
s += "V:" + str(sr.version) + " "
s += "A:" + str(sr.algorithm) + " "
- s += "C:" + sr.commit if sr.commit else "<span class=\"oiv\">(Empty)</span>"
- s += "R:" + sr.reveal if sr.reveal else "<span class=\"oiv\">(Empty)</span>"
+ s += "C:" + (sr.commit if sr.commit else "<span class=\"oiv\">(Empty)</span>")
+ s += "R:"
+ if sr.reveal:
+ s += sr.reveal
+ else:
+ errorCondition = self.doICareAboutMissingRevealValues()
+ if errorCondition:
+ s += "<span class=\"oiv\">"
+ s += "(Empty)"
+ if errorCondition:
+ s += "</span>"
return s + "]"
+ def doICareAboutMissingRevealValues(self):
+ # Copied from get_sr_protocol_phase()
+ # in https://gitweb.torproject.org/tor.git/tree/src/or/shared_random_state.c#n190
+ SHARED_RANDOM_N_ROUNDS = 12
+ SHARED_RANDOM_N_PHASES = 2
+ total_periods = SHARED_RANDOM_N_ROUNDS / SHARED_RANDOM_N_PHASES
+ voting_interval = self.consensus.fresh_until - self.consensus.valid_after
+ current_slot = (unix_time(self.consensus.valid_after) / 1000 / voting_interval.seconds) % total_periods
+
+ if current_slot < SHARED_RANDOM_N_ROUNDS:
+ return False
+ else:
+ return True
def _write_shared_random(self):
"""
Write the shared random information of each directory authority
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits