-
-
Save Ryman/ee2c11e7107a81c926c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import operator | |
import os | |
from stem.descriptor import parse_file | |
from stem.exit_policy import AddressType | |
cached_consensus_filepath = os.path.expandvars('$HOME/.tor/cached-consensus') | |
# Be sure to get the latest consensus doc, e.g. | |
# rsync metrics.torproject.org::metrics-recent/relay-descriptors/consensuses/2013-09-26-00-00-00-consensus data/latest_consensus | |
latest_consensus_filepath = 'data/latest_consensus' | |
missing = 0 | |
ok = 0 | |
total = 0 | |
cached_routers = {} | |
for router in parse_file(cached_consensus_filepath, | |
"network-status-consensus-3 1.0"): | |
cached_routers[router.fingerprint] = 1 | |
for router in parse_file(latest_consensus_filepath, | |
"network-status-consensus-3 1.0"): | |
if router.fingerprint in cached_routers: | |
# OK | |
ok += 1 | |
else: | |
# Missing | |
missing += 1 | |
print "Missing fingerprint: %s" % router.fingerprint | |
total += 1 | |
print "" | |
print "Missing: %d" % missing | |
print "OK(Found): %d" % ok | |
print "Total: %d" % total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment