[Pkg-privacy-commits] [obfsproxy] 59/353: Start using the logging subsystem.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:39 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 76471b37be09fc9801befd468daec625baa8faf7
Author: George Kadianakis <desnacked at riseup.net>
Date: Wed Sep 5 03:27:50 2012 +0300
Start using the logging subsystem.
---
src/obfsproxy/framework/managed/client.py | 5 +--
src/obfsproxy/framework/proxy.py | 16 ++++----
src/obfsproxy/framework/pump.py | 67 ++++++++++++++-----------------
src/obfsproxy/framework/socks.py | 24 +++++------
src/obfsproxy/transports/dummy.py | 2 -
5 files changed, 52 insertions(+), 62 deletions(-)
diff --git a/src/obfsproxy/framework/managed/client.py b/src/obfsproxy/framework/managed/client.py
index 4b48031..9b7c526 100755
--- a/src/obfsproxy/framework/managed/client.py
+++ b/src/obfsproxy/framework/managed/client.py
@@ -1,8 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-import logging
-
import monocle
from monocle import _o, Return
monocle.init('tornado')
@@ -20,6 +18,7 @@ from obfsproxy.transports.obfs3 import Obfs3Client
from pyptlib.easy.client import init, reportSuccess, reportFailure, \
reportEnd
+import obfsproxy.common.log as log
class TransportLaunchException(Exception):
@@ -45,7 +44,7 @@ class ManagedClient:
for transport in managed_info['transports']:
try:
- logging.error('Launching %s' % transport)
+ log.error('Launching %s' % transport)
self.launchClient(transport, 8182) # XXX hardcoded
reportSuccess(transport, 5, ('127.0.0.1', 8182), None,
None)
diff --git a/src/obfsproxy/framework/proxy.py b/src/obfsproxy/framework/proxy.py
index 449604f..7ee4ad4 100644
--- a/src/obfsproxy/framework/proxy.py
+++ b/src/obfsproxy/framework/proxy.py
@@ -5,8 +5,6 @@
The proxy module contains the ProxyHandler class, which implements the server-side handling of pluggable transports.
"""
-import logging
-
from struct import unpack
from socket import inet_ntoa
@@ -20,6 +18,7 @@ from obfsproxy.util import encode
from obfsproxy.framework.pump import Pump
+import obfsproxy.common.log as log
class ProxyHandler:
@@ -42,14 +41,15 @@ class ProxyHandler:
def handle(self, conn):
""" handle is called by the framework to establish a new proxy connection to the Tor server and start processing when an incoming client connection is established. """
- logging.error('connection')
- logging.error('connecting %s:%d' % (self.addr, self.port))
+ log.error('connection')
+ log.error('connecting %s:%d' % (self.addr, self.port))
+ log.error('types: %s:%s' % (str(type(self.addr)), str(type(self.port))))
client = Client()
- try:
- yield client.connect(self.addr, self.port)
- except Exception as e:
- logging.error('Error connecting to destination')
+ try:
+ yield client.connect(self.addr, self.port)
+ except Exception as e:
+ log.error('Error connecting to destination')
return
try:
diff --git a/src/obfsproxy/framework/pump.py b/src/obfsproxy/framework/pump.py
index b6a591a..689de95 100644
--- a/src/obfsproxy/framework/pump.py
+++ b/src/obfsproxy/framework/pump.py
@@ -3,7 +3,6 @@
""" The pump module contains the Pump class, which takes care of moving bytes between the upstream and downstream connections. """
-import logging
from traceback import print_exc
import monocle
@@ -16,6 +15,7 @@ from monocle.stack.network import ConnectionLost
from obfsproxy.util import encode
from obfsproxy.framework.circuit import Circuit
+import obfsproxy.common.log as log
class Pump(object):
@@ -49,7 +49,7 @@ class Pump(object):
@_o
def drain(self):
- logging.error('drain')
+ log.error('drain')
yield self.pumpOut(self.circuit.downstream, self.downstream)
yield self.pumpOut(self.circuit.upstream, self.upstream)
@@ -61,11 +61,11 @@ class Pump(object):
callback,
):
- logging.error('pumpIn yielding '+str(input))
- try:
- data = yield input.read_some()
- except ConnectionLost as e:
- logging.error('pumpIn: Connection lost')
+ log.error('pumpIn yielding '+str(input))
+ try:
+ data = yield input.read_some()
+ except ConnectionLost:
+ log.error('pumpIn: Connection lost')
yield Return(False)
except IOError:
print 'IOError'
@@ -77,10 +77,10 @@ class Pump(object):
yield Return(False)
if data:
- logging.error('pumpIn read ' + str(len(data)))
+ log.error('pumpIn read ' + str(len(data)))
try:
- output.write(data)
- logging.error('pumpIn wrote %d' % (len(data)))
+ output.write(data)
+ log.error('pumpIn wrote %d' % (len(data)))
callback()
except ConnectionLost:
print 'pumpIn: Connection lost'
@@ -93,16 +93,16 @@ class Pump(object):
print 'Exception'
print e
yield Return(False)
- else:
- logging.error('pumpIn no data')
+ else:
+ log.error('pumpIn no data')
logging.error('pumpIn returning True')
yield Return(True)
@_o
def pumpOut(self, input, output):
- logging.error('pumpOut yield')
- try:
+ log.error('pumpOut yield')
+ try:
data = input.read_some()
except ConnectionLost:
print 'pumpOut: Connection lost'
@@ -117,10 +117,10 @@ class Pump(object):
return
if data:
- logging.error('pumpOut read ' + str(len(data)))
+ log.error('pumpOut read ' + str(len(data)))
try:
yield output.write(data)
- logging.error('pumpOut wrote %d' % (len(data)))
+ log.error('pumpOut wrote %d' % (len(data)))
except ConnectionLost:
print 'pumpOut: Connection lost'
return
@@ -132,30 +132,23 @@ class Pump(object):
print 'Exception'
print e
return
- else:
- logging.error('pumpOut no data')
+ else:
+ log.error('pumpOut no data')
@_o
def pumpUpstream(self):
- try:
- pumping=True
- while pumping:
- logging.error('pump upstream')
- pumping=yield self.pumpIn(self.downstream, self.circuit.downstream, self.transport.receivedDownstream)
- yield self.drain()
- logging.error('pumping: '+str(pumping))
- except Exception as e:
- logging.error('Exception in pumpUpstream')
- logging.error(e)
+ pumping=True
+ while pumping:
+ log.error('pump upstream')
+ pumping=yield self.pumpIn(self.downstream, self.circuit.downstream,
+ self.transport.receivedDownstream)
+ yield self.drain()
@_o
def pumpDownstream(self):
- try:
- pumping=True
- while pumping:
- logging.error('pump downstream')
- pumping=yield self.pumpIn(self.upstream, self.circuit.upstream, self.transport.receivedUpstream)
- yield self.drain()
- except Exception as e:
- logging.error('Exception in pumpDownstream')
- logging.error(e)
+ pumping=True
+ while pumping:
+ log.error('pump downstream')
+ pumping=yield self.pumpIn(self.upstream, self.circuit.upstream,
+ self.transport.receivedUpstream)
+ yield self.drain()
diff --git a/src/obfsproxy/framework/socks.py b/src/obfsproxy/framework/socks.py
index 8950f5e..1b3cabc 100644
--- a/src/obfsproxy/framework/socks.py
+++ b/src/obfsproxy/framework/socks.py
@@ -5,7 +5,6 @@
The socks module contains the SocksHandler class, which implements the client-side handling of pluggable transports.
"""
-import logging
from struct import unpack
from socket import inet_ntoa
@@ -16,9 +15,10 @@ from monocle import _o, Return
from monocle.stack.network import Client
from obfsproxy.util import encode
-
from obfsproxy.framework.pump import Pump
+import obfsproxy.common.log as log
+
def uncompact(x):
""" uncompact is a convenience method for unpacking an IPv4 address from its byte representation. """
@@ -32,7 +32,7 @@ def readHandshake(conn):
""" readHandshake reads the SOCKS handshake information to the SOCKS client. """
version = (yield conn.read(1))
- logging.info('version: %s' % encode(str(version)))
+ log.info('version: %s' % encode(str(version)))
nauth = (yield conn.read(1))
nauth = unpack('B', nauth)[0]
auths = []
@@ -86,25 +86,25 @@ class SocksHandler:
def handle(self, conn):
""" handle is called by the framework to establish a new connection to the proxy server and start processing when an incoming SOCKS client connection is established. """
- logging.info('handle_socks')
+ log.info('handle_socks')
yield readHandshake(conn)
- logging.error('read handshake')
+ log.error('read handshake')
yield sendHandshake(conn)
- logging.error('send handshake')
+ log.error('send handshake')
dest = (yield readRequest(conn))
-# logging.error('read request: %s' % str(dest))
+# log.error('read request: %s' % str(dest))
yield sendResponse(dest, conn)
- logging.error('sent response')
+ log.error('sent response')
(addr, port) = uncompact(dest)
- logging.error('connecting %s:%d' % (addr, port))
+ log.error('connecting %s:%d' % (addr, port))
- logging.info(addr)
- logging.info(port)
+ log.info(addr)
+ log.info(port)
client = Client()
yield client.connect(addr, port)
- logging.info('connected %s:%d' % (addr, port))
+ log.info('connected %s:%d' % (addr, port))
self.pump = Pump(conn, client, self.transport)
yield self.pump.run()
diff --git a/src/obfsproxy/transports/dummy.py b/src/obfsproxy/transports/dummy.py
index 7d5e1f5..bbdece8 100644
--- a/src/obfsproxy/transports/dummy.py
+++ b/src/obfsproxy/transports/dummy.py
@@ -3,8 +3,6 @@
""" This module contains an implementation of the 'dummy' transport. """
-import logging
-
from obfsproxy.transports.base import BaseDaemon
--
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