fix command line
This commit is contained in:
parent
73f21ffbf6
commit
1c81465436
1 changed files with 19 additions and 19 deletions
|
@ -69,11 +69,28 @@ def find_config():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def check_config(config):
|
def check_config(config, is_local):
|
||||||
if config.get('daemon', None) == 'stop':
|
if config.get('daemon', None) == 'stop':
|
||||||
# no need to specify configuration for daemon stop
|
# no need to specify configuration for daemon stop
|
||||||
return
|
return
|
||||||
|
|
||||||
|
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 and type(config['server_port']) != list:
|
||||||
|
config['server_port'] = int(config['server_port'])
|
||||||
|
|
||||||
if config.get('local_address', '') in [b'0.0.0.0']:
|
if config.get('local_address', '') in [b'0.0.0.0']:
|
||||||
logging.warn('warning: local set to listen on 0.0.0.0, it\'s not safe')
|
logging.warn('warning: local set to listen on 0.0.0.0, it\'s not safe')
|
||||||
if config.get('server', '') in [b'127.0.0.1', b'localhost']:
|
if config.get('server', '') in [b'127.0.0.1', b'localhost']:
|
||||||
|
@ -214,23 +231,6 @@ def get_config(is_local):
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
config['server_port'] = config.get('server_port', 8388)
|
config['server_port'] = config.get('server_port', 8388)
|
||||||
|
|
||||||
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 and type(config['server_port']) != list:
|
|
||||||
config['server_port'] = int(config['server_port'])
|
|
||||||
|
|
||||||
logging.getLogger('').handlers = []
|
logging.getLogger('').handlers = []
|
||||||
logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE')
|
logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE')
|
||||||
if config['verbose'] >= 2:
|
if config['verbose'] >= 2:
|
||||||
|
@ -247,7 +247,7 @@ def get_config(is_local):
|
||||||
format='%(asctime)s %(levelname)-8s %(message)s',
|
format='%(asctime)s %(levelname)-8s %(message)s',
|
||||||
datefmt='%Y-%m-%d %H:%M:%S')
|
datefmt='%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
check_config(config)
|
check_config(config, is_local)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue