Skip to content

Commit

Permalink
fix #414
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Aug 11, 2015
1 parent 7c08101 commit a2bc6e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
13 changes: 7 additions & 6 deletions shadowsocks/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def main():
'will be ignored')
else:
config['port_password'] = {}
server_port = config['server_port']
if type(server_port) == list:
for a_server_port in server_port:
config['port_password'][a_server_port] = config['password']
else:
config['port_password'][str(server_port)] = config['password']
server_port = config.get('server_port', None)
if server_port:
if type(server_port) == list:
for a_server_port in server_port:
config['port_password'][a_server_port] = config['password']
else:
config['port_password'][str(server_port)] = config['password']

if config.get('manager_address', 0):
logging.info('entering manager mode')
Expand Down
7 changes: 4 additions & 3 deletions shadowsocks/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ def check_config(config, is_local):
sys.exit(2)

if not is_local and not config.get('password', None) \
and not config.get('port_password', None):
and not config.get('port_password', None) \
and not config.get('manager_address'):
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:
if config.get('server_port', None) and type(config['server_port']) != list:
config['server_port'] = int(config['server_port'])

if config.get('local_address', '') in [b'0.0.0.0']:
Expand Down Expand Up @@ -240,7 +241,7 @@ def get_config(is_local):
except Exception as e:
logging.error(e)
sys.exit(2)
config['server_port'] = config.get('server_port', 8388)
config['server_port'] = config.get('server_port', None)

logging.getLogger('').handlers = []
logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE')
Expand Down
8 changes: 8 additions & 0 deletions tests/server-multi-passwd-empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"server": "127.0.0.1",
"local_port": 1081,
"port_password": {
},
"timeout": 60,
"method": "aes-256-cfb"
}

0 comments on commit a2bc6e1

Please sign in to comment.