Skip to content

Commit

Permalink
Remove dependency on six
Browse files Browse the repository at this point in the history
  • Loading branch information
BjarniRunar committed May 11, 2020
1 parent fda0ea5 commit ccb4267
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions sockschain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit ccb4267

Please sign in to comment.