listen at server; show warnings
This commit is contained in:
parent
4caa96586c
commit
29c4fd7de9
8 changed files with 174 additions and 155 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
1.3.2 2013-07-04
|
||||||
|
- Server will listen at server IP specified in config
|
||||||
|
- Check config file and show some warning messages
|
||||||
|
|
||||||
1.3.1 2013-06-29
|
1.3.1 2013-06-29
|
||||||
- Fix -c arg
|
- Fix -c arg
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ shadowsocks
|
||||||
===========
|
===========
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/clowwindy/shadowsocks.png)](https://travis-ci.org/clowwindy/shadowsocks)
|
[![Build Status](https://travis-ci.org/clowwindy/shadowsocks.png)](https://travis-ci.org/clowwindy/shadowsocks)
|
||||||
Current version: 1.3.1
|
Current version: 1.3.2
|
||||||
|
|
||||||
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls
|
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
shadowsocks
|
shadowsocks
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|Build Status| Current version: 1.3.1
|
|Build Status|
|
||||||
|
|
||||||
shadowsocks is a lightweight tunnel proxy which can help you get through
|
shadowsocks is a lightweight tunnel proxy which can help you get through
|
||||||
firewalls
|
firewalls
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ with open('README.rst') as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = "shadowsocks",
|
name = "shadowsocks",
|
||||||
version = "1.3.1",
|
version = "1.3.2",
|
||||||
license = 'MIT',
|
license = 'MIT',
|
||||||
description = "a lightweight tunnel proxy",
|
description = "a lightweight tunnel proxy",
|
||||||
author = 'clowwindy',
|
author = 'clowwindy',
|
||||||
|
|
|
@ -178,6 +178,23 @@ def main():
|
||||||
logging.info('loading config from %s' % config_path)
|
logging.info('loading config from %s' % config_path)
|
||||||
with open(config_path, 'rb') as f:
|
with open(config_path, 'rb') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6')
|
||||||
|
for key, value in optlist:
|
||||||
|
if key == '-p':
|
||||||
|
config['server_port'] = int(value)
|
||||||
|
elif key == '-k':
|
||||||
|
config['password'] = value
|
||||||
|
elif key == '-l':
|
||||||
|
config['local_port'] = int(value)
|
||||||
|
elif key == '-s':
|
||||||
|
config['server'] = value
|
||||||
|
elif key == '-m':
|
||||||
|
config['method'] = value
|
||||||
|
elif key == '-b':
|
||||||
|
config['local'] = value
|
||||||
|
elif key == '-6':
|
||||||
|
IPv6 = True
|
||||||
|
|
||||||
SERVER = config['server']
|
SERVER = config['server']
|
||||||
REMOTE_PORT = config['server_port']
|
REMOTE_PORT = config['server_port']
|
||||||
PORT = config['local_port']
|
PORT = config['local_port']
|
||||||
|
@ -185,33 +202,18 @@ def main():
|
||||||
METHOD = config.get('method', None)
|
METHOD = config.get('method', None)
|
||||||
LOCAL = config.get('local', '')
|
LOCAL = config.get('local', '')
|
||||||
|
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6')
|
|
||||||
for key, value in optlist:
|
|
||||||
if key == '-p':
|
|
||||||
REMOTE_PORT = int(value)
|
|
||||||
elif key == '-k':
|
|
||||||
KEY = value
|
|
||||||
elif key == '-l':
|
|
||||||
PORT = int(value)
|
|
||||||
elif key == '-s':
|
|
||||||
SERVER = value
|
|
||||||
elif key == '-m':
|
|
||||||
METHOD = value
|
|
||||||
elif key == '-b':
|
|
||||||
LOCAL = value
|
|
||||||
elif key == '-6':
|
|
||||||
IPv6 = True
|
|
||||||
|
|
||||||
if not KEY and not config_path:
|
if not KEY and not config_path:
|
||||||
sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks')
|
sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks')
|
||||||
|
|
||||||
|
utils.check_config(config)
|
||||||
|
|
||||||
encrypt.init_table(KEY, METHOD)
|
encrypt.init_table(KEY, METHOD)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if IPv6:
|
if IPv6:
|
||||||
ThreadingTCPServer.address_family = socket.AF_INET6
|
ThreadingTCPServer.address_family = socket.AF_INET6
|
||||||
server = ThreadingTCPServer((LOCAL, PORT), Socks5Server)
|
server = ThreadingTCPServer((LOCAL, PORT), Socks5Server)
|
||||||
logging.info("starting server at %s:%d" % tuple(server.server_address[:2]))
|
logging.info("starting local at %s:%d" % tuple(server.server_address[:2]))
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
|
@ -144,7 +144,7 @@ def main():
|
||||||
IPv6 = False
|
IPv6 = False
|
||||||
|
|
||||||
config_path = utils.find_config()
|
config_path = utils.find_config()
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], 'p:k:m:c:6')
|
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
|
||||||
for key, value in optlist:
|
for key, value in optlist:
|
||||||
if key == '-c':
|
if key == '-c':
|
||||||
config_path = value
|
config_path = value
|
||||||
|
@ -153,31 +153,36 @@ def main():
|
||||||
with open(config_path, 'rb') as f:
|
with open(config_path, 'rb') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
logging.info('loading config from %s' % config_path)
|
logging.info('loading config from %s' % config_path)
|
||||||
|
|
||||||
|
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
|
||||||
|
for key, value in optlist:
|
||||||
|
if key == '-p':
|
||||||
|
config['server_port'] = int(value)
|
||||||
|
elif key == '-k':
|
||||||
|
config['password'] = value
|
||||||
|
elif key == '-s':
|
||||||
|
config['server'] = value
|
||||||
|
elif key == '-m':
|
||||||
|
config['method'] = value
|
||||||
|
elif key == '-6':
|
||||||
|
IPv6 = True
|
||||||
|
|
||||||
SERVER = config['server']
|
SERVER = config['server']
|
||||||
PORT = config['server_port']
|
PORT = config['server_port']
|
||||||
KEY = config['password']
|
KEY = config['password']
|
||||||
METHOD = config.get('method', None)
|
METHOD = config.get('method', None)
|
||||||
|
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], 'p:k:m:c:6')
|
|
||||||
for key, value in optlist:
|
|
||||||
if key == '-p':
|
|
||||||
PORT = int(value)
|
|
||||||
elif key == '-k':
|
|
||||||
KEY = value
|
|
||||||
elif key == '-m':
|
|
||||||
METHOD = value
|
|
||||||
elif key == '-6':
|
|
||||||
IPv6 = True
|
|
||||||
|
|
||||||
if not KEY and not config_path:
|
if not KEY and not config_path:
|
||||||
sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks')
|
sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks')
|
||||||
|
|
||||||
|
utils.check_config(config)
|
||||||
|
|
||||||
encrypt.init_table(KEY, METHOD)
|
encrypt.init_table(KEY, METHOD)
|
||||||
if IPv6:
|
if IPv6:
|
||||||
ThreadingTCPServer.address_family = socket.AF_INET6
|
ThreadingTCPServer.address_family = socket.AF_INET6
|
||||||
try:
|
try:
|
||||||
server = ThreadingTCPServer(('', PORT), Socks5Server)
|
server = ThreadingTCPServer((SERVER, PORT), Socks5Server)
|
||||||
logging.info("starting server at port %d ..." % PORT)
|
logging.info("starting server at %s:%d" % tuple(server.server_address[:2]))
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
def find_config():
|
def find_config():
|
||||||
|
@ -12,3 +13,10 @@ def find_config():
|
||||||
if os.path.exists(config_path):
|
if os.path.exists(config_path):
|
||||||
return config_path
|
return config_path
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def check_config(config):
|
||||||
|
if config.get('server', '') in ['127.0.0.1', 'localhost']:
|
||||||
|
logging.warn('Server is set to "%s", maybe it\'s not correct' % config['server'])
|
||||||
|
logging.warn('Notice server will listen at %s:%s' % (config['server'], config['server_port']))
|
||||||
|
if (config.get('method', '') or '').lower() == 'rc4':
|
||||||
|
logging.warn('RC4 is not safe; please use a safer cipher, like AES-256-CFB')
|
||||||
|
|
2
test.py
2
test.py
|
@ -101,7 +101,7 @@ try:
|
||||||
for fd in r:
|
for fd in r:
|
||||||
line = fd.readline()
|
line = fd.readline()
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
if line.find('starting server') >= 0:
|
if line.find('starting') >= 0:
|
||||||
ready_count += 1
|
ready_count += 1
|
||||||
|
|
||||||
if ready_count == 2 and p3 is None:
|
if ready_count == 2 and p3 is None:
|
||||||
|
|
Loading…
Reference in a new issue