diff --git a/debian/control.in b/debian/control.in index 3b99d6a..6106bad 100644 --- a/debian/control.in +++ b/debian/control.in @@ -12,7 +12,7 @@ Homepage: http://pagekite.net/wiki/Floss/PySocksipyChain/ Package: python-socksipychain Section: python Architecture: all -Depends: ${misc:Depends}, python (>= 2.7), python-six +Depends: ${misc:Depends}, python (>= 2.7) Description: Python SOCKS/HTTP/SSL chaining proxy module This Python module allows you to create TCP connections through a chain of SOCKS or HTTP proxies without any special effort. It also supports diff --git a/sockschain/__init__.py b/sockschain/__init__.py index 792aeef..6bf85d0 100755 --- a/sockschain/__init__.py +++ b/sockschain/__init__.py @@ -46,7 +46,14 @@ """ -import base64, errno, os, socket, sys, select, struct, threading, six +import base64, errno, os, socket, sys, select, struct, threading + +PY2 = ((2, 0) < sys.version_info < (3, 0)) +if PY2: + b = lambda s: s +else: + b = lambda s: s.encode('latin-1') + DEBUG = False #def DEBUG(foo): print foo @@ -576,7 +583,7 @@ def close(self): def makefile(self, mode='r', bufsize=-1): self.__makefile_refs += 1 - if six.PY2: + if PY2: return socket._fileobject(self, mode, bufsize, close=True) else: return socket.SocketIO(self, mode) @@ -669,7 +676,7 @@ def __negotiatesocks5(self, destaddr, destport, proxy): # Resolve remotely ipaddr = None req = req + (chr(0x03).encode() + - chr(len(destaddr)).encode() + six.b(destaddr)) + chr(len(destaddr)).encode() + b(destaddr)) else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))