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

[tor-commits] [stem/master] Specify v2 hidden service creation when using v2 options



commit b09fa1145391ee7abf0b90c2bd0c5b198d78e8c2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Sep 5 09:37:41 2018 -0700

    Specify v2 hidden service creation when using v2 options
    
    Tor just changed its default for hidden service creation from v2 to v3. This is
    all well and good, but it breaks backward compatibility a tad. When attempting
    to create a service with v2 options we should now specify the its version as
    v2.
    
      https://trac.torproject.org/projects/tor/ticket/27446
---
 docs/change_log.rst              |  1 +
 stem/control.py                  | 11 +++++++++++
 test/integ/control/controller.py |  1 +
 3 files changed, 13 insertions(+)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 9f4049e6..89a13738 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -54,6 +54,7 @@ The following are only available within Stem's `git repository
   * Stacktrace if :func:`stem.connection.connect` had a string port argument
   * More reliable ExitPolicy resolution (:trac:`25739`)
   * More reliable caching during configuration changes, especially in multiple-controller situations (:trac:`25821`)
+  * :func:`~stem.control.COntroller.create_hidden_service` failed when creating services with v2 options (:trac:`27446`)
   * :func:`~stem.control.Controller.get_info` commonly raised :class:`stem.ProtocolError` when it should provide :class:`stem.OperationFailed`
   * :func:`~stem.control.Controller.get_microdescriptors` reads descriptors from the control port if available (:spec:`b5396d5`)
   * :func:`~stem.control.Controller.get_exit_policy` now provides None if not configured to be a relay (:trac:`25853`, :spec:`c5453a0`)
diff --git a/stem/control.py b/stem/control.py
index 05cf44ce..5687a4b2 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -2669,6 +2669,17 @@ class Controller(BaseController):
       hsac = "%s %s" % (auth_type, ','.join(client_names))
       conf[path]['HiddenServiceAuthorizeClient'] = hsac
 
+    # Tor 0.3.5 changes its default for HS creation from v2 to v3. This is
+    # fine, but there's a couple options that are incompatible with v3. If
+    # creating a service with one of those we should explicitly create a v2
+    # service instead.
+    #
+    #   https://trac.torproject.org/projects/tor/ticket/27446
+
+    for path in conf:
+      if 'HiddenServiceAuthorizeClient' in conf[path] or 'RendPostPeriod' in conf[path]:
+        conf[path]['HiddenServiceVersion'] = '2'
+
     self.set_hidden_service_conf(conf)
 
     hostname, hostname_for_client = None, {}
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index a28300ba..d5382f72 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -446,6 +446,7 @@ class TestController(unittest.TestCase):
             'HiddenServiceVersion': '2',
           },
           service2_path: {
+            'HiddenServiceVersion': '2',
             'HiddenServiceAuthorizeClient': 'stealth a, b',
             'HiddenServicePort': [
               (8030, '127.0.0.1', 8030),

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