From 825747c5309e5c807779cc109e9d85fa198f2e08 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Sat, 22 Jun 2013 17:56:30 +0800 Subject: [PATCH] better error message --- shadowsocks/local.py | 4 ++++ shadowsocks/server.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/shadowsocks/local.py b/shadowsocks/local.py index 9ff4487..68edb17 100755 --- a/shadowsocks/local.py +++ b/shadowsocks/local.py @@ -163,6 +163,7 @@ def main(): pass print 'shadowsocks %s' % version + KEY = None METHOD = None LOCAL = '' IPv6 = False @@ -201,6 +202,9 @@ def main(): elif key == '-6': IPv6 = True + if not KEY and not config_path: + sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks') + encrypt.init_table(KEY, METHOD) try: diff --git a/shadowsocks/server.py b/shadowsocks/server.py index b1dcea3..f01c8d6 100755 --- a/shadowsocks/server.py +++ b/shadowsocks/server.py @@ -139,6 +139,7 @@ def main(): pass print 'shadowsocks %s' % version + KEY = None METHOD = None IPv6 = False @@ -147,10 +148,10 @@ def main(): for key, value in optlist: if key == '-c': config_path = value - with open('config.json', 'rb') as f: - config = json.load(f) if config_path: + with open('config.json', 'rb') as f: + config = json.load(f) logging.info('loading config from %s' % config_path) SERVER = config['server'] PORT = config['server_port'] @@ -167,6 +168,9 @@ def main(): METHOD = value elif key == '-6': IPv6 = True + + if not KEY and not config_path: + sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks') encrypt.init_table(KEY, METHOD) if IPv6: