[Pkg-privacy-commits] [obfsproxy] 198/353: Pass server-side transport parameters to transports.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:59 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 399248bb0f58babe88406f7017037955962ee9d7
Author: George Kadianakis <desnacked at riseup.net>
Date: Fri Sep 27 12:59:43 2013 +0100
Pass server-side transport parameters to transports.
---
ChangeLog | 3 +++
obfsproxy/common/transport_config.py | 15 +++++++++++++++
obfsproxy/managed/server.py | 15 ++++++++++++++-
obfsproxy/transports/obfs2.py | 10 ++++++++--
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 37efa5d..d8072ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@ Changes in version 0.2.4 - UNRELEASED
- Make pluggable transports aware of where they should store state
in the filesystem. Also introduce --data-dir CLI switch to specify
the path in external mode. Fixes #9815. Patch by Philipp Winter.
+ - Pass server-side parameters (like shared-secrets) from Tor to the
+ transports. Fixes #8979.
+
Changes in version 0.2.3 - 2013-09-11
- Use the new pyptlib API (>= pyptlib-0.0.4). Patch by Ximin Luo.
diff --git a/obfsproxy/common/transport_config.py b/obfsproxy/common/transport_config.py
index 3b705cd..18c5495 100644
--- a/obfsproxy/common/transport_config.py
+++ b/obfsproxy/common/transport_config.py
@@ -21,6 +21,7 @@ class TransportConfig( object ):
"""
self.stateLocation = None
+ self.serverTransportOptions = None
def setStateLocation( self, stateLocation ):
"""
@@ -36,6 +37,20 @@ class TransportConfig( object ):
return self.stateLocation
+ def setServerTransportOptions( self, serverTransportOptions ):
+ """
+ Set the given `serverTransportOptions'.
+ """
+
+ self.serverTransportOptions = serverTransportOptions
+
+ def getServerTransportOptions( self ):
+ """
+ Return the stored `serverTransportOptions'.
+ """
+
+ return self.serverTransportOptions
+
def __str__( self ):
"""
Return a string representation of the `TransportConfig' instance.
diff --git a/obfsproxy/managed/server.py b/obfsproxy/managed/server.py
index 54f9b26..80e1a81 100644
--- a/obfsproxy/managed/server.py
+++ b/obfsproxy/managed/server.py
@@ -32,11 +32,16 @@ def do_managed_server():
ext_orport = ptserver.config.getExtendedORPort()
authcookie = ptserver.config.getAuthCookieFile()
orport = ptserver.config.getORPort()
+ server_transport_options = ptserver.config.getServerTransportOptions()
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)
try:
if ext_orport:
@@ -62,7 +67,15 @@ def do_managed_server():
continue
should_start_event_loop = True
- log.debug("Successfully launched '%s' at '%s'" % (transport, log.safe_addr_str(str(addrport))))
+
+ extra_log = "" # Include server transport options in the log message if we got 'em
+ if transport_options:
+ extra_log = " (server transport options: '%s')" % str(transport_options)
+ log.debug("Successfully launched '%s' at '%s'%s" % (transport, log.safe_addr_str(str(addrport)), extra_log))
+
+ # Report success for this transport.
+ # (We leave the 'options' as None and let pyptlib handle the
+ # SMETHOD argument sending.)
ptserver.reportMethodSuccess(transport, addrport, None)
ptserver.reportMethodsEnd()
diff --git a/obfsproxy/transports/obfs2.py b/obfsproxy/transports/obfs2.py
index 9bbc446..8fb61b2 100644
--- a/obfsproxy/transports/obfs2.py
+++ b/obfsproxy/transports/obfs2.py
@@ -54,8 +54,14 @@ class Obfs2Transport(base.BaseTransport):
def __init__(self, transport_config):
"""Initialize the obfs2 pluggable transport."""
- # Check if the shared_secret class attribute was instantiated
- # by external-mode code. If not, instantiate it now.
+ # Check for shared-secret in the server transport options.
+ transport_options = transport_config.getServerTransportOptions()
+ if transport_options and "shared-secret" in transport_options:
+ log.debug("Setting shared-secret from server transport options: '%s'", transport_options["shared-secret"])
+ self.shared_secret = transport_options["shared-secret"]
+
+ # Check if the shared_secret class attribute was already
+ # instantiated. If not, instantiate it now.
if not hasattr(self, 'shared_secret'):
self.shared_secret = None
# If external-mode code did not specify the number of hash
--
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