[Pkg-privacy-commits] [obfsproxy] 182/353: update to new pyptlib API
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:57 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 c5135c9f2f1a40a45b71a7245d5ba05e25041e1a
Author: Ximin Luo <infinity0 at gmx.com>
Date: Tue Sep 10 15:57:52 2013 +0100
update to new pyptlib API
---
obfsproxy/managed/client.py | 17 +++++++++--------
obfsproxy/managed/server.py | 28 ++++++++++++++++------------
2 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/obfsproxy/managed/client.py b/obfsproxy/managed/client.py
index 91eb286..d4f6924 100644
--- a/obfsproxy/managed/client.py
+++ b/obfsproxy/managed/client.py
@@ -7,7 +7,7 @@ import obfsproxy.network.launch_transport as launch_transport
import obfsproxy.transports.transports as transports
import obfsproxy.common.log as logging
-from pyptlib.client import init, reportSuccess, reportFailure, reportEnd
+from pyptlib.client import ClientTransportPlugin
from pyptlib.config import EnvError
import pprint
@@ -19,31 +19,32 @@ def do_managed_client():
should_start_event_loop = False
+ ptclient = ClientTransportPlugin()
try:
- managedInfo = init(transports.transports.keys())
+ ptclient.init(transports.transports.keys())
except EnvError, err:
log.warning("Client managed-proxy protocol failed (%s)." % err)
return
- log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(managedInfo))
+ log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(ptclient.getDebugData()))
- for transport in managedInfo['transports']:
+ for transport in ptclient.getTransports():
try:
addrport = launch_transport.launch_transport_listener(transport, None, 'socks', None)
except transports.TransportNotFound:
log.warning("Could not find transport '%s'" % transport)
- reportFailure(transport, "Could not find transport.")
+ ptclient.reportMethodError(transport, "Could not find transport.")
continue
except error.CannotListenError:
log.warning("Could not set up listener for '%s'." % transport)
- reportFailure(transport, "Could not set up listener.")
+ ptclient.reportMethodError(transport, "Could not set up listener.")
continue
should_start_event_loop = True
log.debug("Successfully launched '%s' at '%s'" % (transport, log.safe_addr_str(str(addrport))))
- reportSuccess(transport, 4, addrport, None, None)
+ ptclient.reportMethodSuccess(transport, "socks4", addrport, None, None)
- reportEnd()
+ ptclient.reportMethodsEnd()
if should_start_event_loop:
log.info("Starting up the event loop.")
diff --git a/obfsproxy/managed/server.py b/obfsproxy/managed/server.py
index 13542ae..09352aa 100644
--- a/obfsproxy/managed/server.py
+++ b/obfsproxy/managed/server.py
@@ -3,7 +3,7 @@
from twisted.internet import reactor, error
-from pyptlib.server import init, reportSuccess, reportFailure, reportEnd
+from pyptlib.server import ServerTransportPlugin
from pyptlib.config import EnvError
import obfsproxy.transports.transports as transports
@@ -19,41 +19,45 @@ def do_managed_server():
should_start_event_loop = False
+ ptserver = ServerTransportPlugin()
try:
- managed_info = init(transports.transports.keys())
+ ptserver.init(transports.transports.keys())
except EnvError, err:
log.warning("Server managed-proxy protocol failed (%s)." % err)
return
- log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(managed_info))
+ log.debug("pyptlib gave us the following data:\n'%s'", pprint.pformat(ptserver.getDebugData()))
- for transport, transport_bindaddr in managed_info['transports'].items():
+ ext_orport = ptserver.config.getExtendedORPort()
+ authcookie = ptserver.config.getAuthCookieFile()
+ orport = ptserver.config.getORPort()
+ for transport, transport_bindaddr in ptserver.getBindAddresses().items():
try:
- if managed_info['ext_orport']:
+ if ext_orport:
addrport = launch_transport.launch_transport_listener(transport,
transport_bindaddr,
'ext_server',
- managed_info['ext_orport'],
- managed_info['auth_cookie_file'])
+ ext_orport,
+ authcookie)
else:
addrport = launch_transport.launch_transport_listener(transport,
transport_bindaddr,
'server',
- managed_info['orport'])
+ orport)
except transports.TransportNotFound:
log.warning("Could not find transport '%s'" % transport)
- reportFailure(transport, "Could not find transport.")
+ ptserver.reportMethodError(transport, "Could not find transport.")
continue
except error.CannotListenError:
log.warning("Could not set up listener for '%s'." % transport)
- reportFailure(transport, "Could not set up listener.")
+ ptserver.reportMethodError(transport, "Could not set up listener.")
continue
should_start_event_loop = True
log.debug("Successfully launched '%s' at '%s'" % (transport, log.safe_addr_str(str(addrport))))
- reportSuccess(transport, addrport, None)
+ ptserver.reportMethodSuccess(transport, addrport, None)
- reportEnd()
+ ptserver.reportMethodsEnd()
if should_start_event_loop:
log.info("Starting up the event loop.")
--
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