[Pkg-privacy-commits] [obfsproxy] 203/353: Call transport setup at obfsproxy start

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:02:00 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 55e42c59d2c7ec46182f7bcfc2fdf62587d9e33f
Author: David Stainton <dstainton415 at gmail.com>
Date:   Mon Nov 11 21:41:43 2013 -0800

    Call transport setup at obfsproxy start
    
    Pluggable Transports can use the setup class method
    to receive Pluggable Transport config and save data to class attributes.
---
 obfsproxy/managed/client.py  | 10 +++++++---
 obfsproxy/managed/server.py  | 11 ++++++++---
 obfsproxy/pyobfsproxy.py     |  7 +++++++
 obfsproxy/transports/base.py | 12 ++++++++++++
 4 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/obfsproxy/managed/client.py b/obfsproxy/managed/client.py
index f847b76..a3a3e53 100644
--- a/obfsproxy/managed/client.py
+++ b/obfsproxy/managed/client.py
@@ -29,11 +29,15 @@ def do_managed_client():
 
     log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(ptclient.getDebugData()))
 
+
+    # Will hold configuration parameters for the pluggable transport module.
+    pt_config = transport_config.TransportConfig()
+    pt_config.setStateLocation(ptclient.config.getStateLocation())
+
     for transport in ptclient.getTransports():
 
-        # Will hold configuration parameters for the pluggable transport module.
-        pt_config = transport_config.TransportConfig()
-        pt_config.setStateLocation(ptclient.config.getStateLocation())
+        transport_class = transports.get_transport_class(transport, 'socks')
+        transport_class.setup(pt_config)
 
         try:
             addrport = launch_transport.launch_transport_listener(transport, None, 'socks', None, pt_config)
diff --git a/obfsproxy/managed/server.py b/obfsproxy/managed/server.py
index 80e1a81..2b5d518 100644
--- a/obfsproxy/managed/server.py
+++ b/obfsproxy/managed/server.py
@@ -33,16 +33,21 @@ def do_managed_server():
     authcookie = ptserver.config.getAuthCookieFile()
     orport = ptserver.config.getORPort()
     server_transport_options = ptserver.config.getServerTransportOptions()
+
+    # Will hold configuration parameters for the pluggable transport module.
+    pt_config = transport_config.TransportConfig()
+    pt_config.setStateLocation(ptserver.config.getStateLocation())
+
     for transport, transport_bindaddr in ptserver.getBindAddresses().items():
 
-        # Will hold configuration parameters for the pluggable transport module.
-        pt_config = transport_config.TransportConfig()
-        pt_config.setStateLocation(ptserver.config.getStateLocation())
         transport_options = ""
         if server_transport_options and transport in server_transport_options:
             transport_options = server_transport_options[transport]
             pt_config.setServerTransportOptions(transport_options)
 
+        transport_class = transports.get_transport_class(transport, 'server')
+        transport_class.setup(pt_config)
+
         try:
             if ext_orport:
                 addrport = launch_transport.launch_transport_listener(transport,
diff --git a/obfsproxy/pyobfsproxy.py b/obfsproxy/pyobfsproxy.py
index 1b1401a..b29d669 100755
--- a/obfsproxy/pyobfsproxy.py
+++ b/obfsproxy/pyobfsproxy.py
@@ -83,6 +83,8 @@ def do_external_mode(args):
     pt_config = transport_config.TransportConfig()
     pt_config.setStateLocation(args.data_dir)
 
+    run_transport_setup(pt_config)
+
     launch_transport.launch_transport_listener(args.name, args.listen_addr, args.mode, args.dest, pt_config, args.ext_cookie_file)
     log.info("Launched '%s' listener at '%s:%s' for transport '%s'." % \
                  (args.mode, log.safe_addr_str(args.listen_addr[0]), args.listen_addr[1], args.name))
@@ -107,6 +109,11 @@ def consider_cli_args(args):
     elif (args.name == 'managed') and (not args.log_file):
         # managed proxies without a logfile must not log at all.
         log.disable_logs()
+ 
+def run_transport_setup(pt_config):
+    """Pass the Pluggable Transport Config to each transport."""
+    for transport, transport_class in transports.transports.items():
+        transport_class['base'].setup(pt_config)
 
 def pyobfsproxy():
     """Actual pyobfsproxy entry-point."""
diff --git a/obfsproxy/transports/base.py b/obfsproxy/transports/base.py
index 6cbb0ce..1e74abf 100644
--- a/obfsproxy/transports/base.py
+++ b/obfsproxy/transports/base.py
@@ -31,6 +31,18 @@ class BaseTransport(object):
     """
 
     def __init__(self):
+        """
+        Initialize transport. This is called right after TCP connect.
+        """
+        pass
+
+    @classmethod
+    def setup(cls, pt_config):
+        """
+        Receive Pluggable Transport Config, perform setup task
+        and save state in class attributes.
+        Called at obfsproxy startup.
+        """
         pass
 
     def handshake(self, circuit):

-- 
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