[Pkg-privacy-commits] [obfsproxy] 02/353: Initial import of code from pyptlib

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:31 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 1b17847fd6a965c0292f311118cc9996edfc3f3b
Author: Brandon Wiley <brandon at blanu.net>
Date:   Mon Jun 25 13:49:44 2012 -0500

    Initial import of code from pyptlib
---
 LICENSE                                    |  27 +++++
 README                                     |   2 +
 py-obfsproxy.xcodeproj/project.pbxproj     | 155 +++++++++++++++++++++++++++++
 setup.py                                   |  31 ++++++
 src/__init__.py                            |   0
 src/pyptlib/__init__.py                    |   0
 src/pyptlib/__init__.pyc                   | Bin 0 -> 137 bytes
 src/pyptlib/cli/obfsproxy.py               |  36 +++++++
 src/pyptlib/config/__init__.py             |   0
 src/pyptlib/config/__init__.pyc            | Bin 0 -> 144 bytes
 src/pyptlib/config/client.py               |  43 ++++++++
 src/pyptlib/config/client.pyc              | Bin 0 -> 1911 bytes
 src/pyptlib/config/config.py               |  70 +++++++++++++
 src/pyptlib/config/config.pyc              | Bin 0 -> 3069 bytes
 src/pyptlib/config/server.py               | 115 +++++++++++++++++++++
 src/pyptlib/config/server.pyc              | Bin 0 -> 4442 bytes
 src/pyptlib/framework/__init__.py          |   0
 src/pyptlib/framework/daemon.py            |  52 ++++++++++
 src/pyptlib/framework/external/__init__.py |   0
 src/pyptlib/framework/external/client.py   |  63 ++++++++++++
 src/pyptlib/framework/external/server.py   |  62 ++++++++++++
 src/pyptlib/framework/loopback.py          |  64 ++++++++++++
 src/pyptlib/framework/managed/__init__.py  |   0
 src/pyptlib/framework/managed/client.py    |  63 ++++++++++++
 src/pyptlib/framework/managed/server.py    |  62 ++++++++++++
 src/pyptlib/framework/proxy.py             |  27 +++++
 src/pyptlib/framework/shared.py            |  47 +++++++++
 src/pyptlib/framework/socks.py             |  71 +++++++++++++
 src/pyptlib/manager/__init__.py            |   0
 src/pyptlib/manager/__init__.pyc           | Bin 0 -> 145 bytes
 src/pyptlib/manager/clientManager.py       |  14 +++
 src/pyptlib/manager/manager.py             |  17 ++++
 src/pyptlib/manager/manager.pyc            | Bin 0 -> 1156 bytes
 src/pyptlib/manager/serverManager.py       |  16 +++
 src/pyptlib/transports/__init__.py         |   0
 src/pyptlib/transports/__init__.pyc        | Bin 0 -> 148 bytes
 src/pyptlib/transports/dummy.py            |  14 +++
 src/pyptlib/transports/dummy.pyc           | Bin 0 -> 1187 bytes
 src/pyptlib/transports/rot13.py            |  22 ++++
 src/pyptlib/util.py                        | 135 +++++++++++++++++++++++++
 src/pyptlib/util.pyc                       | Bin 0 -> 4877 bytes
 41 files changed, 1208 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..63ffde9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+    * Neither the names of the copyright owners nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README b/README
new file mode 100644
index 0000000..3b3f311
--- /dev/null
+++ b/README
@@ -0,0 +1,2 @@
+This is a python implementation of the Pluggable Transports for Circumvention specification for Tor:
+https://gitweb.torproject.org/torspec.git/blob_plain/HEAD:/proposals/180-pluggable-transport.txt
diff --git a/py-obfsproxy.xcodeproj/project.pbxproj b/py-obfsproxy.xcodeproj/project.pbxproj
index 4379829..73bda22 100644
--- a/py-obfsproxy.xcodeproj/project.pbxproj
+++ b/py-obfsproxy.xcodeproj/project.pbxproj
@@ -6,11 +6,166 @@
 	objectVersion = 46;
 	objects = {
 
+/* Begin PBXFileReference section */
+		89C39C6D1598EA2600271216 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
+		89C39C6E1598EA2600271216 /* README */ = {isa = PBXFileReference; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
+		89C39C6F1598EA2600271216 /* setup.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = setup.py; sourceTree = "<group>"; };
+		89C39C711598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C731598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C741598EA2600271216 /* __init__.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = __init__.pyc; sourceTree = "<group>"; };
+		89C39C761598EA2600271216 /* obfsproxy.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = obfsproxy.py; sourceTree = "<group>"; };
+		89C39C781598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C791598EA2600271216 /* __init__.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = __init__.pyc; sourceTree = "<group>"; };
+		89C39C7A1598EA2600271216 /* client.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = client.py; sourceTree = "<group>"; };
+		89C39C7B1598EA2600271216 /* client.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.pyc; sourceTree = "<group>"; };
+		89C39C7C1598EA2600271216 /* config.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = config.py; sourceTree = "<group>"; };
+		89C39C7D1598EA2600271216 /* config.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = config.pyc; sourceTree = "<group>"; };
+		89C39C7E1598EA2600271216 /* server.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = server.py; sourceTree = "<group>"; };
+		89C39C7F1598EA2600271216 /* server.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.pyc; sourceTree = "<group>"; };
+		89C39C811598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C821598EA2600271216 /* daemon.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = daemon.py; sourceTree = "<group>"; };
+		89C39C841598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C851598EA2600271216 /* client.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = client.py; sourceTree = "<group>"; };
+		89C39C861598EA2600271216 /* server.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = server.py; sourceTree = "<group>"; };
+		89C39C871598EA2600271216 /* loopback.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = loopback.py; sourceTree = "<group>"; };
+		89C39C891598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C8A1598EA2600271216 /* client.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = client.py; sourceTree = "<group>"; };
+		89C39C8B1598EA2600271216 /* server.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = server.py; sourceTree = "<group>"; };
+		89C39C8C1598EA2600271216 /* proxy.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = proxy.py; sourceTree = "<group>"; };
+		89C39C8D1598EA2600271216 /* shared.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = shared.py; sourceTree = "<group>"; };
+		89C39C8E1598EA2600271216 /* socks.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = socks.py; sourceTree = "<group>"; };
+		89C39C901598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C911598EA2600271216 /* __init__.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = __init__.pyc; sourceTree = "<group>"; };
+		89C39C921598EA2600271216 /* clientManager.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = clientManager.py; sourceTree = "<group>"; };
+		89C39C931598EA2600271216 /* manager.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = manager.py; sourceTree = "<group>"; };
+		89C39C941598EA2600271216 /* manager.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = manager.pyc; sourceTree = "<group>"; };
+		89C39C951598EA2600271216 /* serverManager.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = serverManager.py; sourceTree = "<group>"; };
+		89C39C971598EA2600271216 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
+		89C39C981598EA2600271216 /* __init__.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = __init__.pyc; sourceTree = "<group>"; };
+		89C39C991598EA2600271216 /* dummy.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = dummy.py; sourceTree = "<group>"; };
+		89C39C9A1598EA2600271216 /* dummy.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = dummy.pyc; sourceTree = "<group>"; };
+		89C39C9B1598EA2600271216 /* rot13.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = rot13.py; sourceTree = "<group>"; };
+		89C39C9C1598EA2600271216 /* util.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = util.py; sourceTree = "<group>"; };
+		89C39C9D1598EA2600271216 /* util.pyc */ = {isa = PBXFileReference; lastKnownFileType = file; path = util.pyc; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
 /* Begin PBXGroup section */
 		89C39C641598E9DE00271216 = {
 			isa = PBXGroup;
 			children = (
+				89C39C6D1598EA2600271216 /* LICENSE */,
+				89C39C6E1598EA2600271216 /* README */,
+				89C39C6F1598EA2600271216 /* setup.py */,
+				89C39C701598EA2600271216 /* src */,
+			);
+			sourceTree = "<group>";
+		};
+		89C39C701598EA2600271216 /* src */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C711598EA2600271216 /* __init__.py */,
+				89C39C721598EA2600271216 /* pyptlib */,
+			);
+			path = src;
+			sourceTree = "<group>";
+		};
+		89C39C721598EA2600271216 /* pyptlib */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C731598EA2600271216 /* __init__.py */,
+				89C39C741598EA2600271216 /* __init__.pyc */,
+				89C39C751598EA2600271216 /* cli */,
+				89C39C771598EA2600271216 /* config */,
+				89C39C801598EA2600271216 /* framework */,
+				89C39C8F1598EA2600271216 /* manager */,
+				89C39C961598EA2600271216 /* transports */,
+				89C39C9C1598EA2600271216 /* util.py */,
+				89C39C9D1598EA2600271216 /* util.pyc */,
+			);
+			path = pyptlib;
+			sourceTree = "<group>";
+		};
+		89C39C751598EA2600271216 /* cli */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C761598EA2600271216 /* obfsproxy.py */,
+			);
+			path = cli;
+			sourceTree = "<group>";
+		};
+		89C39C771598EA2600271216 /* config */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C781598EA2600271216 /* __init__.py */,
+				89C39C791598EA2600271216 /* __init__.pyc */,
+				89C39C7A1598EA2600271216 /* client.py */,
+				89C39C7B1598EA2600271216 /* client.pyc */,
+				89C39C7C1598EA2600271216 /* config.py */,
+				89C39C7D1598EA2600271216 /* config.pyc */,
+				89C39C7E1598EA2600271216 /* server.py */,
+				89C39C7F1598EA2600271216 /* server.pyc */,
+			);
+			path = config;
+			sourceTree = "<group>";
+		};
+		89C39C801598EA2600271216 /* framework */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C811598EA2600271216 /* __init__.py */,
+				89C39C821598EA2600271216 /* daemon.py */,
+				89C39C831598EA2600271216 /* external */,
+				89C39C871598EA2600271216 /* loopback.py */,
+				89C39C881598EA2600271216 /* managed */,
+				89C39C8C1598EA2600271216 /* proxy.py */,
+				89C39C8D1598EA2600271216 /* shared.py */,
+				89C39C8E1598EA2600271216 /* socks.py */,
+			);
+			path = framework;
+			sourceTree = "<group>";
+		};
+		89C39C831598EA2600271216 /* external */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C841598EA2600271216 /* __init__.py */,
+				89C39C851598EA2600271216 /* client.py */,
+				89C39C861598EA2600271216 /* server.py */,
+			);
+			path = external;
+			sourceTree = "<group>";
+		};
+		89C39C881598EA2600271216 /* managed */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C891598EA2600271216 /* __init__.py */,
+				89C39C8A1598EA2600271216 /* client.py */,
+				89C39C8B1598EA2600271216 /* server.py */,
+			);
+			path = managed;
+			sourceTree = "<group>";
+		};
+		89C39C8F1598EA2600271216 /* manager */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C901598EA2600271216 /* __init__.py */,
+				89C39C911598EA2600271216 /* __init__.pyc */,
+				89C39C921598EA2600271216 /* clientManager.py */,
+				89C39C931598EA2600271216 /* manager.py */,
+				89C39C941598EA2600271216 /* manager.pyc */,
+				89C39C951598EA2600271216 /* serverManager.py */,
+			);
+			path = manager;
+			sourceTree = "<group>";
+		};
+		89C39C961598EA2600271216 /* transports */ = {
+			isa = PBXGroup;
+			children = (
+				89C39C971598EA2600271216 /* __init__.py */,
+				89C39C981598EA2600271216 /* __init__.pyc */,
+				89C39C991598EA2600271216 /* dummy.py */,
+				89C39C9A1598EA2600271216 /* dummy.pyc */,
+				89C39C9B1598EA2600271216 /* rot13.py */,
 			);
+			path = transports;
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..83353dc
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+import sys
+
+sys.path.insert(0, 'src')
+
+from setuptools import setup
+
+setup(name='pyptlib',
+      version='0.1',
+      description='A python implementation of the Pluggable Transports for Circumvention specification for Tor',
+      long_description='A python implementation of the Pluggable Transports for Circumvention specification for Tor',
+      author='Brandon Wiley',
+      author_email='brandon at blanu.net',
+      url='http://stepthreeprivacy.org/',
+      classifiers=[
+	"Development Status :: 3 - Alpha",
+    	"Environment :: No Input/Output (Daemon)",
+    	"License :: OSI Approved :: BSD License",
+    	"Programming Language :: Python",
+    	"Intended Audience :: Developers",
+    	"Operating System :: OS Independent",
+    	"Topic :: Internet",
+    	"Topic :: Security :: Cryptography",
+    	"Topic :: Software Development :: Libraries :: Python Modules",
+      ],
+      keywords='cryptography privacy internet',
+      license='BSD',
+      package_dir={'pyptlib': 'src/pyptlib'},
+      packages=['pyptlib'],
+     )
diff --git a/src/__init__.py b/src/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/__init__.py b/src/pyptlib/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/__init__.pyc b/src/pyptlib/__init__.pyc
new file mode 100644
index 0000000..e50beb2
Binary files /dev/null and b/src/pyptlib/__init__.pyc differ
diff --git a/src/pyptlib/cli/obfsproxy.py b/src/pyptlib/cli/obfsproxy.py
new file mode 100644
index 0000000..e2d81bf
--- /dev/null
+++ b/src/pyptlib/cli/obfsproxy.py
@@ -0,0 +1,36 @@
+import argparse
+
+from pyptlib.framework.server import ManagedServer
+from pyptlib.framework.client import ManagedClient
+
+protocols=['dummy', 'rot13']
+
+if __name__=='__main__':
+  parser=argparse.ArgumentParser(description="* Available protocols: "+(' '.join(protocols)))
+  parser.add_argument('--log-file', nargs=1, help='set logfile')
+  parser.add_argument('--log-min-severity', nargs=1, default='notice', choices=['warn', 'notice', 'info', 'debug'], help='set minimum logging severity (default: %(default)s)')
+  parser.add_argument('--no-log', action='store_false', default=True, help='disable logging')
+  parser.add_argument('--no-safe-logging', action='store_false', default=True, help='disable safe (scrubbed address) logging')
+  parser.add_argument('--managed', action='store_true', default=False, help='enabled managed mode, for use when called by tor')
+  parser.add_argument('--dest', nargs=1, help='set destination, enable client mode instead of server mode')
+
+  parser.add_argument('obfsproxy_args')
+  parser.add_argument('protocol_name')
+  parser.add_argument('protocol_args')
+  parser.add_argument('protocol_options')
+  parser.add_argument('protocol_name')
+
+  args = parser.parse_args()
+
+  print(args)
+
+  if managed:
+    if dest:
+      client=ManagedClient()
+    else:
+      server=ManagedServer()
+  else:
+    if dest:
+      client=ExternalClient()
+    else:
+      server=ExternalServer()
diff --git a/src/pyptlib/config/__init__.py b/src/pyptlib/config/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/config/__init__.pyc b/src/pyptlib/config/__init__.pyc
new file mode 100644
index 0000000..1bd55bb
Binary files /dev/null and b/src/pyptlib/config/__init__.pyc differ
diff --git a/src/pyptlib/config/client.py b/src/pyptlib/config/client.py
new file mode 100644
index 0000000..0cc268c
--- /dev/null
+++ b/src/pyptlib/config/client.py
@@ -0,0 +1,43 @@
+import os
+
+from pyptlib.config.config import Config
+
+"""
+Configuration for a Pluggable Transport client.
+"""
+
+__docformat__ = 'restructuredtext'
+
+class ClientConfig(Config):  
+  #Public methods
+  
+  def __init__(self): # throws EnvError
+    Config.__init__(self)
+    
+    self.transports=self.get('TOR_PT_CLIENT_TRANSPORTS').split(',')
+    if '*' in self.transports:
+      self.allTransportsEnabled=True
+      self.transports.remove('*')      
+
+  # Returns a list of strings representing the client transports reported by Tor. If present, '*' is stripped from this list and used to set allTransportsEnabled to True.
+  def getClientTransports(self):
+    return self.transports
+
+  # Write a message to stdout specifying a supported transport
+  # Takes: str, int, (str, int), [str], [str]
+  def writeMethod(self, name, socksVersion, address, args, optArgs): # CMETHOD
+    methodLine='CMETHOD %s socks%s %s:%s' % (name, socksVersion, address[0], address[1])
+    if args and len(args)>0:
+      methodLine=methodLine+' ARGS='+args.join(',')
+    if optArgs and len(optArgs)>0:
+      methodLine=methodLine+' OPT-ARGS='+args.join(',')
+    print(methodLine) 
+   
+  # Write a message to stdout specifying that an error occurred setting up the specified method
+  # Takes: str, str
+  def writeMethodError(self, name, message): # CMETHOD-ERROR
+    print('CMETHOD-ERROR %s %s' % (name, message))
+    
+  # Write a message to stdout specifying that the list of supported transports has ended
+  def writeMethodEnd(self): # CMETHODS DONE
+    print('CMETHODS DONE')
diff --git a/src/pyptlib/config/client.pyc b/src/pyptlib/config/client.pyc
new file mode 100644
index 0000000..5006f94
Binary files /dev/null and b/src/pyptlib/config/client.pyc differ
diff --git a/src/pyptlib/config/config.py b/src/pyptlib/config/config.py
new file mode 100644
index 0000000..148cc7a
--- /dev/null
+++ b/src/pyptlib/config/config.py
@@ -0,0 +1,70 @@
+import os
+
+"""
+The base class for the client and server config classes. This class should not be used directly. Instead, use pyptlib.client or pyptlib.server.
+"""
+
+__docformat__ = 'restructuredtext'
+
+class Config:
+  stateLocation=None     # TOR_PT_STATE_LOCATION
+  managedTransportVer=[] # TOR_PT_MANAGED_TRANSPORT_VER
+  transports=[] # TOR_PT_SERVER_TRANSPORTS or TOR_PT_CLIENT_TRANSPORTS
+  allTransportsEnabled=False
+  
+  #Public methods
+  
+  def __init__(self): # throws EnvError
+    self.stateLocation=self.get('TOR_PT_STATE_LOCATION')
+    self.managedTransportVer=self.get('TOR_PT_MANAGED_TRANSPORT_VER').split(',')
+        
+  # Returns a string representing the path to the state storage directory (which may not exist, but should be creatable) reported by Tor
+  def getStateLocation(self):
+    return self.stateLocation
+
+  # Returns a list of strings representing supported versions as reported by Tor    
+  def getManagedTransportVersions(self):
+    return self.managedTransportVer
+    
+  # Checks to see if the specified version is included in those reported by Tor
+  # Returns True if the version is included and False if it is not
+  def checkManagedTransportVersion(self, version):
+    return version in self.managedTransportVer
+
+  # Returns a bool, True if the transport '*' was specified by Tor, otherwise False.
+  def getAllTransportsEnabled(self):
+    return self.allTransportsEnabled
+    
+  def checkTransportEnabled(self, transport):
+    return self.allTransportsEnabled or transport in self.transports    
+
+  # Write a message to stdout specifying that an error parsing the environment variables has occurred
+  # Takes: str
+  def writeEnvError(self, message): # ENV-ERROR
+    print('ENV-ERROR %s' % (message))
+
+  # Write a message to stdout specifying that the specified configuration protocol version is supported   
+  # Takes: str
+  def writeVersion(self, version): # VERSION
+    print('VERSION %s' % (version))
+
+  # Write a message to stdout specifying that none of the specified configuration protocol versions are supported
+  def writeVersionError(self): # VERSION-ERROR
+    print('VERSION-ERROR no-version')
+    
+ # Private methods
+ 
+  def get(self, key):
+    if key in os.environ:
+      return os.environ[key]
+    else:
+      message="Missing environment variable %s" % (key)
+      self.writeEnvError(message)
+      raise EnvException(message)
+
+# Exception thrown when there is an error parsing the configuration parameters provided by Tor in environment variables    
+class EnvException(Exception):
+  message=None
+
+  def __init__(self, message):
+    self.message=message
diff --git a/src/pyptlib/config/config.pyc b/src/pyptlib/config/config.pyc
new file mode 100644
index 0000000..4710a84
Binary files /dev/null and b/src/pyptlib/config/config.pyc differ
diff --git a/src/pyptlib/config/server.py b/src/pyptlib/config/server.py
new file mode 100644
index 0000000..809de3b
--- /dev/null
+++ b/src/pyptlib/config/server.py
@@ -0,0 +1,115 @@
+import os
+
+from pyptlib.config.config import Config
+
+"""
+Configuration for a Pluggable Transport server.
+"""
+
+__docformat__ = 'restructuredtext'
+
+class ServerConfig(Config):
+  extendedServerPort=None # TOR_PT_EXTENDED_SERVER_PORT
+  ORPort=None             # TOR_PT_ORPORT
+  serverBindAddr={}       # TOR_PT_SERVER_BINADDR
+  
+  #Public methods
+  
+  def __init__(self): # throws EnvError
+    Config.__init__(self)
+    
+    self.extendedServerPort=self.get('TOR_PT_EXTENDED_SERVER_PORT')
+    self.ORPort=self.get('TOR_PT_ORPORT')
+    
+    binds=self.get('TOR_PT_SERVER_BINDADDR').split(',')
+    for bind in binds:
+      key,value=bind.split('-')
+      self.serverBindAddr[key]=value
+    
+    self.transports=self.get('TOR_PT_SERVER_TRANSPORTS').split(',')
+    if '*' in self.transports:
+      self.allTransportsEnabled=True
+      self.transports.remove('*')      
+    
+  # Returns a tuple (str,int) representing the address of the Tor server port as reported by Tor
+  def getExtendedServerPort(self):
+    return self.extendedServerPort
+    
+  # Returns a tuple (str,int) representing the address of the Tor OR port as reported by Tor
+  def getORPort(self):
+    return self.ORPort
+    
+  # Returns a dict {str: (str,int)} representing the addresses for each transport as reported by Tor
+  def getServerBindAddresses(self):
+    return self.serverBindAddr
+    
+  # Returns a list of strings representing the server transports reported by Tor. If present, '*' is stripped from this list and used to set allTransportsEnabled to True.
+  def getServerTransports(self):
+    return self.transports
+    
+  # Write a message to stdout specifying a supported transport
+  # Takes: str, (str, int), MethodOptions
+  def writeMethod(self, name, address, options): # SMETHOD
+    if options:
+      print('SMETHOD %s %s:%s %s' % (name, address[0], address[1], options))
+    else:
+      print('SMETHOD %s %s:%s' % (name, address[0], address[1]))
+    
+  # Write a message to stdout specifying that an error occurred setting up the specified method
+  # Takes: str, str
+  def writeMethodError(self, name, message): # SMETHOD-ERROR
+    print('SMETHOD-ERROR %s %s' % (name, message))
+    
+  # Write a message to stdout specifying that the list of supported transports has ended
+  def writeMethodEnd(self): # SMETHODS DONE
+    print('SMETHODS DONE')
+
+class MethodOptions:
+  forward=False         # FORWARD
+  args={}               # ARGS
+  declare={}            # DECLARE
+  useExtendedPort=False # USE-EXTENDED-PORT
+
+  #Public methods
+  
+  def __init__(self):
+    pass
+
+  # Sets forward to True    
+  def setForward(self):
+    self.forward=True
+  
+  # Adds a key-value pair to args
+  def addArg(self, key, value):
+    self.args[key]=value
+
+  # Adds a key-value pair to declare    
+  def addDeclare(self, key, value):
+    self.declare[key]=value
+    
+  # Sets useExtendedPort to True
+  def setUserExtendedPort(self):
+    self.useExtendedPort=True
+
+  def __str__(self):
+    options=[]
+    if self.forward:
+      options.append('FORWARD:1')
+    if len(self.args)>0:
+      argstr='ARGS:'
+      for key in self.args:
+        value=self.args[key]
+        argstr=argstr+key+'='+value+','
+      argstr=argstr[:-1] # Remove trailing comma
+      options.append(argstr)
+    if len(self.declare)>0:
+      decs='DECLARE:'
+      for key in self.declare:
+        value=self.declare[key]
+        decs=decs+key+'='+value+','
+      decs=decs[:-1] # Remove trailing comma      
+      options.append(decs)
+    if self.useExtendedPort:
+      options.append('USE-EXTENDED-PORT:1')
+
+    return ' '.join(options)
diff --git a/src/pyptlib/config/server.pyc b/src/pyptlib/config/server.pyc
new file mode 100644
index 0000000..cf1017b
Binary files /dev/null and b/src/pyptlib/config/server.pyc differ
diff --git a/src/pyptlib/framework/__init__.py b/src/pyptlib/framework/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/framework/daemon.py b/src/pyptlib/framework/daemon.py
new file mode 100644
index 0000000..cc55605
--- /dev/null
+++ b/src/pyptlib/framework/daemon.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+import sys
+import time
+
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+monocle.init('tornado')
+
+from monocle.stack import eventloop
+from monocle.stack.network import add_service, Service, Client, ConnectionLost
+from pyptlib.framework.loopback import FakeSocket
+
+from pyptlib.framework.shared import *
+from pyptlib.framework.socks import *
+
+class Daemon:
+  config=None
+  handler=None
+  
+  supportedTransportVersion='1'
+  supportedTransport='dummy'
+
+  def __init__(self, configManager, handler):
+    self.config=configManager
+    self.handler=handler
+    
+    if self.config.checkManagedTransportVersion(self.supportedTransportVersion):
+      self.config.writeVersion(self.supportedTransportVersion)
+    else:
+      self.config.writeVersionError()
+      raise UnsupportedManagedTransportVersionException()
+        
+    if not self.config.checkTransportEnabled(self.supportedTransport):
+      raise NoSupportedTransportsException()
+  
+  def run(self):
+    eventloop.run()
+    
+class UnsupportedManagedTransportVersionException(Exception):
+  pass
+
+class NoSupportedTransportsException(Exception):
+  pass
+
+class TransportLaunchException(Exception):
+  def __init__(self, message):
+    self.message=message
+  
\ No newline at end of file
diff --git a/src/pyptlib/framework/external/__init__.py b/src/pyptlib/framework/external/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/framework/external/client.py b/src/pyptlib/framework/external/client.py
new file mode 100755
index 0000000..e60cd63
--- /dev/null
+++ b/src/pyptlib/framework/external/client.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python -u
+
+import os
+import sys
+
+import argparse
+
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+monocle.init('tornado')
+
+from monocle.stack import eventloop
+from monocle.stack.network import add_service, Service, Client, ConnectionLost
+from pyptlib.framework.loopback import FakeSocket
+
+from pyptlib.framework.socks import SocksHandler
+
+from pyptlib.config.config import EnvException
+from pyptlib.config.client import ClientConfig
+from pyptlib.framework.daemon import *
+
+from pyptlib.transports.dummy import DummyClient
+
+class ManagedClient(Daemon):
+  def __init__(self):
+    try:
+      Daemon.__init__(self, ClientConfig(), SocksHandler())
+    except EnvException:
+      print('error 0')
+      return
+    except UnsupportedManagedTransportVersionException:
+      print('error 1')
+      return
+    except NoSupportedTransportsException:
+      print('error 2')
+      return
+
+    try:
+      self.launchClient(self.supportedTransport, 8182)
+      self.config.writeMethod(self.supportedTransport, 5, ('127.0.0.1', 8182), None, None)
+    except TransportLaunchException as e:
+      print('error 3')
+      self.config.writeMethodError(self.supportedTransport, e.message)
+
+    self.config.writeMethodEnd()
+    
+    self.run()
+      
+  def launchClient(self, name, port):
+    if name!=self.supportedTransport:
+      raise TransportLaunchException('Tried to launch unsupported transport %s' % (name))
+
+    client=DummyClient()
+    self.handler.setTransport(client)
+    add_service(Service(self.handler, port=port))    
+
+if __name__=='__main__':
+  sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+  server=ManagedClient()
+  
\ No newline at end of file
diff --git a/src/pyptlib/framework/external/server.py b/src/pyptlib/framework/external/server.py
new file mode 100755
index 0000000..08b2e09
--- /dev/null
+++ b/src/pyptlib/framework/external/server.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python -u
+
+import os
+import sys
+
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+monocle.init('tornado')
+
+from monocle.stack import eventloop
+from monocle.stack.network import add_service, Service, Client
+
+from pyptlib.framework.shared import pump
+
+from pyptlib.config.config import EnvException
+from pyptlib.config.server import ServerConfig, MethodOptions
+from pyptlib.framework.daemon import *
+
+from pyptlib.framework.proxy import ProxyHandler
+
+from pyptlib.transports.dummy import DummyServer
+
+class ManagedServer(Daemon):
+  def __init__(self):
+    try:
+      Daemon.__init__(self, ServerConfig(), ProxyHandler())
+    except EnvException:
+      print('error 0')
+      return
+    except UnsupportedManagedTransportVersionException:
+      print('error 1')
+      return
+    except NoSupportedTransportsException:
+      print('error 2')
+      return
+
+    try:
+      self.launchServer(self.supportedTransport, 8182)
+      self.config.writeMethod(self.supportedTransport, ('127.0.0.1', 8182), MethodOptions())
+    except TransportLaunchException as e:
+      print('error 3')
+      self.config.writeMethodError(self.supportedTransport, e.message)
+
+    self.config.writeMethodEnd()
+    
+    self.run()
+    
+  def launchServer(self, name, port):
+    if name!=self.supportedTransport:
+      raise TransportLaunchException('Tried to launch unsupported transport %s' % (name))
+
+    client=DummyServer()
+    self.handler.setTransport(client)
+    add_service(Service(self.handler, port=port))   
+
+if __name__=='__main__':
+  sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+  server=ManagedServer()
+  
\ No newline at end of file
diff --git a/src/pyptlib/framework/loopback.py b/src/pyptlib/framework/loopback.py
new file mode 100644
index 0000000..ecdb4d3
--- /dev/null
+++ b/src/pyptlib/framework/loopback.py
@@ -0,0 +1,64 @@
+import monocle
+from monocle import _o
+monocle.init('tornado')
+
+from monocle.core import Callback, Return
+from monocle.stack import eventloop
+
+from monocle.stack.network import Connection, ConnectionLost
+from monocle.experimental import Channel
+
+buffsize=1024
+
+class FakeSocket(object):
+  def __init__(self, a=None, b=None):
+    if a==None:
+      self.a=Channel(buffsize)
+    else:
+      self.a=a
+    if b==None:
+      self.b=Channel(buffsize)
+    else:
+      self.b=b
+
+    self.inBuff=b''
+    self.outBuff=b''
+
+  def invert(self):
+    return FakeSocket(a=self.b, b=self.a)
+
+  @_o
+  def read(self, x):
+    while len(self.inBuff)<x:
+      data=yield self.a.recv()
+      if data:
+        self.inBuff=self.inBuff+data
+      else:
+        yield ConnectionLost()
+
+    data=self.inBuff[:x]
+    self.inBuff=self.inBuff[x:]
+
+    yield Return(data)
+
+  @_o
+  def read_some(self):
+    if len(self.inBuff)>0:
+      data=self.inBuff
+      self.inBuff=b''
+      yield Return(data)
+    else:
+      data=b''
+      while len(data)==0:
+        data=yield self.a.recv()
+      if data:
+        yield Return(data)
+      else:
+        yield ConnectionLost()
+
+  @_o
+  def write(self, bs):
+    yield self.b.send(bs)
+
+  def close(self):
+    yield self.b.send(None)
diff --git a/src/pyptlib/framework/managed/__init__.py b/src/pyptlib/framework/managed/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/framework/managed/client.py b/src/pyptlib/framework/managed/client.py
new file mode 100755
index 0000000..e60cd63
--- /dev/null
+++ b/src/pyptlib/framework/managed/client.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python -u
+
+import os
+import sys
+
+import argparse
+
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+monocle.init('tornado')
+
+from monocle.stack import eventloop
+from monocle.stack.network import add_service, Service, Client, ConnectionLost
+from pyptlib.framework.loopback import FakeSocket
+
+from pyptlib.framework.socks import SocksHandler
+
+from pyptlib.config.config import EnvException
+from pyptlib.config.client import ClientConfig
+from pyptlib.framework.daemon import *
+
+from pyptlib.transports.dummy import DummyClient
+
+class ManagedClient(Daemon):
+  def __init__(self):
+    try:
+      Daemon.__init__(self, ClientConfig(), SocksHandler())
+    except EnvException:
+      print('error 0')
+      return
+    except UnsupportedManagedTransportVersionException:
+      print('error 1')
+      return
+    except NoSupportedTransportsException:
+      print('error 2')
+      return
+
+    try:
+      self.launchClient(self.supportedTransport, 8182)
+      self.config.writeMethod(self.supportedTransport, 5, ('127.0.0.1', 8182), None, None)
+    except TransportLaunchException as e:
+      print('error 3')
+      self.config.writeMethodError(self.supportedTransport, e.message)
+
+    self.config.writeMethodEnd()
+    
+    self.run()
+      
+  def launchClient(self, name, port):
+    if name!=self.supportedTransport:
+      raise TransportLaunchException('Tried to launch unsupported transport %s' % (name))
+
+    client=DummyClient()
+    self.handler.setTransport(client)
+    add_service(Service(self.handler, port=port))    
+
+if __name__=='__main__':
+  sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+  server=ManagedClient()
+  
\ No newline at end of file
diff --git a/src/pyptlib/framework/managed/server.py b/src/pyptlib/framework/managed/server.py
new file mode 100755
index 0000000..08b2e09
--- /dev/null
+++ b/src/pyptlib/framework/managed/server.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python -u
+
+import os
+import sys
+
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+monocle.init('tornado')
+
+from monocle.stack import eventloop
+from monocle.stack.network import add_service, Service, Client
+
+from pyptlib.framework.shared import pump
+
+from pyptlib.config.config import EnvException
+from pyptlib.config.server import ServerConfig, MethodOptions
+from pyptlib.framework.daemon import *
+
+from pyptlib.framework.proxy import ProxyHandler
+
+from pyptlib.transports.dummy import DummyServer
+
+class ManagedServer(Daemon):
+  def __init__(self):
+    try:
+      Daemon.__init__(self, ServerConfig(), ProxyHandler())
+    except EnvException:
+      print('error 0')
+      return
+    except UnsupportedManagedTransportVersionException:
+      print('error 1')
+      return
+    except NoSupportedTransportsException:
+      print('error 2')
+      return
+
+    try:
+      self.launchServer(self.supportedTransport, 8182)
+      self.config.writeMethod(self.supportedTransport, ('127.0.0.1', 8182), MethodOptions())
+    except TransportLaunchException as e:
+      print('error 3')
+      self.config.writeMethodError(self.supportedTransport, e.message)
+
+    self.config.writeMethodEnd()
+    
+    self.run()
+    
+  def launchServer(self, name, port):
+    if name!=self.supportedTransport:
+      raise TransportLaunchException('Tried to launch unsupported transport %s' % (name))
+
+    client=DummyServer()
+    self.handler.setTransport(client)
+    add_service(Service(self.handler, port=port))   
+
+if __name__=='__main__':
+  sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+  server=ManagedServer()
+  
\ No newline at end of file
diff --git a/src/pyptlib/framework/proxy.py b/src/pyptlib/framework/proxy.py
new file mode 100644
index 0000000..68d9a16
--- /dev/null
+++ b/src/pyptlib/framework/proxy.py
@@ -0,0 +1,27 @@
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+
+from pyptlib.util import encode
+
+from pyptlib.framework.shared import pump
+
+class ProxyHandler:
+  transport=None
+
+  def setTransport(self, transport):
+    self.transport=transport
+
+  @_o
+  def handle(self, conn):
+    print('connection')
+    client = Client()
+    yield client.connect('blanu.net', 7051)
+
+    coder=yield handshake(client)
+
+    monocle.launch(pump, conn, client, coder.encrypt)
+    yield pump(client, conn, coder.decrypt)
+
diff --git a/src/pyptlib/framework/shared.py b/src/pyptlib/framework/shared.py
new file mode 100644
index 0000000..274b825
--- /dev/null
+++ b/src/pyptlib/framework/shared.py
@@ -0,0 +1,47 @@
+import monocle
+from monocle import _o, Return
+
+from monocle.stack.network import ConnectionLost
+
+from pyptlib.util import encode
+
+ at _o
+def pump(input, output, transform, debug=False):
+  while True:
+    try:
+      message = yield input.read_some()
+#      message=yield input.read(1)
+      if not message or len(message)==0:
+        print('0 from '+str(input)+' '+str(type(message)))
+        raise(Exception())
+#        message=yield input.read(1)
+      if debug:
+        print('receive '+str(len(message)))
+    except ConnectionLost:
+      print('Client connection closed')
+      output.close()
+      break
+    except IOError:
+      output.close()
+      break
+
+    if transform:
+      message=yield transform(message)
+
+    if debug:
+      print('sending '+str(len(message)))
+    try:
+      yield output.write(message)
+    except ConnectionLost:
+      print('Connection lost')
+      input.close()
+      return
+    except IOError:
+      print('IOError')
+      input.close()
+      return
+    except Exception, e:
+      print('Exception')
+      print(e)
+      input.close()
+      return
diff --git a/src/pyptlib/framework/socks.py b/src/pyptlib/framework/socks.py
new file mode 100644
index 0000000..c5659f0
--- /dev/null
+++ b/src/pyptlib/framework/socks.py
@@ -0,0 +1,71 @@
+from struct import unpack
+from socket import inet_ntoa
+
+import monocle
+from monocle import _o, Return
+
+from pyptlib.util import encode
+
+from pyptlib.framework.shared import pump
+
+def uncompact(x):
+    ip, port = unpack("!4sH", x)
+    return inet_ntoa(ip), port
+
+ at _o
+def readHandshake(input):
+  version=yield input.read(1)
+  print('version: '+encode(str(version)))
+  nauth=yield input.read(1)
+  nauth=unpack('B', nauth)[0]
+  auths=[]
+  for x in range(nauth):
+    auth=yield input.read(1)
+    auth=unpack('B', auth)[0]
+    auths.append(auth)
+
+ at _o
+def sendHandshake(output):
+  yield output.write(b"\x05\x00")
+
+ at _o
+def readRequest(input):
+  version=yield input.read(1)
+  command=yield input.read(1)
+  reserved=yield input.read(1)
+  addrtype=yield input.read(1)
+  dest=yield input.read(6)
+
+  yield Return(dest)
+
+ at _o
+def sendResponse(dest, output):
+  yield output.write(b"\x05\x00\x00\x01"+dest)
+
+class SocksHandler:
+  transport=None
+
+  def setTransport(self, transport):
+    self.transport=transport
+
+  @_o
+  def handle(self, conn):
+    print('handle_socks')
+    yield readHandshake(conn)
+    print('read handshake')
+    yield sendHandshake(conn)
+    print('send handshake')
+    dest=yield readRequest(conn)
+    print('read request: '+str(dest))
+    yield sendResponse(dest, conn)
+    print('sent response')
+
+    addr, port=uncompact(dest)
+    print(addr)
+    print(port)
+
+    client = Client()
+    yield client.connect(addr, port)
+    print('connected '+str(addr)+', '+str(port))
+    monocle.launch(pump, conn, client, None)
+    yield pump(client, conn, None)
diff --git a/src/pyptlib/manager/__init__.py b/src/pyptlib/manager/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/manager/__init__.pyc b/src/pyptlib/manager/__init__.pyc
new file mode 100644
index 0000000..e3507ba
Binary files /dev/null and b/src/pyptlib/manager/__init__.pyc differ
diff --git a/src/pyptlib/manager/clientManager.py b/src/pyptlib/manager/clientManager.py
new file mode 100644
index 0000000..8ce6a0c
--- /dev/null
+++ b/src/pyptlib/manager/clientManager.py
@@ -0,0 +1,14 @@
+import os
+
+from pyptlib.manager.manager import Manager
+
+class ClientManager(Manager):
+  def __init__(self):
+    Manager.__init__(self)
+  
+    os.environ['TOR_PT_CLIENT_TRANSPORTS']='dummy'
+    
+if __name__=='__main__':
+  manager=ClientManager()
+  manager.launch('src/pyptlib/framework/client.py')
+  
\ No newline at end of file
diff --git a/src/pyptlib/manager/manager.py b/src/pyptlib/manager/manager.py
new file mode 100644
index 0000000..b5f0ee9
--- /dev/null
+++ b/src/pyptlib/manager/manager.py
@@ -0,0 +1,17 @@
+import os
+import sys
+import subprocess
+
+class Manager:
+  def __init__(self):
+    os.environ['TOR_PT_STATE_LOCATION']='/'
+    os.environ['TOR_PT_MANAGED_TRANSPORT_VER']='1'
+
+  def launch(self, path):
+    p=subprocess.Popen(['python', '-u', path], stdout=subprocess.PIPE)
+    line=p.stdout.readline().strip()
+    while line!=None and line !='':
+      print(str(line))
+      sys.stdout.flush()
+      line=p.stdout.readline().strip()
+    print('Done!')
diff --git a/src/pyptlib/manager/manager.pyc b/src/pyptlib/manager/manager.pyc
new file mode 100644
index 0000000..f171236
Binary files /dev/null and b/src/pyptlib/manager/manager.pyc differ
diff --git a/src/pyptlib/manager/serverManager.py b/src/pyptlib/manager/serverManager.py
new file mode 100644
index 0000000..a287ea7
--- /dev/null
+++ b/src/pyptlib/manager/serverManager.py
@@ -0,0 +1,16 @@
+import os
+
+from pyptlib.manager.manager import Manager
+
+class ServerManager(Manager):
+  def __init__(self):
+    Manager.__init__(self)
+  
+    os.environ['TOR_PT_EXTENDED_SERVER_PORT']='127.0.0.1:22211'
+    os.environ['TOR_PT_ORPORT']='127.0.0.1:43210'
+    os.environ['TOR_PT_SERVER_BINDADDR']='dummy-127.0.0.1:46466'
+    os.environ['TOR_PT_SERVER_TRANSPORTS']='dummy'
+    
+if __name__=='__main__':
+  manager=ServerManager()
+  manager.launch('src/pyptlib/framework/server.py')
diff --git a/src/pyptlib/transports/__init__.py b/src/pyptlib/transports/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/transports/__init__.pyc b/src/pyptlib/transports/__init__.pyc
new file mode 100644
index 0000000..3ffbf76
Binary files /dev/null and b/src/pyptlib/transports/__init__.pyc differ
diff --git a/src/pyptlib/transports/dummy.py b/src/pyptlib/transports/dummy.py
new file mode 100644
index 0000000..06473f5
--- /dev/null
+++ b/src/pyptlib/transports/dummy.py
@@ -0,0 +1,14 @@
+class DummyClient:
+  def encode(self, data):
+    return data
+
+  def decode(self, data):
+    return data
+
+class DummyServer:
+  def encode(self, data):
+    return data
+
+  def decode(self, data):
+    return data
+
diff --git a/src/pyptlib/transports/dummy.pyc b/src/pyptlib/transports/dummy.pyc
new file mode 100644
index 0000000..c069ca6
Binary files /dev/null and b/src/pyptlib/transports/dummy.pyc differ
diff --git a/src/pyptlib/transports/rot13.py b/src/pyptlib/transports/rot13.py
new file mode 100644
index 0000000..a050b8e
--- /dev/null
+++ b/src/pyptlib/transports/rot13.py
@@ -0,0 +1,22 @@
+def rot13(data):
+  for x in range(len(data)):
+    ascii=ord(data[x])
+    if ascii>=97 and ascii<=122:  # a-z
+      data[x]=(((ascii-97)+13)%26)+97
+    elif ascii>=65 and ascii<=90: # A-Z
+      data[x]=(((ascii-65)+13)%26)+65
+  return data
+
+class Rot13Client:
+  def encode(self, data):
+    return rot13(data)
+
+  def decode(self, data):
+    return rot13(data)
+
+class Rot13Server:
+  def encode(self, data):
+    return rot13(data)
+
+  def decode(self, data):
+    return rot13(data)
\ No newline at end of file
diff --git a/src/pyptlib/util.py b/src/pyptlib/util.py
new file mode 100644
index 0000000..e307e5c
--- /dev/null
+++ b/src/pyptlib/util.py
@@ -0,0 +1,135 @@
+import re
+import sys
+import binascii
+
+from struct import pack, unpack
+from socket import inet_aton, inet_ntoa
+
+v3=(sys.version[0]=='3')
+
+def uncompact(x):
+    ip, port = unpack("!4sH", x)
+    return inet_ntoa(ip), port
+
+def encode(s):
+  return binascii.hexlify(s).decode('ascii')
+
+def decode(s):
+  return binascii.unhexlify(s.encode('ascii'))
+
+def encodeAddress(addr):
+  ip=addr[0]
+  if ip=='':
+    ip='::'
+  port=addr[1]
+  if '.' in ip:
+    return ip+':'+str(port)
+  else:
+    return '['+ip+']:'+str(port)
+
+def decodeAddress(s):
+  if '.' in s:
+    parts=s.split(':')
+    return (parts[0], int(parts[1]), False)
+  else:
+    m=re.match('\[([0-9a-f:]+)\]:([0-9]+)', s)
+    return (m.group(1), int(m.group(2)), True)
+
+def getAddress(port):
+  return encodeAddress((getPublicIP(), port))
+
+def splitFields(msg, fields, optionalData=False):
+  values=[]
+  for field in fields:
+    value=msg[:field]
+    msg=msg[field:]
+    values.append(value)
+  if len(msg)>0:
+    values.append(msg)
+  elif optionalData:
+    values.append(None)
+  return values
+
+def splitField(msg, field):
+  return msg[:field], msg[field:]
+
+def decodeFlags(flagsByte):
+  from bitstring import BitString
+  bits=BitString(bytes=flagsByte)
+  bools=[]
+  for x in range(bits.length):
+    bools.append(bits.readbit().uint==1)
+  return bools
+
+def encodeFlags(bools):
+  from bitstring import BitString
+  bits=BitString()
+  for bool in bools:
+    if bool:
+      bits.append(BitString('0b1'))
+    else:
+      bits.append(BitString('0b0'))
+  return bits.bytes
+
+def fill(bs, size):
+  while len(bs)<size:
+    if v3:
+      filler=bytes('\x00', 'ascii')
+    else:
+      filler='\x00'
+    bs=bs+filler
+  return bs
+
+def xor(a, b):
+  if len(a)!=len(b):
+    print('xor parameters must be the same length:', len(a), len(b))
+    return None
+  if v3:
+    c=bytearray()
+    for x in range(len(a)):
+      c.append(a[x] ^ b[x])
+    return bytes(c)
+  else:
+    c=''
+    for x in range(len(a)):
+      c=c+chr(ord(a[x]) ^ ord(b[x]))
+    return c
+
+if v3:
+  from urllib.request import urlopen
+else:
+  from urllib2 import urlopen
+
+def getPublicIP(v6=True):
+  if v6:
+#    try:
+      text=urlopen("http://ipv6.ip6.me/").read()
+      if v3:
+        match=re.search(bytes("\+3>([^<]+)<", 'ascii'), text)
+      else:
+        match=re.search("\+3>([^<]+)<", text)
+      ip=match.group(1)
+      ip=ip.decode('ascii')
+      return ip
+#    except Exception as e:
+#      print(e)
+#      ip=urlopen("http://whatismyv6ip.com/myip").read()
+#      return ip.decode('ascii')
+  else:
+    text=urlopen("http://ip4.me/").read()
+    if v3:
+      match=re.search(bytes("\+3>([^<]+)<", 'ascii'), text)
+    else:
+      match=re.search("\+3>([^<]+)<", text)
+#     ip=urlopen("http://whatismyv6ip.com/myip").read()
+#     return ip.decode('ascii')
+    ip=match.group(1)
+    ip=ip.decode('ascii')
+    return ip
+
+def randomPort():
+  import random
+  minPort=5000
+  maxPort=10000
+  port=random.randint(minPort, maxPort)
+  return port
diff --git a/src/pyptlib/util.pyc b/src/pyptlib/util.pyc
new file mode 100644
index 0000000..9784d60
Binary files /dev/null and b/src/pyptlib/util.pyc differ

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