commit 7b2156d89846f8c435b6ad0632c37996969d668e Author: Damian Johnson atagar@torproject.org Date: Sat Apr 28 11:37:38 2018 -0700
Don't fall back to dirauths by default for descriptors
When constructing a DescriptorDownloader originally we'd also use directory mirrors to distribute load. This in turn made our DescriptorDownloader unreliable since mirrors are far flakier than dirauths, so using three mirrors in a row would reasonably often fail.
As such when using a DescriptorDownloader (but not Query directly) we'd adjust our fall_back_to_authority to true. There's two reasons why this is no longer relevant...
1. The DescriptorDownloader no longer uses mirrors by default, meaning we always download from dirauths (making the argument moot).
2. Nowadays our most common access pattern is for callers to use our singleton aliases. When a user calls...
get_server_descriptor(endpoint = my_relay)
They expect Stem to... well, download from their relay. Not attempt to download twice then fetch from a dirauth.
This has bitten me a half dozen times so lets finally change to a more consistent default. ;P --- docs/change_log.rst | 1 + stem/descriptor/remote.py | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst index b237f25f..8bd00d99 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -60,6 +60,7 @@ The following are only available within Stem's `git repository * `Fallback directory v2 support https://lists.torproject.org/pipermail/tor-dev/2017-December/012721.html`_, which adds *nickname* and *extrainfo* * Added server descriptor's new is_hidden_service_dir attribute * Don't retry downloading descriptors when we've timed out + * `stem.descriptor.remote <api/descriptor/remote.html>`_ now consistently defaults **fall_back_to_authority** to false. * Added :func:`~stem.descriptor.remote.their_server_descriptor` * Added the reply_headers attribute to :class:`~stem.descriptor.remote.Query` * Supplying a User-Agent when downloading descriptors. diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py index 7908becf..e745ce20 100644 --- a/stem/descriptor/remote.py +++ b/stem/descriptor/remote.py @@ -963,6 +963,10 @@ class DescriptorDownloader(object): """ Issues a request for the given resource.
+ .. versionchanged:: 1.7.0 + The **fall_back_to_authority** default when using this method is now + **False**, like the :class:`~stem.descriptor.Query` class. + :param str resource: resource being fetched, such as '/tor/server/all' :param query_args: additional arguments for the :class:`~stem.descriptor.remote.Query` constructor @@ -979,13 +983,7 @@ class DescriptorDownloader(object): if 'endpoints' not in args: args['endpoints'] = self._endpoints
- if 'fall_back_to_authority' not in args: - args['fall_back_to_authority'] = True - - return Query( - resource, - **args - ) + return Query(resource, **args)
class Directory(object):