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

[tor-commits] [stem/master] Add support for ADD_ONION's MaxStreamsCloseCircuit



commit 1ffcb598f780ae80b10cc66f7a89cf1d2c6a301c
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Dec 1 09:33:00 2017 -0800

    Add support for ADD_ONION's MaxStreamsCloseCircuit
    
    Adding support for a newly documented Onion Service capability...
    
      https://gitweb.torproject.org/torspec.git/commit/?id=2fcb1c2
      https://trac.torproject.org/projects/tor/ticket/24201
---
 docs/change_log.rst |  4 ++++
 stem/control.py     | 16 +++++++++++++++-
 stem/version.py     |  2 ++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 191290e1..cfe5200e 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -44,6 +44,10 @@ Unreleased
 The following are only available within Stem's `git repository
 <download.html>`_.
 
+ * **Controller**
+
+  * Added support for limiting the maximum number of streams to :func:`~stem.control.Controller.create_ephemeral_hidden_service` (:spec:`2fcb1c2`)
+
 .. _version_1.6:
 
 Version 1.6 (November 5th, 2017)
diff --git a/stem/control.py b/stem/control.py
index 1468e6c2..1b719dd0 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -2804,7 +2804,7 @@ class Controller(BaseController):
 
     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):
+  def create_ephemeral_hidden_service(self, ports, key_type = 'NEW', key_content = 'BEST', discard_key = False, detached = False, await_publication = False, basic_auth = None, max_streams = None):
     """
     Creates a new hidden service. Unlike
     :func:`~stem.control.Controller.create_hidden_service` this style of
@@ -2862,6 +2862,9 @@ class Controller(BaseController):
        'HiddenServiceSingleHopMode 1' and 'HiddenServiceNonAnonymousMode 1' in
        your torrc.
 
+    .. versionchanged:: 1.7.0
+       Added the max_streams argument.
+
     :param int,list,dict ports: hidden service port(s) or mapping of hidden
       service ports to their targets
     :param str key_type: type of key being provided, generates a new key if
@@ -2875,6 +2878,8 @@ class Controller(BaseController):
     :param bool await_publication: blocks until our descriptor is successfully
       published if **True**
     :param dict basic_auth: required user credentials to access this service
+    :param int max_streams: maximum number of streams the hidden service will
+      accept, unlimited if zero or not set
 
     :returns: :class:`~stem.response.add_onion.AddOnionResponse` with the response
 
@@ -2908,6 +2913,12 @@ class Controller(BaseController):
 
       flags.append('BasicAuth')
 
+    if max_streams is not None:
+      if self.get_version() < stem.version.Requirement.ADD_ONION_MAX_STREAMS:
+        raise stem.UnsatisfiableRequest(message = 'Limitation of the maximum number of streams to accept was added to ADD_ONION in tor version %s' % stem.version.Requirement.ADD_ONION_MAX_STREAMS)
+
+      flags.append('MaxStreamsCloseCircuit')
+
     if self.get_version() >= stem.version.Requirement.ADD_ONION_NON_ANONYMOUS:
       if self.get_conf('HiddenServiceSingleHopMode', None) == '1' and self.get_conf('HiddenServiceNonAnonymousMode', None) == '1':
         flags.append('NonAnonymous')
@@ -2915,6 +2926,9 @@ class Controller(BaseController):
     if flags:
       request += ' Flags=%s' % ','.join(flags)
 
+    if max_streams is not None:
+      request += ' MaxStreams=%s' % max_streams
+
     if isinstance(ports, int):
       request += ' Port=%s' % ports
     elif isinstance(ports, list):
diff --git a/stem/version.py b/stem/version.py
index 5f7822ba..6af239b0 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -66,6 +66,7 @@ easily parsed and compared, for instance...
   **ADD_ONION**                         ADD_ONION and DEL_ONION requests
   **ADD_ONION_BASIC_AUTH**              ADD_ONION supports basic authentication
   **ADD_ONION_NON_ANONYMOUS**           ADD_ONION supports non-anonymous mode
+  **ADD_ONION_MAX_STREAMS**             ADD_ONION support for MaxStreamsCloseCircuit
   **LOADCONF**                          LOADCONF requests
   **MICRODESCRIPTOR_IS_DEFAULT**        Tor gets microdescriptors by default rather than server descriptors
   **SAVECONF_FORCE**                    Added the 'FORCE' flag to SAVECONF
@@ -382,6 +383,7 @@ Requirement = stem.util.enum.Enum(
   ('ADD_ONION', Version('0.2.7.1-alpha')),
   ('ADD_ONION_BASIC_AUTH', Version('0.2.9.1-alpha')),
   ('ADD_ONION_NON_ANONYMOUS', Version('0.2.9.3-alpha')),
+  ('ADD_ONION_MAX_STREAMS', Version('0.2.7.2-alpha')),
   ('LOADCONF', Version('0.2.1.1')),
   ('MICRODESCRIPTOR_IS_DEFAULT', Version('0.2.3.3')),
   ('SAVECONF_FORCE', Version('0.3.1.1-alpha')),

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