stem_test.py 747 B

1234567891011121314151617181920212223
  1. import stem.descriptor.remote
  2. #try:
  3. # for desc in stem.descriptor.remote.get_consensus():
  4. # print("found relay %s (%s)" % (desc.nickname, desc.fingerprint))
  5. #except Exception as exc:
  6. # print("Unable to retrieve the consensus: %s" % exc
  7. endpoint = ('127.0.0.1', 8080)
  8. try:
  9. consensus = stem.descriptor.remote.get_consensus(
  10. endpoints = (stem.DirPort('127.0.0.1', 7000),)
  11. )
  12. print('got consensus: {}'.format(consensus))
  13. for desc in consensus:
  14. print("found relay %s (%s) - %s" % (desc.nickname, desc.fingerprint, desc.exit_policy))
  15. for x in [desc for desc in consensus if desc.exit_policy.can_exit_to(*endpoint)]:
  16. print('%s' % (x.nickname))
  17. except Exception as exc:
  18. print("Unable to retrieve the consensus: %s" % exc)