Browse Source

add help

1.4
clowwindy 11 years ago
parent
commit
ea663145e2
  1. 4
      CHANGES
  2. 2
      README.md
  3. 2
      setup.py
  4. 2
      shadowsocks/encrypt.py
  5. 72
      shadowsocks/local.py
  6. 64
      shadowsocks/server.py
  7. 48
      shadowsocks/utils.py

4
CHANGES

@ -1,3 +1,7 @@
1.3.5 2014-04-07
- Add help
- Change default local binding address into 127.0.0.1
1.3.4 2014-02-17 1.3.4 2014-02-17
- Fix a bug when no config file exists - Fix a bug when no config file exists
- Client now support multiple server ports and multiple server/port pairs - Client now support multiple server ports and multiple server/port pairs

2
README.md

@ -1,7 +1,7 @@
shadowsocks shadowsocks
=========== ===========
Current version: 1.3.4 [![Build Status](https://travis-ci.org/clowwindy/shadowsocks.png?branch=master)](https://travis-ci.org/clowwindy/shadowsocks) Current version: 1.3.5 [![Build Status](https://travis-ci.org/clowwindy/shadowsocks.png?branch=master)](https://travis-ci.org/clowwindy/shadowsocks)
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.

2
setup.py

@ -6,7 +6,7 @@ with open('README.rst') as f:
setup( setup(
name = "shadowsocks", name = "shadowsocks",
version = "1.3.4", version = "1.3.5",
license = 'MIT', license = 'MIT',
description = "a lightweight tunnel proxy", description = "a lightweight tunnel proxy",
author = 'clowwindy', author = 'clowwindy',

2
shadowsocks/encrypt.py

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2012 clowwindy # Copyright (c) 2014 clowwindy
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal

72
shadowsocks/local.py

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2013 clowwindy # Copyright (c) 2014 clowwindy
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -190,45 +190,49 @@ def main():
IPv6 = False IPv6 = False
config_path = utils.find_config() config_path = utils.find_config()
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6') try:
for key, value in optlist: optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6')
if key == '-c': for key, value in optlist:
config_path = value if key == '-c':
config_path = value
if config_path:
logging.info('loading config from %s' % config_path) if config_path:
with open(config_path, 'rb') as f: logging.info('loading config from %s' % config_path)
try: with open(config_path, 'rb') as f:
config = json.load(f) try:
except ValueError as e: config = json.load(f)
logging.error('found an error in config.json: %s', e.message) except ValueError as e:
sys.exit(1) logging.error('found an error in config.json: %s', e.message)
else: sys.exit(1)
config = {} else:
config = {}
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6')
for key, value in optlist: optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6')
if key == '-p': for key, value in optlist:
config['server_port'] = int(value) if key == '-p':
elif key == '-k': config['server_port'] = int(value)
config['password'] = value elif key == '-k':
elif key == '-l': config['password'] = value
config['local_port'] = int(value) elif key == '-l':
elif key == '-s': config['local_port'] = int(value)
config['server'] = value elif key == '-s':
elif key == '-m': config['server'] = value
config['method'] = value elif key == '-m':
elif key == '-b': config['method'] = value
config['local'] = value elif key == '-b':
elif key == '-6': config['local'] = value
IPv6 = True elif key == '-6':
IPv6 = True
except getopt.GetoptError:
utils.print_local_help()
sys.exit(2)
SERVER = config['server'] SERVER = config['server']
REMOTE_PORT = config['server_port'] REMOTE_PORT = config['server_port']
PORT = config['local_port'] PORT = config['local_port']
KEY = config['password'] KEY = config['password']
METHOD = config.get('method', None) METHOD = config.get('method', None)
LOCAL = config.get('local', '') LOCAL = config.get('local', '127.0.0.1')
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')

64
shadowsocks/server.py

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2013 clowwindy # Copyright (c) 2014 clowwindy
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -144,35 +144,39 @@ def main():
IPv6 = False IPv6 = False
config_path = utils.find_config() config_path = utils.find_config()
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6') try:
for key, value in optlist: optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
if key == '-c': for key, value in optlist:
config_path = value if key == '-c':
config_path = value
if config_path:
logging.info('loading config from %s' % config_path) if config_path:
with open(config_path, 'rb') as f: logging.info('loading config from %s' % config_path)
try: with open(config_path, 'rb') as f:
config = json.load(f) try:
except ValueError as e: config = json.load(f)
logging.error('found an error in config.json: %s', e.message) except ValueError as e:
sys.exit(1) logging.error('found an error in config.json: %s', e.message)
logging.info('loading config from %s' % config_path) sys.exit(1)
else: logging.info('loading config from %s' % config_path)
config = {} else:
config = {}
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
for key, value in optlist: optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
if key == '-p': for key, value in optlist:
config['server_port'] = int(value) if key == '-p':
elif key == '-k': config['server_port'] = int(value)
config['password'] = value elif key == '-k':
elif key == '-s': config['password'] = value
config['server'] = value elif key == '-s':
elif key == '-m': config['server'] = value
config['method'] = value elif key == '-m':
elif key == '-6': config['method'] = value
IPv6 = True elif key == '-6':
IPv6 = True
except getopt.GetoptError:
utils.print_server_help()
sys.exit(2)
SERVER = config['server'] SERVER = config['server']
PORT = config['server_port'] PORT = config['server_port']

48
shadowsocks/utils.py

@ -1,6 +1,26 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2014 clowwindy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import os import os
import logging import logging
@ -14,9 +34,37 @@ def find_config():
return config_path return config_path
return None return None
def check_config(config): def check_config(config):
if config.get('server', '') in ['127.0.0.1', 'localhost']: 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('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'])) logging.warn('Notice server will listen at %s:%s' % (config['server'], config['server_port']))
if (config.get('method', '') or '').lower() == 'rc4': if (config.get('method', '') or '').lower() == 'rc4':
logging.warn('RC4 is not safe; please use a safer cipher, like AES-256-CFB') logging.warn('RC4 is not safe; please use a safer cipher, like AES-256-CFB')
def print_local_help():
print '''usage: sslocal [-h] -s SERVER_ADDR -p SERVER_PORT [-b LOCAL_ADDR] -l LOCAL_PORT -k PASSWORD -m METHOD [-c config]
optional arguments:
-h, --help show this help message and exit
-s SERVER_ADDR server address
-p SERVER_PORT server port
-b LOCAL_ADDR local binding address, default is 127.0.0.1
-s LOCAL_PORT local port
-k PASSWORD password
-s METHOD encryption method, for example, aes-256-cfb
-c CONFIG path to config file
'''
def print_server_help():
print '''usage: ssserver [-h] -s SERVER_ADDR -p SERVER_PORT -k PASSWORD -m METHOD [-c config]
optional arguments:
-h, --help show this help message and exit
-s SERVER_ADDR server address
-p SERVER_PORT server port
-k PASSWORD password
-s METHOD encryption method, for example, aes-256-cfb
-c CONFIG path to config file
'''
Loading…
Cancel
Save