MicroDescriptor¶
Parsing for Tor microdescriptors, which contain a distilled version of a relay’s server descriptor. As of Tor version 0.2.3.3-alpha Tor no longer downloads server descriptors by default, opting for microdescriptors instead.
Unlike most descriptor documents these aren’t available on the metrics site (since they don’t contain any information that the server descriptors don’t).
The limited information in microdescriptors make them rather clunky to use compared with server descriptors. For instance microdescriptors lack the relay’s fingerprint, making it difficut to use them to look up the relay’s other descriptors.
To do so you need to match the microdescriptor’s digest against its corresponding router status entry. For added fun as of this writing the controller doesn’t even surface those router status entries (ticket 7953).
For instance, here’s an example that prints the nickname and fingerprints of the exit relays.
import os
from stem.control import Controller
from stem.descriptor import parse_file
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
exit_digests = set()
data_dir = controller.get_conf('DataDirectory')
for desc in controller.get_microdescriptors():
if desc.exit_policy.is_exiting_allowed():
exit_digests.add(desc.digest)
print 'Exit Relays:'
for desc in parse_file(os.path.join(data_dir, 'cached-microdesc-consensus')):
if desc.digest in exit_digests:
print ' %s (%s)' % (desc.nickname, desc.fingerprint)
Doing the same is trivial with server descriptors…
from stem.descriptor import parse_file
print 'Exit Relays:'
for desc in parse_file('/home/atagar/.tor/cached-descriptors'):
if desc.exit_policy.is_exiting_allowed():
print ' %s (%s)' % (desc.nickname, desc.fingerprint)
Module Overview:
Microdescriptor - Tor microdescriptor.