[tor-commits] [doctor/master] Notify if flag count substantially differ
atagar at torproject.org
atagar at torproject.org
Sun Feb 11 20:56:27 UTC 2018
commit 894501335535e04668fb63f3aadd5f25c7318ebe
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Feb 11 12:50:42 2018 -0800
Notify if flag count substantially differ
Recently dannenberg stopped issuing the Exit flag. Check Requested by nusenu...
https://lists.torproject.org/pipermail/tor-dev/2018-February/012918.html
---
consensus_health_checker.py | 30 ++++++++++++++++++++++++++++++
data/consensus_health.cfg | 1 +
2 files changed, 31 insertions(+)
diff --git a/consensus_health_checker.py b/consensus_health_checker.py
index 23f3f9d..e91e292 100755
--- a/consensus_health_checker.py
+++ b/consensus_health_checker.py
@@ -321,6 +321,7 @@ def run_checks(consensuses, votes):
voting_bandwidth_scanners,
#unmeasured_relays,
has_authority_flag,
+ has_similar_flag_counts,
is_recommended_versions,
bad_exits_in_sync,
bandwidth_authorities_in_sync,
@@ -612,6 +613,35 @@ def has_authority_flag(latest_consensus, consensuses, votes):
return issues
+def has_similar_flag_counts(latest_consensus, consensuses, votes):
+ "Checks that flags issued by authorities are similar."
+
+ issues = []
+ flag_count = {} # {flag => count}
+
+ for desc in latest_consensus.routers.values():
+ for flag in desc.flags:
+ flag_count[flag] = flag_count.setdefault(flag, 0) + 1
+
+ for authority, vote in votes.items():
+ authority_flag_count = {}
+
+ for desc in vote.routers.values():
+ for flag in desc.flags:
+ authority_flag_count[flag] = authority_flag_count.setdefault(flag, 0) + 1
+
+ for flag, count in flag_count.items():
+ if flag == 'BadExit':
+ continue
+
+ vote_count = authority_flag_count.get(flag, 0)
+
+ if vote_count > count * 1.5 or vote_count < count * 0.5:
+ issues.append(Issue(Runlevel.NOTICE, 'FLAG_COUNT_DIFFERS', authority = authority, flag = flag, consensus_count = count, vote_count = vote_count, to = [authority]))
+
+ return issues
+
+
def has_expected_fingerprints(latest_consensus, consensuses, votes):
"Checks that the authorities have the fingerprints that we expect."
diff --git a/data/consensus_health.cfg b/data/consensus_health.cfg
index 423ab6d..326aa20 100644
--- a/data/consensus_health.cfg
+++ b/data/consensus_health.cfg
@@ -14,6 +14,7 @@ msg TOO_MANY_UNMEASURED_RELAYS => As a bandwidth authority {authority} lacked a
msg MISSING_VOTES => The consensuses downloaded from the following authorities are missing votes that are contained in consensuses downloaded from other authorities: {authorities}
msg MISSING_AUTHORITIES => The following authorities are missing from the consensus: {authorities}
msg EXTRA_AUTHORITIES => The following authorities were not expected in the consensus: {authorities}
+msg FLAG_COUNT_DIFFERS => {authority} had {vote_count} {flag} flags in its vote but the consensus had {consensus_count}
msg FINGERPRINT_MISMATCH => {authority} had a different fingerprint than we expected (expected: {expected}, actual: {actual})
msg TOR_OUT_OF_DATE => The following authorities are an out of date version of tor: {authorities}
msg BADEXIT_OUT_OF_SYNC => Authorities disagree about the BadExit flag for {fingerprint} ({counts})
More information about the tor-commits
mailing list