[Pkg-privacy-commits] [obfsproxy] 219/353: Add some more flags to TransportConfig.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:02:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfsproxy.

commit 425a964ba9ad34b65f381621f0280687bf2d5a16
Author: George Kadianakis <desnacked at riseup.net>
Date:   Mon Jan 20 15:30:23 2014 +0000

    Add some more flags to TransportConfig.
    
    Specifically a flag to tell us whether we are in external/managed
    mode, and a flag to tell us whether we are client or server. These
    will be useful so that transports can configure themselves during
    setup().
---
 obfsproxy/common/transport_config.py | 22 ++++++++++++++++++++++
 obfsproxy/managed/client.py          |  2 ++
 obfsproxy/managed/server.py          |  7 ++++++-
 obfsproxy/pyobfsproxy.py             |  2 ++
 obfsproxy/transports/obfs2.py        |  3 +--
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/obfsproxy/common/transport_config.py b/obfsproxy/common/transport_config.py
index 18c5495..648b903 100644
--- a/obfsproxy/common/transport_config.py
+++ b/obfsproxy/common/transport_config.py
@@ -23,6 +23,11 @@ class TransportConfig( object ):
         self.stateLocation = None
         self.serverTransportOptions = None
 
+        # True if we are client, False if not.
+        self.weAreClient = None
+        # True if we are in external mode. False otherwise.
+        self.weAreExternal = None
+
     def setStateLocation( self, stateLocation ):
         """
         Set the given `stateLocation'.
@@ -51,6 +56,23 @@ class TransportConfig( object ):
 
         return self.serverTransportOptions
 
+    def setListenerMode( self, mode ):
+        if mode == "client" or mode == "socks":
+            self.weAreClient = True
+        elif mode == "server" or mode == "ext_server":
+            self.weAreClient = False
+        else:
+            raise ValueError("Invalid listener mode: %s" % mode)
+
+    def setObfsproxyMode( self, mode ):
+        if mode == "external":
+            self.weAreExternal = True
+        elif mode == "managed":
+            self.weAreExternal = False
+        else:
+            raise ValueError("Invalid obfsproxy mode: %s" % mode)
+
+
     def __str__( self ):
         """
         Return a string representation of the `TransportConfig' instance.
diff --git a/obfsproxy/managed/client.py b/obfsproxy/managed/client.py
index 6d0e7ed..72eccec 100644
--- a/obfsproxy/managed/client.py
+++ b/obfsproxy/managed/client.py
@@ -34,6 +34,8 @@ def do_managed_client():
         # Will hold configuration parameters for the pluggable transport module.
         pt_config = transport_config.TransportConfig()
         pt_config.setStateLocation(ptclient.config.getStateLocation())
+        pt_config.setListenerMode("socks")
+        pt_config.setObfsproxyMode("managed")
 
         # Call setup() method for this transport.
         transport_class = transports.get_transport_class(transport, 'socks')
diff --git a/obfsproxy/managed/server.py b/obfsproxy/managed/server.py
index 92d4c9a..5152a6d 100644
--- a/obfsproxy/managed/server.py
+++ b/obfsproxy/managed/server.py
@@ -39,8 +39,13 @@ def do_managed_server():
         # Will hold configuration parameters for the pluggable transport module.
         pt_config = transport_config.TransportConfig()
         pt_config.setStateLocation(ptserver.config.getStateLocation())
-        transport_options = ""
+        if ext_orport:
+            pt_config.setListenerMode("ext_server")
+        else:
+            pt_config.setListenerMode("server")
+        pt_config.setObfsproxyMode("managed")
 
+        transport_options = ""
         if server_transport_options and transport in server_transport_options:
             transport_options = server_transport_options[transport]
             pt_config.setServerTransportOptions(transport_options)
diff --git a/obfsproxy/pyobfsproxy.py b/obfsproxy/pyobfsproxy.py
index d0f9388..4227c2f 100755
--- a/obfsproxy/pyobfsproxy.py
+++ b/obfsproxy/pyobfsproxy.py
@@ -82,6 +82,8 @@ def do_external_mode(args):
 
     pt_config = transport_config.TransportConfig()
     pt_config.setStateLocation(args.data_dir)
+    pt_config.setListenerMode(args.mode)
+    pt_config.setObfsproxyMode("external")
 
     # Run setup() method.
     run_transport_setup(pt_config)
diff --git a/obfsproxy/transports/obfs2.py b/obfsproxy/transports/obfs2.py
index 36de060..5ddee74 100644
--- a/obfsproxy/transports/obfs2.py
+++ b/obfsproxy/transports/obfs2.py
@@ -101,6 +101,7 @@ class Obfs2Transport(base.BaseTransport):
     @classmethod
     def setup(cls, transport_config):
         """Setup the obfs2 pluggable transport."""
+        cls.we_are_initiator = transport_config.weAreClient
 
         # Check for shared-secret in the server transport options.
         transport_options = transport_config.getServerTransportOptions()
@@ -296,7 +297,6 @@ class Obfs2Client(Obfs2Transport):
         self.recv_pad_keytype = 'Responder obfuscation padding'
         self.send_keytype = "Initiator obfuscated data"
         self.recv_keytype = "Responder obfuscated data"
-        self.we_are_initiator = True
 
         Obfs2Transport.__init__(self, transport_config)
 
@@ -313,7 +313,6 @@ class Obfs2Server(Obfs2Transport):
         self.recv_pad_keytype = 'Initiator obfuscation padding'
         self.send_keytype = "Responder obfuscated data"
         self.recv_keytype = "Initiator obfuscated data"
-        self.we_are_initiator = False
 
         Obfs2Transport.__init__(self, transport_config)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git



More information about the Pkg-privacy-commits mailing list