commit 5303c453120378be89c478ce1cc40db5302c44ec Author: Starlight starlight@binnacle.cx Date: Sat Dec 28 14:51:19 2019 -0500
resolve ticket 32842
replace hard coded exclusion of authority tor26 with three lists that during checks determine which authorities to not a) check reachability for b) check presence in consensus for c) request and validate documents from
correct defect where router-line IPv4 OR address was not checked for reachability
eliminate Python 3 exception by truncating array index expression result to integer (further 2to3 revisions applied during testing but not committed) --- consensus_health_checker.py | 27 ++++++++++++++++++++------- descriptor_checker.py | 8 ++++++-- 2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/consensus_health_checker.py b/consensus_health_checker.py index eb4620c..cb512b0 100755 --- a/consensus_health_checker.py +++ b/consensus_health_checker.py @@ -26,7 +26,12 @@ from stem.util.lru_cache import lru_cache Runlevel = stem.util.enum.UppercaseEnum('NOTICE', 'WARNING', 'ERROR')
DIRECTORY_AUTHORITIES = stem.directory.Authority.from_cache() -del DIRECTORY_AUTHORITIES['tor26'] # DirPort does not service requests without a '.z' suffix + +DIRAUTH_SKIP_REACHABLE = () +DIRAUTH_SKIP_SEEN = () +DIRAUTH_SKIP_CHECKS = ( + 'tor26' # tor26 DirPort does not service requests without a .z suffix +)
EMAIL_SUBJECT = 'Consensus issues' BANDWIDTH_AUTHORITIES = ('moria1', 'gabelmoo', 'maatuska', 'Faravahar', 'bastet', 'longclaw') @@ -636,10 +641,8 @@ def has_authority_flag(latest_consensus, consensuses, votes):
for desc in latest_consensus.routers.values(): if Flag.AUTHORITY in desc.flags: - seen_authorities.add(desc.nickname) - - if 'tor26' in seen_authorities: - seen_authorities.remove('tor26') + if not desc.nickname in DIRAUTH_SKIP_SEEN: + seen_authorities.add(desc.nickname)
known_authorities = set(DIRECTORY_AUTHORITIES.keys()) missing_authorities = known_authorities.difference(seen_authorities) @@ -823,9 +826,15 @@ def is_orport_reachable(latest_consensus, consensuses, votes): if not desc: continue # authority isn't in the consensus
+ if authority.nickname in DIRAUTH_SKIP_REACHABLE: + continue # reachability of authority impaired + + issue = util.check_reachability(desc.address, desc.or_port) + if issue: + issues.append(Issue(Runlevel.WARNING, 'UNABLE_TO_REACH_ORPORT', authority = authority.nickname, address = desc.address, port = desc.or_port, error = issue, to = [authority])) + for address, port, is_ipv6 in desc.or_addresses: issue = util.check_reachability(address, port) - if issue: issues.append(Issue(Runlevel.WARNING, 'UNABLE_TO_REACH_ORPORT', authority = authority.nickname, address = address, port = port, error = issue, to = [authority]))
@@ -956,9 +965,13 @@ def _get_documents(label, resource): documents, times_taken, clock_skew, issues = {}, {}, {}, []
for authority in DIRECTORY_AUTHORITIES.values(): + if authority.v3ident is None: continue # not a voting authority
+ if authority.nickname in DIRAUTH_SKIP_CHECKS: + continue # checking of authority impaired + query = downloader.query( resource, endpoints = [(authority.address, authority.dir_port)], @@ -976,7 +989,7 @@ def _get_documents(label, resource): issues.append(Issue(Runlevel.ERROR, 'AUTHORITY_UNAVAILABLE', fetch_type = label, authority = authority.nickname, url = query.download_url, error = exc, to = [authority.nickname]))
if label == 'consensus' and times_taken: - median_time = sorted(times_taken.values())[len(times_taken) / 2] + median_time = sorted(times_taken.values())[int(len(times_taken) / 2)] authority_times = ', '.join(['%s => %0.1fs' % (authority, time_taken) for authority, time_taken in times_taken.items()])
for nickname, time_taken in times_taken.items(): diff --git a/descriptor_checker.py b/descriptor_checker.py index 1d464f8..a0f5db3 100755 --- a/descriptor_checker.py +++ b/descriptor_checker.py @@ -29,6 +29,10 @@ time: %s error: %s """
+DIRAUTH_SKIP_CHECKS = ( + 'tor26' # tor26 DirPort does not service requests without a .z suffix +) + log = util.get_logger('descriptor_checker') util.log_stem_debugging('descriptor_checker')
@@ -65,8 +69,8 @@ def main(): for authority in stem.directory.Authority.from_cache().values(): if authority.v3ident is None: continue # authority doesn't vote in the consensus - elif authority.nickname == 'tor26': - continue # DirPort doesn't accept requests without a .z suffix + elif authority.nickname in DIRAUTH_SKIP_CHECKS: + continue # checking of authority impaired
log.debug("Downloading the consensus from %s..." % authority.nickname)
tor-commits@lists.torproject.org