[stem/master] Only use directory mirrors with a DirPort

commit 4d4d75fdc57de91ae6796341468811d061e82c9c Author: Damian Johnson <atagar@torproject.org> Date: Sat Nov 10 16:58:37 2018 -0800 Only use directory mirrors with a DirPort Oops! Iirc the V2Dir flag once was only granted to relays with a DirPort but seems that's no longer the case. As a result our use_directory_mirrors() method inserted endpoints with port values of 'None'... https://trac.torproject.org/projects/tor/ticket/28393 Traceback (most recent call last): File "bushel.py", line 21, in <module> for desc in downloader.get_consensus().run(): ... File "/usr/lib/python3/dist-packages/stem/__init__.py", line 571, in __init__ raise ValueError("'%s' isn't a valid port" % port) ValueError: 'None' isn't a valid port We could use their ORPort to download descriptors instead, but Stem's ORPort capabilities are still pretty immature so just gonna restrict ourselves to DirPort mirrors for now instead. --- docs/change_log.rst | 1 + stem/descriptor/remote.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/change_log.rst b/docs/change_log.rst index a06b2ae8..01f3f2a4 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -51,6 +51,7 @@ The following are only available within Stem's `git repository * **Descriptors** + * DescriptorDownloader crashed if **use_mirrors** is set (:trac:`28393`) * Don't download from Serge, a bridge authority that frequently timeout * **Website** diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py index f1171697..47af2232 100644 --- a/stem/descriptor/remote.py +++ b/stem/descriptor/remote.py @@ -580,7 +580,7 @@ class DescriptorDownloader(object): consensus = list(self.get_consensus(document_handler = stem.descriptor.DocumentHandler.DOCUMENT).run())[0] for desc in consensus.routers.values(): - if stem.Flag.V2DIR in desc.flags: + if stem.Flag.V2DIR in desc.flags and desc.dir_port: new_endpoints.add((desc.address, desc.dir_port)) # we need our endpoints to be a list rather than set for random.choice()
participants (1)
-
atagar@torproject.org