-
-
Save Ryman/1f2e76d7465abb7ea603 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 | |
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option('-s', '--skip-new', dest='skip_new', | |
action='store_true', default=False) | |
(options, args) = parser.parse_args() | |
consensus_filepath = os.path.expandvars('$HOME/.tor/cached-consensus') | |
descriptors_filepath = os.path.expandvars('$HOME/.tor/cached-descriptors') | |
new_descriptors_filepath = os.path.expandvars('$HOME/.tor/cached-descriptors.new') | |
server_descriptors = {} | |
for descriptor in parse_file(descriptors_filepath, "server-descriptor 1.0"): | |
server_descriptors[descriptor.fingerprint] = 1 | |
if not options.skip_new: | |
for descriptor in parse_file(new_descriptors_filepath, "server-descriptor 1.0"): | |
if descriptor.fingerprint not in server_descriptors: | |
server_descriptors[descriptor.fingerprint] = 2 | |
missing = 0 | |
in_new = 0 | |
ok = 0 | |
total = 0 | |
for router in parse_file(consensus_filepath, | |
"network-status-consensus-3 1.0"): | |
if router.fingerprint in server_descriptors: | |
# OK | |
if server_descriptors[router.fingerprint] == 2: | |
print "Found in new: %s" % router.fingerprint | |
in_new += 1 | |
ok += 1 | |
else: | |
# Missing | |
missing += 1 | |
print "Missing fingerprint: %s" % router.fingerprint | |
total += 1 | |
print "" | |
print "Missing: %d" % missing | |
if not options.skip_new: | |
print "From_new: %d" % in_new | |
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