[Pkg-privacy-commits] [obfsproxy] 70/353: Fix some issues.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:41 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 992f9f857d98300bf0d2928478c035356e3d47e3
Author: George Kadianakis <desnacked at riseup.net>
Date: Tue Sep 18 18:53:59 2012 +0300
Fix some issues.
---
obfsproxy.py | 10 +---------
obfsproxy/managed/client.py | 15 +++++++++------
obfsproxy/managed/server.py | 11 ++++++-----
obfsproxy/transports/base.py | 24 ++++++++++++++----------
obfsproxy/transports/transports.py | 8 ++++----
5 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/obfsproxy.py b/obfsproxy.py
index 3833a35..fbace9e 100755
--- a/obfsproxy.py
+++ b/obfsproxy.py
@@ -13,15 +13,7 @@ import argparse
import obfsproxy.transports.transports as transports
import obfsproxy.common.log as log
-# XXX kill these
-sys.path.insert(0,
- os.path.realpath(os.path.join(os.path.dirname(__file__),
- '../../Dust/py')))
-sys.path.insert(0,
- os.path.realpath(os.path.join(os.path.dirname(__file__),
- '../../pyptlib/src')))
-
-from pyptlib.easy.util import checkClientMode
+from pyptlib.util import checkClientMode
from obfsproxy.managed.server import ManagedServer
from obfsproxy.managed.client import ManagedClient
diff --git a/obfsproxy/managed/client.py b/obfsproxy/managed/client.py
index 56ad728..3f6a2ee 100644
--- a/obfsproxy/managed/client.py
+++ b/obfsproxy/managed/client.py
@@ -3,12 +3,12 @@
# XXX put listener/client-creation functions in their own file
import obfsproxy.network.socks as socks
-from twisted.internet import reactor, error, address, tcp
+from twisted.internet import reactor, error
import obfsproxy.transports.transports as transports
-from pyptlib.easy.client import init, reportSuccess, reportFailure, \
- reportEnd
+from pyptlib.client import init, reportSuccess, reportFailure, reportEnd
+from pyptlib.config import EnvException
import obfsproxy.common.log as log
import pprint
@@ -16,8 +16,10 @@ import pprint
class ManagedClient:
def __init__(self):
- managedInfo = init(transports.transports.keys())
- if managedInfo is None: # XXX what should we return?
+ try:
+ managedInfo = init(transports.transports.keys())
+ except EnvException:
+ log.warn("Client managed-proxy protocol failed.")
return
log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(managedInfo))
@@ -36,6 +38,7 @@ class ManagedClient:
log.info("Starting up the event loop.")
reactor.run()
+ # XXX turn into a function to be used by exteral-mode code, etc.
def launchClient(self, name, managedInfo):
"""
Launch a client of transport 'name' using the environment
@@ -55,7 +58,7 @@ class ManagedClient:
try:
addrport = reactor.listenTCP(0, factory, interface='localhost')
- except CannotListenError:
+ except error.CannotListenError:
log.error("Could not set up a client listener.")
return False, None
diff --git a/obfsproxy/managed/server.py b/obfsproxy/managed/server.py
index dad5370..a4b999f 100644
--- a/obfsproxy/managed/server.py
+++ b/obfsproxy/managed/server.py
@@ -7,8 +7,8 @@ from twisted.internet import reactor, error, address, tcp
import obfsproxy.transports.transports as transports
-from pyptlib.easy.server import init, reportSuccess, reportFailure, \
- reportEnd
+from pyptlib.server import init, reportSuccess, reportFailure, reportEnd
+from pyptlib.config import EnvException
import obfsproxy.common.log as log
import pprint
@@ -16,9 +16,10 @@ import pprint
class ManagedServer:
def __init__(self):
- managedInfo = init(transports.transports.keys())
- if managedInfo is None: # XXX what is this function supposed to return?!
- log.warning("pyptlib failed to init().")
+ try:
+ managedInfo = init(transports.transports.keys())
+ except EnvException:
+ log.warn("Server managed-proxy protocol failed.")
return
log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(managedInfo))
diff --git a/obfsproxy/transports/base.py b/obfsproxy/transports/base.py
index 040d2f3..fcab386 100644
--- a/obfsproxy/transports/base.py
+++ b/obfsproxy/transports/base.py
@@ -10,18 +10,18 @@ However, BaseDaemon provides utility methods that are useful for a variety of co
"""
def addrport(string):
- """
- Receive '<addr>:<port>' and return [<addr>,<port>]. Used during
- argparse CLI parsing.
- """
+ """
+ Receive '<addr>:<port>' and return [<addr>,<port>]. Used during
+ argparse CLI parsing.
+ """
- addrport = string.split(':')
+ addrport = string.split(':')
- if (len(addrport) != 2):
- msg = "'%s' is not in <addr>:<port> format" % string
- raise argparse.ArgumentTypeError(msg)
+ if (len(addrport) != 2):
+ msg = "'%s' is not in <addr>:<port> format" % string
+ raise argparse.ArgumentTypeError(msg)
- return addrport
+ return addrport
class BaseDaemon:
@@ -29,6 +29,9 @@ class BaseDaemon:
The BaseDaemon class is a skeleton class for implementing pluggable transports.
"""
+ def __init__(self):
+ pass
+
@classmethod
def register_external_mode_cli(cls, subparser):
"""
@@ -39,7 +42,7 @@ class BaseDaemon:
function.
"""
- subparser.add_argument('mode', choices=['server','client','socks'])
+ subparser.add_argument('mode', choices=['server', 'client', 'socks'])
subparser.add_argument('listen_addr', type=addrport)
subparser.add_argument('--dest', type=addrport, help='Destination address')
@@ -104,6 +107,7 @@ class BaseDaemon:
pass
+ # XXX update with the new API
def receivedDownstream(self):
"""
This is the callback method which is called by the framework when bytes have been received on the downstream socket.
diff --git a/obfsproxy/transports/transports.py b/obfsproxy/transports/transports.py
index 7229f6b..09db92d 100644
--- a/obfsproxy/transports/transports.py
+++ b/obfsproxy/transports/transports.py
@@ -1,14 +1,14 @@
# XXX modulify transports and move this to a single import
import obfsproxy.transports.dummy as dummy
import obfsproxy.transports.b64 as b64
-import obfsproxy.transports.dust_transport as dust
-# XXX obfs2 is broken...
+# XXX broken transports
+#import obfsproxy.transports.dust_transport as dust
#import obfsproxy.transports.obfs2 as obfs2
#import obfsproxy.transports.obfs3 as obfs3
transports = { 'dummy' : {'client' : dummy.DummyClient, 'socks' : dummy.DummyClient, 'server' : dummy.DummyServer },
- 'b64' : {'client' : b64.B64Client, 'socks' : b64.B64Client, 'server' : b64.B64Server },
- 'dust' : {'client' : dust.DustClient, 'socks' : dust.DustClient, 'server' : dust.DustServer } }
+ 'b64' : {'client' : b64.B64Client, 'socks' : b64.B64Client, 'server' : b64.B64Server } }
+# 'dust' : {'client' : dust.DustClient, 'socks' : dust.DustClient, 'server' : dust.DustServer } }
# 'obfs2' : {'client' : obfs2.Obfs2Client, 'socks' : obfs2.Obfs2Client, 'server' : obfs2.Obfs2Server },
# 'obfs3' : {'client' : obfs3.Obfs3Client, 'socks' : obfs3.Obfs3Client, 'server' : obfs3.Obfs3Server }
--
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