lookupFallbackDirContact.py 830 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python
  2. # Lookup fallback directory contact lines for every fingerprint passed as an
  3. # argument.
  4. #
  5. # Usage:
  6. # lookupFallbackDirContact.py fingerprint ...
  7. import sys
  8. import stem.descriptor.remote as remote
  9. if len(sys.argv) <= 1:
  10. print "Usage: {} fingerprint ...".format(sys.argv[0])
  11. sys.exit(-1)
  12. # we need descriptors, because the consensus does not have contact infos
  13. descriptor_list = remote.get_server_descriptors(fingerprints=sys.argv[1:]).run()
  14. descriptor_list_fingerprints = []
  15. for d in descriptor_list:
  16. assert d.fingerprint in sys.argv[1:]
  17. descriptor_list_fingerprints.append(d.fingerprint)
  18. print "{} {}".format(d.fingerprint, d.contact)
  19. for fingerprint in sys.argv[1:]:
  20. if fingerprint not in descriptor_list_fingerprints:
  21. print "{} not found in current descriptors".format(fingerprint)