diff --git a/shadowsocks/server.py b/shadowsocks/server.py index 0ad46fb..0b1bfd8 100755 --- a/shadowsocks/server.py +++ b/shadowsocks/server.py @@ -41,7 +41,7 @@ def main(): utils.print_shadowsocks() if config['port_password']: - if config['server_port'] or config['password']: + if config['password']: logging.warn('warning: port_password should not be used with ' 'server_port and password. server_port and password ' 'will be ignored') diff --git a/shadowsocks/utils.py b/shadowsocks/utils.py index 2f2c0b7..252c564 100644 --- a/shadowsocks/utils.py +++ b/shadowsocks/utils.py @@ -154,7 +154,7 @@ def get_config(is_local): print_help(is_local) sys.exit(2) - config['password'] = config.get('password', None) + config['password'] = config.get('password', '') config['method'] = config.get('method', 'aes-256-cfb') config['port_password'] = config.get('port_password', None) config['timeout'] = int(config.get('timeout', 300)) @@ -172,11 +172,23 @@ def get_config(is_local): config['server'] = config.get('server', '0.0.0.0') config['server_port'] = config.get('server_port', 8388) - if not ('password' in config and config['password']): + if is_local and not config.get('password', None): logging.error('password not specified') print_help(is_local) sys.exit(2) + if not is_local and not config.get('password', None) \ + and not config.get('port_password', None): + logging.error('password or port_password not specified') + print_help(is_local) + sys.exit(2) + + if 'local_port' in config: + config['local_port'] = int(config['local_port']) + + if 'server_port' in config: + config['server_port'] = int(config['server_port']) + logging.getLogger('').handlers = [] logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE') if config['verbose'] >= 2: