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

[tor-commits] [stem/master] Tor change causes list_ephemeral_hidden_services() to return empty strings



commit c5cef004ef3ab8840f4c237a2bbfae204f09ae04
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Feb 25 14:57:40 2017 -0800

    Tor change causes list_ephemeral_hidden_services() to return empty strings
    
    Tor changed how GETINFO responses for listing ephemereal hidden services
    works...
    
      https://trac.torproject.org/projects/tor/ticket/21329
---
 docs/change_log.rst |  1 +
 stem/control.py     | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index edd5fa8..030ea66 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -47,6 +47,7 @@ The following are only available within Stem's `git repository
 
   * Added the GUARD_WAIT :data:`~stem.CircStatus` (:spec:`6446210`)
   * Unable to use cookie auth when path includes wide characters (chinese, japanese, etc)
+  * Tor change caused :func:`~stem.control.Controller.list_ephemeral_hidden_services` to provide empty strings if unset (:trac:`21329`)
 
  * **Descriptors**
 
diff --git a/stem/control.py b/stem/control.py
index 61d54fb..65e3401 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -2739,6 +2739,10 @@ class Controller(BaseController):
 
     .. versionadded:: 1.4.0
 
+    .. versionchanged:: 1.6.0
+       Tor change caused this to start providing empty strings if unset
+       (:trac:`21329`).
+
     :param object default: response if the query fails
     :param bool our_services: include services created with this controller
       that weren't flagged as 'detached'
@@ -2761,6 +2765,11 @@ class Controller(BaseController):
       try:
         result += self.get_info('onions/current').split('\n')
       except stem.ProtocolError as exc:
+        # TODO: Tor's behavior around this was changed in Feb 2017, we should
+        # drop it when all versions that did this are deprecated...
+        #
+        #   https://trac.torproject.org/projects/tor/ticket/21329
+
         if 'No onion services of the specified type.' not in str(exc):
           raise
 
@@ -2771,7 +2780,7 @@ class Controller(BaseController):
         if 'No onion services of the specified type.' not in str(exc):
           raise
 
-    return result
+    return [r for r in result if r]  # drop any empty responses (GETINFO is blank if unset)
 
   def create_ephemeral_hidden_service(self, ports, key_type = 'NEW', key_content = 'BEST', discard_key = False, detached = False, await_publication = False, basic_auth = None):
     """

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