[Pkg-privacy-commits] [obfsproxy] 61/353: Prepare for the Twisted rewrite -- delete files.

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 33e6f25d4ed8a9833303ce0d1aa3d0b5f23b4ad7
Author: George Kadianakis <desnacked at riseup.net>
Date:   Mon Sep 17 04:05:13 2012 +0300

    Prepare for the Twisted rewrite -- delete files.
    
    Delete monocle networking files.
---
 src/obfsproxy/framework/circuit.py |  96 -----------------------
 src/obfsproxy/framework/proxy.py   |  62 ---------------
 src/obfsproxy/framework/pump.py    | 154 -------------------------------------
 3 files changed, 312 deletions(-)

diff --git a/src/obfsproxy/framework/circuit.py b/src/obfsproxy/framework/circuit.py
deleted file mode 100644
index ccd6f5d..0000000
--- a/src/obfsproxy/framework/circuit.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-""" The circuit module contains the Buffer, Connection, and Circuit classes, which are used for managing connections. """
-
-
-class Buffer(object):
-
-    """ The Buffer class manages an internal byte buffer, allowing for reading and writing. """
-
-    def __init__(self):
-        """ Initialize the Buffer with an empty byte buffer. """
-
-        self.buffer = bytes('')
-
-    def read(self, x):
-        """ Read exactly x bytes from the buffer. If x bytes are not available, return None. """
-
-        if len(self.buffer) < x:
-            return None
-        else:
-            data = self.buffer[:x]
-            self.buffer = self.buffer[x:]
-            return data
-
-    def read_some(self):
-        """ Read all of the bytes from the buffer. """
-
-        return self.read(len(self.buffer))
-
-    def write(self, bs):
-        """ Write the bytes bs to the buffer. """
-
-        self.buffer = self.buffer + bs
-
-
-class Connection(object):
-
-    """ The Connection class contains two buffers, incoming and outgoing. It allows for reading from the incoming buffer and writing to the outgoing buffer. A Connection can be inverted to flip the incoming and outgoing buffers. """
-
-    def __init__(self, incoming=None, outgoing=None):
-        """ Initialize the Connection's incoming and outgoing buffers. If either buffer is supplied as an optional parameters, reuse that Buffer, otherwise create a new empty Buffer. """
-
-        if incoming:
-            self.incomingBuffer = incoming
-        else:
-            self.incomingBuffer = Buffer()
-
-        if outgoing:
-            self.outgoingBuffer = outgoing
-        else:
-            self.outgoingBuffer = Buffer()
-
-    def invert(self):
-        """ Returns a Connection with the incoming and outgoing buffers switched. """
-
-        return Connection(self.outgoingBuffer, self.incomingBuffer)
-
-    def read(self, x):
-        """ Read exactly x bytes from the incoming buffer. If x bytes are not available, return None. """
-
-        return self.incomingBuffer.read(x)
-
-    def read_some(self):
-        """ Read all of the bytes from the incoming buffer. """
-
-        return self.incomingBuffer.read_some()
-
-    def write(self, bs):
-        """ Write the bytes bs to the outgoing buffer. """
-
-        self.outgoingBuffer.write(bs)
-
-
-class Circuit(object):
-
-    """ The Circuit class contains two connections, one upstream and one downstream. """
-
-    def __init__(self, downstream=None, upstream=None):
-        """ Initialize the Circuit's upstream and downstream conections. If either connection is supplied as an optional parameters, reuse that Connection, otherwise create a new Connection. """
-
-        if downstream:
-            self.downstream = downstream
-        else:
-            self.downstream = Connection()
-        if upstream:
-            self.upstream = upstream
-        else:
-            self.upstream = Connection()
-
-    def invert(self):
-        """ Returns a Circuit with the incoming and outgoing buffers switched on the Connections. """
-
-        return Circuit(self.downstream.invert(), self.upstream.invert())
-
-
diff --git a/src/obfsproxy/framework/proxy.py b/src/obfsproxy/framework/proxy.py
deleted file mode 100644
index 7ee4ad4..0000000
--- a/src/obfsproxy/framework/proxy.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-"""
-The proxy module contains the ProxyHandler class, which implements the server-side handling of pluggable transports.
-"""
-
-from struct import unpack
-from socket import inet_ntoa
-
-import monocle
-monocle.init('tornado')
-
-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
-
-class ProxyHandler:
-
-    """
-    The ProxyHandler class implements the server-side handling of pluggable transports.
-    """
-
-    transport = None
-
-    def __init__(self, addr, port):
-        self.addr = addr
-        self.port = port
-
-    def setTransport(self, transport):
-        """ setTransport sets the pluggable transport for this proxy server """
-
-        self.transport = transport
-
-    @_o
-    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. """
-
-        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:
-	    log.error('Error connecting to destination')
-            return
-
-        try:
-            self.pump = Pump(conn, client, self.transport)
-            yield self.pump.run()
-        except Exception as e:
-            logging.error('Exception pumping')
-            logging.error(e)
-
-
diff --git a/src/obfsproxy/framework/pump.py b/src/obfsproxy/framework/pump.py
deleted file mode 100644
index 689de95..0000000
--- a/src/obfsproxy/framework/pump.py
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/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. """
-
-from traceback import print_exc
-
-import monocle
-monocle.init('tornado')
-
-from monocle import _o, Return
-
-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):
-
-    """ The Pump class takes care of moving bytes between the upstream and downstream connections. """
-
-    def __init__(
-        self,
-        downstream,
-        upstream,
-        transportClass,
-        ):
-        """ Initializes the downstream and upstream instance variables, instantiates the transportClass, and sets up a circuit. """
-
-        self.downstream = downstream
-        self.upstream = upstream
-
-        circuit = Circuit()
-        self.transport = transportClass(circuit)
-        self.circuit = circuit.invert()
-
-    @_o
-    def run(self):
-        """ 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.pumpUpstream)
-        yield self.pumpDownstream()
-
-    @_o
-    def drain(self):
-        log.error('drain')
-        yield self.pumpOut(self.circuit.downstream, self.downstream)
-        yield self.pumpOut(self.circuit.upstream, self.upstream)
-
-    @_o
-    def pumpIn(
-        self,
-        input,
-        output,
-        callback,
-        ):
-
-        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'
-            print_exc()
-            yield Return(False)
-        except Exception, e:
-            print 'Exception'
-            print e
-            yield Return(False)
-
-        if data:
-            log.error('pumpIn read ' + str(len(data)))
-            try:
-	        output.write(data)
-		log.error('pumpIn wrote %d' % (len(data)))
-                callback()
-            except ConnectionLost:
-                print 'pumpIn: Connection lost'
-                yield Return(False)
-            except IOError:
-                print 'IOError'
-                print_exc()
-                yield Return(False)
-            except Exception, e:
-                print 'Exception'
-                print e
-                yield Return(False)
-	else:
-		log.error('pumpIn no data')
-
-        logging.error('pumpIn returning True')
-        yield Return(True)
-
-    @_o
-    def pumpOut(self, input, output):
-        log.error('pumpOut yield')
-	try:
-            data = input.read_some()
-        except ConnectionLost:
-            print 'pumpOut: Connection lost'
-            return
-        except IOError:
-            print 'IOError'
-            print_exc()
-            return
-        except Exception, e:
-            print 'Exception'
-            print e
-            return
-
-        if data:
-            log.error('pumpOut read ' + str(len(data)))
-            try:
-                yield output.write(data)
-		log.error('pumpOut wrote %d' % (len(data)))
-            except ConnectionLost:
-                print 'pumpOut: Connection lost'
-                return
-            except IOError:
-                print 'IOError'
-                print_exc()
-                return
-            except Exception, e:
-                print 'Exception'
-                print e
-                return
-	else:
-	    log.error('pumpOut no data')
-
-    @_o
-    def pumpUpstream(self):
-        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):
-        pumping=True
-        while pumping:
-            log.error('pump downstream')
-            pumping=yield self.pumpIn(self.upstream, self.circuit.upstream,
-                              self.transport.receivedUpstream)
-            yield self.drain()

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