Skip to content

Instantly share code, notes, and snippets.

@Ryman
Created September 26, 2013 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryman/ee2c11e7107a81c926c8 to your computer and use it in GitHub Desktop.
Save Ryman/ee2c11e7107a81c926c8 to your computer and use it in GitHub Desktop.
#!/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