Browse Source

compatible with py2exe; lint code

1.4
clowwindy 12 years ago
parent
commit
f18d6cd2f8
  1. 12
      local.py
  2. 19
      packaging/py2exe/setup.py
  3. 6
      server.py

12
local.py

@ -143,7 +143,14 @@ class Socks5Server(SocketServer.StreamRequestHandler):
if __name__ == '__main__':
os.chdir(os.path.dirname(__file__) or '.')
try:
os.chdir(os.path.dirname(__file__) or '.')
except NameError:
# fix py2exe
if hasattr(sys, "frozen") and sys.frozen in \
("windows_exe", "console_exe"):
p = os.path.dirname(os.path.abspath(sys.executable))
os.chdir(p)
print 'shadowsocks v1.2.2'
with open('config.json', 'rb') as f:
@ -170,7 +177,8 @@ if __name__ == '__main__':
elif key == '-6':
IPv6 = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
encrypt.init_table(KEY, METHOD)

19
packaging/py2exe/setup.py

@ -0,0 +1,19 @@
from distutils.core import setup
# NOTICE!!
# This setup.py is written for py2exe
# Don't make a python package using this file!
try:
import py2exe
except ImportError:
pass
setup(name='shadowsocks',
version='1.2.2',
description='a lightweight tunnel proxy which can help you get through firewalls',
author='clowwindy',
author_email='clowwindy42@gmail.com',
url='https://github.com/clowwindy/shadowsocks',
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = [{"script":"local.py", "dest_base": "shadowsocks_local",}],
zipfile = None)

6
server.py

@ -105,7 +105,8 @@ class Socks5Server(SocketServer.StreamRequestHandler):
addr = self.decrypt(
self.rfile.read(ord(self.decrypt(sock.recv(1)))))
elif addrtype == 4:
addr = socket.inet_ntop(socket.AF_INET6, self.decrypt(self.rfile.read(16)))
addr = socket.inet_ntop(socket.AF_INET6,
self.decrypt(self.rfile.read(16)))
else:
# not support
logging.warn('addr_type not support')
@ -147,7 +148,8 @@ if __name__ == '__main__':
elif key == '-6':
IPv6 = True
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
encrypt.init_table(KEY, METHOD)

Loading…
Cancel
Save