Browse Source

support --version

master
clowwindy 10 years ago
parent
commit
dfd81af844
  1. 2
      .jenkins.sh
  2. 2
      shadowsocks/local.py
  3. 2
      shadowsocks/server.py
  4. 2
      shadowsocks/tcprelay.py
  5. 16
      shadowsocks/utils.py
  6. 3
      tests/test_command.sh

2
.jenkins.sh

@ -27,7 +27,7 @@ function run_test {
python --version
coverage erase
mkdir tmp
run_test pep8 .
run_test pep8 --ignore=E402 .
run_test pyflakes .
run_test coverage run tests/nose_plugin.py -v
run_test python setup.py sdist

2
shadowsocks/local.py

@ -40,8 +40,6 @@ def main():
daemon.daemon_exec(config)
utils.print_shadowsocks()
try:
logging.info("starting local at %s:%d" %
(config['local_address'], config['local_port']))

2
shadowsocks/server.py

@ -34,8 +34,6 @@ def main():
daemon.daemon_exec(config)
utils.print_shadowsocks()
if config['port_password']:
if config['password']:
logging.warn('warning: port_password should not be used with '

2
shadowsocks/tcprelay.py

@ -328,7 +328,7 @@ class TCPRelayHandler(object):
addrs = socket.getaddrinfo(ip, port, 0, socket.SOCK_STREAM,
socket.SOL_TCP)
if len(addrs) == 0:
raise Exception("getaddrinfo failed for %s:%d" % (ip, port))
raise Exception("getaddrinfo failed for %s:%d" % (ip, port))
af, socktype, proto, canonname, sa = addrs[0]
if self._forbidden_iplist:
if common.to_str(sa[0]) in self._forbidden_iplist:

16
shadowsocks/utils.py

@ -50,7 +50,7 @@ def print_shadowsocks():
version = pkg_resources.get_distribution('shadowsocks').version
except Exception:
pass
print('shadowsocks %s' % version)
print('Shadowsocks %s' % version)
def find_config():
@ -119,11 +119,12 @@ def get_config(is_local):
format='%(levelname)-s: %(message)s')
if is_local:
shortopts = 'hd:s:b:p:k:l:m:c:t:vq'
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'user=']
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'user=',
'version']
else:
shortopts = 'hd:s:p:k:m:c:t:vq'
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'workers=',
'forbidden-ip=', 'user=']
'forbidden-ip=', 'user=', 'version']
try:
config_path = find_config()
optlist, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
@ -179,6 +180,9 @@ def get_config(is_local):
else:
print_server_help()
sys.exit(0)
elif key == '--version':
print_shadowsocks()
sys.exit(0)
elif key == '-d':
config['daemon'] = to_str(value)
elif key == '--pid-file':
@ -262,7 +266,6 @@ A fast tunnel proxy that helps you bypass firewalls.
You can supply configurations via either config file or command line arguments.
Proxy options:
-h, --help show this help message and exit
-c CONFIG path to config file
-s SERVER_ADDR server address
-p SERVER_PORT server port, default: 8388
@ -274,12 +277,14 @@ Proxy options:
--fast-open use TCP_FASTOPEN, requires Linux 3.7+
General options:
-h, --help show this help message and exit
-d start/stop/restart daemon mode
--pid-file PID_FILE pid file for daemon mode
--log-file LOG_FILE log file for daemon mode
--user USER username to run as
-v, -vv verbose mode
-q, -qq quiet mode, only show warnings/errors
--version show version information
Online help: <https://github.com/shadowsocks/shadowsocks>
''')
@ -292,7 +297,6 @@ A fast tunnel proxy that helps you bypass firewalls.
You can supply configurations via either config file or command line arguments.
Proxy options:
-h, --help show this help message and exit
-c CONFIG path to config file
-s SERVER_ADDR server address, default: 0.0.0.0
-p SERVER_PORT server port, default: 8388
@ -304,12 +308,14 @@ Proxy options:
--forbidden-ip IPLIST comma seperated IP list forbidden to connect
General options:
-h, --help show this help message and exit
-d start/stop/restart daemon mode
--pid-file PID_FILE pid file for daemon mode
--log-file LOG_FILE log file for daemon mode
--user USER username to run as
-v, -vv verbose mode
-q, -qq quiet mode, only show warnings/errors
--version show version information
Online help: <https://github.com/shadowsocks/shadowsocks>
''')

3
tests/test_command.sh

@ -6,6 +6,9 @@ PYTHON="coverage run -a -p"
LOCAL="$PYTHON shadowsocks/local.py"
SERVER="$PYTHON shadowsocks/server.py"
assert "$LOCAL --version 2>&1 | grep Shadowsocks | awk -F\" \" '{print \$1}'" "Shadowsocks"
assert "$SERVER --version 2>&1 | grep Shadowsocks | awk -F\" \" '{print \$1}'" "Shadowsocks"
assert "$LOCAL 2>&1 | grep ERROR" "ERROR: config not specified"
assert "$LOCAL 2>&1 | grep usage | cut -d: -f1" "usage"

Loading…
Cancel
Save