[tor-bugs] #24706 [Core Tor/Fallback Scripts]: Add a script that creates fallback directory whitelist entries

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Dec 27 01:41:28 UTC 2017


#24706: Add a script that creates fallback directory whitelist entries
---------------------------------------+-----------------------------------
 Reporter:  teor                       |          Owner:  teor
     Type:  enhancement                |         Status:  needs_review
 Priority:  Medium                     |      Milestone:  Tor:
                                       |  0.3.3.x-final
Component:  Core Tor/Fallback Scripts  |        Version:
 Severity:  Normal                     |     Resolution:
 Keywords:                             |  Actual Points:  0.3
Parent ID:  #22271                     |         Points:  0.2
 Reviewer:                             |        Sponsor:
---------------------------------------+-----------------------------------

Comment (by atagar):

 Thanks Tim. For other's reference
 [https://github.com/teor2345/tor/commit/bfb49a here's the link].

 Your generateFallbackDirLine.py looks good, but I'm unsure why you're
 downloading the full consensus rather than just fetching this from the
 server descriptor. Doing do does the same, is simpler, and runs far
 faster.

 Otherwise looks good to me!

 {{{
 #!/usr/bin/env python

 # Generate a fallback directory whitelist/blacklist line for every
 fingerprint
 # passed as an argument.
 #
 # Usage:
 # generateFallbackDirLine.py fingerprint ...

 import sys
 import urllib2

 import stem.descriptor.remote
 import stem.util.tor_tools

 if len(sys.argv) <= 1:
   print('Usage: %s fingerprint ...' % sys.argv[0])
   sys.exit(1)

 fingerprint = sys.argv[1]

 if not stem.util.tor_tools.is_valid_fingerprint(fingerprint):
   print("'%s' isn't a valid relay fingerprint" % fingerprint)

 try:
   desc =
 stem.descriptor.remote.get_server_descriptors(fingerprint).run()[0]
 except urllib2.HTTPError as exc:
   if exc.code == 404:
     print('# %s not found in current consensus' % fingerprint)
     sys.exit(1)
   else:
     raise

 if not desc.dir_port:
   print("# %s needs a DirPort" % fingerprint)
 else:
   ipv6_addresses = [(address, port) for address, port, is_ipv6 in
 desc.or_addresses if is_ipv6]
   ipv6_field = ' ipv6=[%s]:%s' % ipv6_addresses[0] if ipv6_addresses else
 ''
   print('%s:%s orport=%s id=%s%s # %s' % (desc.address, desc.dir_port,
 desc.or_port, fingerprint, ipv6_field, desc.nickname))
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24706#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list