[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Don't check 'UseMicrodescriptors 1' when calling get_network_statuses()



commit 136537c229193f77f86a11e02d528c6123ee91ab
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Nov 2 10:07:59 2017 -0700

    Don't check 'UseMicrodescriptors 1' when calling get_network_statuses()
    
    So much confusion around this...
    
      https://trac.torproject.org/projects/tor/ticket/24110
    
    It turns out in practice these methods essentially never provided
    microdescriptor flavored router status entries because 'UseMicrodescriptors'
    defaults to 'auto' (and it's rare to set it to '1' since that's the default
    anyway). However, if that was done we stacktraced...
    
      >>> desc = next(controller.get_network_statuses())
      Traceback (most recent call last):
        File "<console>", line 1, in <module>
        File "/home/atagar/Desktop/stem/stem/control.py", line 494, in wrapped
          for val in func(self, *args, **kwargs):
        File "/home/atagar/Desktop/stem/stem/control.py", line 1993, in get_network_statuses
          for desc in desc_iterator:
        File "/home/atagar/Desktop/stem/stem/descriptor/router_status_entry.py", line 104, in _parse_file
          yield entry_class(desc_content, validate, *extra_args)
        File "/home/atagar/Desktop/stem/stem/descriptor/router_status_entry.py", line 446, in __init__
          raise ValueError("%s must have a '%s' line:\n%s" % (self._name(True), keyword, str(self)))
      ValueError: Router status entries (micro v3) must have a 'm' line:
      r networkofthesmoker AAaX5kASI9/xzl9Qp7aFdPOSnrQ aoqBoLrUWKssJAKnO8r6GpZs5p8 2017-11-02 13:51:59 128.72.180.74 443 0
      s Fast Guard HSDir Running Stable V2Dir Valid
      w Bandwidth=4150
    
    From what I can tell nowadays UseMicrodescriptors doesn't change the 'GETINFO
    ns/all' response. As such reverting...
    
      https://gitweb.torproject.org/stem.git/commit/?id=d70fa9cd
---
 docs/change_log.rst |  1 +
 stem/control.py     | 38 ++++----------------------------------
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 12a7dc8c..e6ff38d3 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -65,6 +65,7 @@ The following are only available within Stem's `git repository
   * Failed to parse torrcs without a port on ipv6 exit policy entries
   * Resilient to 'Tor' prefix in 'GETINFO version' result (:spec:`c5ff1b1`)
   * Added a **all_extra** parameter to :class:`stem.version.Version` and support for multiple parenthetical entries (:trac:`22110`, :spec:`b50917d`)
+  * Setting 'UseMicrodescriptors 1' in your torrc caused :func:`~stem.control.Controller.get_network_statuses` to error (:trac:`24110`)
   * Closing controller connection faster when under heavy event load
   * Better messaging when unable to connect to tor on FreeBSD
   * More succinct trace level logging
diff --git a/stem/control.py b/stem/control.py
index 7c67cd0d..412740cc 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1889,17 +1889,6 @@ class Controller(BaseController):
     or nickname. If the relay identifier could be either a fingerprint *or*
     nickname then it's queried as a fingerprint.
 
-    This provides
-    :class:`~stem.descriptor.router_status_entry.RouterStatusEntryMicroV3`
-    instances if tor is using microdescriptors...
-
-    ::
-
-      controller.get_conf('UseMicrodescriptors', '0') == '1'
-
-    ... and :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3`
-    otherwise.
-
     If no **relay** is provided then this defaults to ourselves. Remember that
     this requires that we've retrieved our own descriptor from remote
     authorities so this both won't be available for newly started relays and
@@ -1911,7 +1900,7 @@ class Controller(BaseController):
     :param str relay: fingerprint or nickname of the relay to be queried
     :param object default: response if the query fails
 
-    :returns: :class:`~stem.descriptor.router_status_entry.RouterStatusEntry`
+    :returns: :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3`
       for the given relay
 
     :raises:
@@ -1948,10 +1937,7 @@ class Controller(BaseController):
     if not desc_content:
       raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
 
-    if self.get_conf('UseMicrodescriptors', '0') == '1':
-      return stem.descriptor.router_status_entry.RouterStatusEntryMicroV3(desc_content)
-    else:
-      return stem.descriptor.router_status_entry.RouterStatusEntryV3(desc_content)
+    return stem.descriptor.router_status_entry.RouterStatusEntryV3(desc_content)
 
   @with_default(yields = True)
   def get_network_statuses(self, default = UNDEFINED):
@@ -1961,21 +1947,10 @@ class Controller(BaseController):
     Provides an iterator for all of the router status entries that tor
     currently knows about.
 
-    This provides
-    :class:`~stem.descriptor.router_status_entry.RouterStatusEntryMicroV3`
-    instances if tor is using microdescriptors...
-
-    ::
-
-      controller.get_conf('UseMicrodescriptors', '0') == '1'
-
-    ... and :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3`
-    otherwise.
-
     :param list default: items to provide if the query fails
 
     :returns: iterates over
-      :class:`~stem.descriptor.router_status_entry.RouterStatusEntry` for
+      :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3` for
       relays in the tor network
 
     :raises: :class:`stem.ControllerError` if unable to query tor and no
@@ -1987,11 +1962,6 @@ class Controller(BaseController):
     #
     # https://trac.torproject.org/8248
 
-    if self.get_conf('UseMicrodescriptors', '0') == '1':
-      desc_class = stem.descriptor.router_status_entry.RouterStatusEntryMicroV3
-    else:
-      desc_class = stem.descriptor.router_status_entry.RouterStatusEntryV3
-
     desc_content = self.get_info('ns/all', get_bytes = True)
 
     if not desc_content:
@@ -2000,7 +1970,7 @@ class Controller(BaseController):
     desc_iterator = stem.descriptor.router_status_entry._parse_file(
       io.BytesIO(desc_content),
       False,
-      entry_class = desc_class,
+      entry_class = stem.descriptor.router_status_entry.RouterStatusEntryV3,
     )
 
     for desc in desc_iterator:

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits