[Pkg-privacy-commits] [obfsproxy] 39/353: Merge branch 'master' of https://github.com/blanu/py-obfsproxy

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:36 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 d7141eddf88c4b7210d6a931387545fe23e5cc16
Merge: 4b59827 aaa6dec
Author: Brandon Wiley <brandon at blanu.net>
Date:   Mon Aug 27 19:17:18 2012 -0500

    Merge branch 'master' of https://github.com/blanu/py-obfsproxy
    
    Conflicts:
    	src/cli.py
    	src/obfsproxy/framework/pump.py
    	src/obfsproxy/framework/socks.py
    	src/obfsproxy/framework/tunnel.py
    	src/obfsproxy/manager/clientManager.py
    	src/obfsproxy/transports/base.py
    	src/obfsproxy/transports/dummy.py

 bin/py-obfsproxy                           |   5 +-
 src/cli.py                                 |  24 ++---
 src/obfsproxy/crypto/aes.py                |  11 ++
 src/obfsproxy/framework/circuit.py         |  96 +++++++++++++++++
 src/obfsproxy/framework/managed/client.py  |   5 +-
 src/obfsproxy/framework/managed/server.py  |  20 ++--
 src/obfsproxy/framework/proxy.py           |  16 ++-
 src/obfsproxy/framework/pump.py            |  65 ++++++------
 src/obfsproxy/framework/socks.py           |  50 +++++----
 src/obfsproxy/manager/clientManager.py     |  24 ++++-
 src/obfsproxy/manager/manager.py           |  19 ++++
 src/obfsproxy/manager/serverManager.py     |  25 ++++-
 src/obfsproxy/transports/base.py           |  59 ++++++++++-
 src/obfsproxy/transports/dummy.py          |  39 +++++++
 src/obfsproxy/transports/dust_transport.py |  72 ++++++++++---
 src/obfsproxy/transports/obfs2.py          | 132 ++++++++++++++++-------
 src/obfsproxy/transports/obfs3.py          |  72 ++++++++++---
 src/obfsproxy/transports/rot13.py          |  60 ++++++++---
 src/obfsproxy/util.py                      | 162 -----------------------------
 19 files changed, 624 insertions(+), 332 deletions(-)

diff --cc src/obfsproxy/framework/pump.py
index aae3680,08574d3..af4e463
--- a/src/obfsproxy/framework/pump.py
+++ b/src/obfsproxy/framework/pump.py
@@@ -1,99 -1,103 +1,96 @@@
  #!/usr/bin/python
  # -*- coding: utf-8 -*-
  
+ """ The pump module contains the Pump class, which takes care of moving bytes between the upstream and downstream connections. """
+ 
 +import logging
 +
  import monocle
 +monocle.init('tornado')
 +
  from monocle import _o, Return
  
  from monocle.stack.network import ConnectionLost
  
  from obfsproxy.util import encode
- from obfsproxy.framework.tunnel import Tunnel
+ from obfsproxy.framework.circuit import Circuit
+ 
  
  class Pump(object):
-     def __init__(self, local, remote, transportClass):
- 	logging.error('pump init')
-         self.local=local
-         self.remote=remote
 -
+     """ The Pump class takes care of moving bytes between the upstream and downstream connections. """
  
-         self.tunnel=Tunnel()
-         self.transport=transportClass(self.tunnel.invert())
+     def __init__(
+         self,
+         downstream,
+         upstream,
+         transportClass,
+         ):
+         """ Initializes the downstream and upstream instance variables, instantiates the transportClass, and sets up a circuit. """
  
-         logging.error('Buffers:')
-         logging.error('local in: '+str(self.tunnel.local.incomingBuffer))
-         logging.error('local out: '+str(self.tunnel.local.outgoingBuffer))
-         logging.error('remote in: '+str(self.tunnel.remote.incomingBuffer))
-         logging.error('remote out: '+str(self.tunnel.remote.outgoingBuffer))
+         self.downstream = downstream
+         self.upstream = upstream
+ 
+         circuit = Circuit()
+         self.transport = transportClass(circuit)
+         self.circuit = circuit.invert()
  
 +    @_o
      def run(self):
- 	logging.error('pump run')
+         """ Calls the start event on the transport and initiates pumping between upstream and downstream connections in both directions. """
 -
          self.transport.start()
 +
 +        self.drain()
 +
-         monocle.launch(self.pumpLocal)
-         yield self.pumpRemote()
-         logging.error('end pump run')
+         monocle.launch(self.pumpDownstream)
+         yield self.pumpUpstream()
  
      @_o
 -    def pumpDownstream(self):
 -        """ Handle the downstream connection. """
 -
 -        while True:
 -            data = self.circuit.downstream.read_some()
 -            if data:
 -                try:
 -                    yield self.downstream.write(data)
 -                except ConnectionLost:
 -                    print 'Connection lost'
 -                    return
 -                except IOError:
 -                    print 'IOError'
 -                    return
 -                except Exception, e:
 -                    print 'Exception'
 -                    print e
 -                    return
 +    def drain(self):
 +        logging.error('drain')
-         yield self.pumpOut(self.tunnel.local, self.local)
-         yield self.pumpOut(self.tunnel.remote, self.remote)
++        yield self.pumpOut(self.circuit.downstream, self.downstream)
++        yield self.pumpOut(self.circuit.upstream, self.upstream)
  
 +    @_o
 +    def pumpIn(self, input, output, callback):
 +        logging.error('pumpIn')
 +        data=yield input.read_some()
 +        if data:
 +            logging.error('Pump read '+str(len(data))+' from tunnel')
              try:
-                 output.write(data)
-                 callback()
+                 data = (yield self.downstream.read_some())
+                 if data:
+                     self.circuit.downstream.write(data)
+                     self.transport.receivedDownstream()
              except ConnectionLost:
 -                print 'Client connection closed'
 +                print 'Connection lost'
                  return
              except IOError:
 +                print 'IOError'
 +                return
 +            except Exception, e:
 +                print 'Exception'
 +                print e
                  return
  
      @_o
 -    def pumpUpstream(self):
 -        """ Handle the upstream connection. """
 -
 -        while True:
 -            data = self.circuit.upstream.read_some()
 -            if data:
 -                try:
 -                    yield self.upstream.write(data)
 -                except ConnectionLost:
 -                    print 'Connection lost'
 -                    return
 -                except IOError:
 -                    print 'IOError'
 -                    return
 -                except Exception, e:
 -                    print 'Exception'
 -                    print e
 -                    return
 -
 +    def pumpOut(self, input, output):
 +        logging.error('pumpOut')
 +        data=input.read_some()
 +        if data:
 +            logging.error('Pump read '+str(len(data))+' from tunnel')
              try:
 -                data = (yield self.upstream.read_some())
 -                if data:
 -                    self.circuit.upstream.write(data)
 -                    self.transport.receivedUpstream()
 -            except ConnectionLost:
 -                print 'Client connection closed'
 -                return
 -            except IOError:
 -                return
 +                yield output.write(data)
-             except ConnectionLost:
-                 print 'Connection lost'
-                 return
-             except IOError:
-                 print 'IOError'
-                 return
-             except Exception, e:
-                 print 'Exception'
-                 print e
-                 return
  
 +    @_o
-     def pumpLocal(self):
++    def pumpUpstream(self):
 +	logging.error('pump local')
 +        while True:
-             yield self.pumpIn(self.local, self.tunnel.local, self.transport.decodedReceived)
++            yield self.pumpIn(self.dowstream, self.circuit.dowstream, self.transport.downstreamReceived)
 +            yield self.drain()
  
 +    @_o
-     def pumpRemote(self):
++    def pumpDownstream(self):
 +	logging.error('pump remote')
 +        while True:
-             yield self.pumpIn(self.remote, self.tunnel.remote, self.transport.encodedReceived)
++            yield self.pumpIn(self.upstream, self.circuit.upstream, self.transport.upstreamReceived)
 +            yield self.drain()
diff --cc src/obfsproxy/framework/socks.py
index 156a34e,b71833a..cf7f735
--- a/src/obfsproxy/framework/socks.py
+++ b/src/obfsproxy/framework/socks.py
@@@ -63,16 -84,17 +84,17 @@@ class SocksHandler
  
      @_o
      def handle(self, conn):
- 	logging.error('new socks connection')
-         logging.error('handle_socks')
+         """ 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')
          yield readHandshake(conn)
 -        logging.info('read handshake')
 +        logging.error('read handshake')
          yield sendHandshake(conn)
 -        logging.info('send handshake')
 +        logging.error('send handshake')
          dest = (yield readRequest(conn))
-         logging.error('read request: %s' % (str(dest)))
+         logging.info('read request: %s' % str(dest))
          yield sendResponse(dest, conn)
 -        logging.info('sent response')
 +        logging.error('sent response')
  
          (addr, port) = uncompact(dest)
  
@@@ -84,12 -103,9 +103,7 @@@
  
          client = Client()
          yield client.connect(addr, port)
-         logging.error('connected %s:%d' % (addr, port))
- 
- 	try:
- 	    self.pump=Pump(conn, client, self.transport)
-             logging.error('Pump: '+str(self.pump))
-             yield self.pump.run()
-             logging.error('ran pump')
- 	except Exception as e:
- 	    logging.error('Pump error: '+str(e))
+         logging.info('connected %s:%d' % (addr, port))
+ 
+         self.pump = Pump(conn, client, self.transport)
+         self.pump.run()
 -
 -
diff --cc src/obfsproxy/manager/clientManager.py
index ec1400c,ebadb26..32c29dd
--- a/src/obfsproxy/manager/clientManager.py
+++ b/src/obfsproxy/manager/clientManager.py
@@@ -15,8 -30,6 +30,9 @@@ class ClientManager(Manager)
  
  
  if __name__ == '__main__':
 -    transport = sys.argv[1]
 -    manager = ClientManager(transport)
 -    manager.launch()
 +    try:
-         manager = ClientManager()
-         manager.launch()
++      transport = sys.argv[1]
++      manager = ClientManager(transport)
++      manager.launch()
 +    except Exception as e:
 +      print('Exception: '+str(e))
diff --cc src/obfsproxy/transports/base.py
index 1fccb08,8567894..82c798e
--- a/src/obfsproxy/transports/base.py
+++ b/src/obfsproxy/transports/base.py
@@@ -4,9 -10,15 +10,21 @@@ However, BaseDaemon provides utility me
  
  class BaseDaemon:
  
++<<<<<<< HEAD
 +    def __init__(self, tunnel):
 +        self.decodedSocket = tunnel.local
 +        self.encodedSocket = tunnel.remote
++=======
+     """
+     The BaseDaemon class is a base class for implementing pluggable transport clients and server.
+     """
+ 
+     def __init__(self, downstreamConnection, upstreamConnection):
+         """ Store the upstream and downstream sockets for use in other methods. """
+ 
+         self.downstreamConnection = downstreamConnection
+         self.upstreamConnection = upstreamConnection
++>>>>>>> aaa6decd2a9f03db165cf03e0d369113bc5818c1
  
      def read(
          self,
diff --cc src/obfsproxy/transports/dummy.py
index dc5dbe6,808ddbc..dc1c695
--- a/src/obfsproxy/transports/dummy.py
+++ b/src/obfsproxy/transports/dummy.py
@@@ -1,23 -1,35 +1,52 @@@
  #!/usr/bin/python
  # -*- coding: utf-8 -*-
  
++<<<<<<< HEAD
 +import logging
++=======
+ """ This module contains an implementation of the 'dummy' transport. """
++>>>>>>> aaa6decd2a9f03db165cf03e0d369113bc5818c1
  
  from obfsproxy.transports.base import BaseDaemon
  
  
  class DummyDaemon(BaseDaemon):
  
++<<<<<<< HEAD
 +    def decodedReceived(self):
 +        logging.error('dummy decoded received')
 +        data = self.decodedSocket.read_some()
 +        self.encodedSocket.write(data)
 +        logging.error('wrote '+str(len(data))+' encoded')
 +
 +    def encodedReceived(self):
 +        logging.error('dummy encoded received')
 +        data = self.encodedSocket.read_some()
 +        self.decodedSocket.write(data)
++=======
+     """
+     DummyDaemon is the base class for DummyClient and DummyServer.
+     Since the protocol is so simple, DummyDaemon provides all of the functionality for the dummy protocol implementation.
+     """
+ 
+     def receivedDownstream(self):
+         """
+         receivedDownstream is the event which is called when bytes are received from the downstream socket.
+         The dummy protocol just writes these to the upstream socket.
+         """
+ 
+         data = self.downstreamConnection.readAll()
+         self.upstreamConnection.write(data)
+ 
+     def receivedUpstream(self):
+         """
+         receivedUpstream is the event which is called when bytes are received from the upstream socket.
+         The dummy protocol just writes these to the downstream socket.
+         """
+ 
+         data = self.upstreamConnection.readAll()
+         self.downstreamConnection.write(data)
++>>>>>>> aaa6decd2a9f03db165cf03e0d369113bc5818c1
  
  
  class DummyClient(DummyDaemon):

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