[tor-commits] [doctor/master] Adding support for ignored authorities

atagar at torproject.org atagar at torproject.org
Wed Jun 18 16:58:02 UTC 2014


commit 3fcbb971d84dc634846fb7808e95b25c471c8e25
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Jun 18 09:49:16 2014 -0700

    Adding support for ignored authorities
    
    Adding a config option to the consensus health checker to exclude particular
    authorities from notifications.
---
 consensus_health_checker.py |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/consensus_health_checker.py b/consensus_health_checker.py
index cc2b4ab..18ea748 100755
--- a/consensus_health_checker.py
+++ b/consensus_health_checker.py
@@ -29,9 +29,10 @@ Runlevel = stem.util.enum.UppercaseEnum("NOTICE", "WARNING", "ERROR")
 DIRECTORY_AUTHORITIES = stem.descriptor.remote.get_authorities()
 EMAIL_SUBJECT = 'Consensus issues'
 
-CONFIG = stem.util.conf.config_dict("consensus_health", {
+CONFIG = stem.util.conf.config_dict('consensus_health', {
   'msg': {},
   'suppression': {},
+  'ignored_authorities': [],
   'bandwidth_authorities': [],
   'known_params': [],
 })
@@ -121,7 +122,7 @@ def rate_limit_notice(key, hours = 0, days = 0):
   if hours == 0 and days == 0:
     return True
 
-  config = stem.util.conf.get_config("last_notified")
+  config = stem.util.conf.get_config('last_notified')
   config_path = util.get_path('data', 'last_notified.cfg')
 
   try:
@@ -145,6 +146,11 @@ def rate_limit_notice(key, hours = 0, days = 0):
     return False
 
 
+ at lru_cache()
+def directory_authorities():
+  return dict((k, v) for (k, v) in DIRECTORY_AUTHORITIES.items() if k not in CONFIG['ignored_authorities'])
+
+
 def main():
   start_time = time.time()
 
@@ -416,7 +422,7 @@ def has_all_signatures(latest_consensus, consensuses, votes):
 
       missing_authority = missing_signature
 
-      for authority in DIRECTORY_AUTHORITIES.values():
+      for authority in directory_authorities().values():
         if authority.v3ident == missing_signature:
           missing_authority = authority.nickname
           break
@@ -466,9 +472,9 @@ def has_authority_flag(latest_consensus, consensuses, votes):
     if Flag.AUTHORITY in desc.flags:
       seen_authorities.add(desc.nickname)
 
-  known_authorities = set(DIRECTORY_AUTHORITIES.keys())
+  known_authorities = set(directory_authorities().keys())
   missing_authorities = known_authorities.difference(seen_authorities)
-  extra_authorities = seen_authorities.difference(known_authorities)
+  extra_authorities = seen_authorities.difference(known_authorities - set(CONFIG['ignored_authorities']))
 
   issues = []
 
@@ -486,8 +492,8 @@ def has_expected_fingerprints(latest_consensus, consensuses, votes):
 
   issues = []
   for desc in latest_consensus.routers.values():
-    if desc.nickname in DIRECTORY_AUTHORITIES and Flag.NAMED in desc.flags:
-      expected_fingerprint = DIRECTORY_AUTHORITIES[desc.nickname].fingerprint
+    if desc.nickname in directory_authorities() and Flag.NAMED in desc.flags:
+      expected_fingerprint = directory_authorities()[desc.nickname].fingerprint
 
       if desc.fingerprint != expected_fingerprint:
         issues.append(Issue(Runlevel.ERROR, 'FINGERPRINT_MISMATCH', authority = desc.nickname, expected = desc.fingerprint, actual = expected_fingerprint))
@@ -501,7 +507,7 @@ def is_recommended_versions(latest_consensus, consensuses, votes):
   outdated_authorities = {}
   min_version = min(latest_consensus.server_versions)
 
-  for authority in DIRECTORY_AUTHORITIES.values():
+  for authority in directory_authorities().values():
     desc = latest_consensus.routers.get(authority.fingerprint)
 
     if desc and desc.version and desc.version < min_version:
@@ -582,7 +588,7 @@ def get_votes():
 def _get_documents(label, resource):
   queries, documents, issues = {}, {}, []
 
-  for authority in DIRECTORY_AUTHORITIES.values():
+  for authority in directory_authorities().values():
     if authority.v3ident is None:
       continue  # not a voting authority
 
@@ -599,7 +605,7 @@ def _get_documents(label, resource):
       if label == 'vote':
         # try to download the vote via the other authorities
 
-        v3ident = DIRECTORY_AUTHORITIES[authority].v3ident
+        v3ident = directory_authorities()[authority].v3ident
 
         query = downloader.query(
           '/tor/status-vote/current/%s' % v3ident,





More information about the tor-commits mailing list