|
@ -100,7 +100,7 @@ def get_config(is_local): |
|
|
logging.info('loading config from %s' % config_path) |
|
|
logging.info('loading config from %s' % config_path) |
|
|
with open(config_path, 'rb') as f: |
|
|
with open(config_path, 'rb') as f: |
|
|
try: |
|
|
try: |
|
|
config = json.load(f) |
|
|
config = json.load(f, object_hook=_decode_dict) |
|
|
except ValueError as e: |
|
|
except ValueError as e: |
|
|
logging.error('found an error in config.json: %s', |
|
|
logging.error('found an error in config.json: %s', |
|
|
e.message) |
|
|
e.message) |
|
@ -210,4 +210,32 @@ optional arguments: |
|
|
-v verbose mode |
|
|
-v verbose mode |
|
|
|
|
|
|
|
|
Online help: <https://github.com/clowwindy/shadowsocks> |
|
|
Online help: <https://github.com/clowwindy/shadowsocks> |
|
|
''' |
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _decode_list(data): |
|
|
|
|
|
rv = [] |
|
|
|
|
|
for item in data: |
|
|
|
|
|
if isinstance(item, unicode): |
|
|
|
|
|
item = item.encode('utf-8') |
|
|
|
|
|
elif isinstance(item, list): |
|
|
|
|
|
item = _decode_list(item) |
|
|
|
|
|
elif isinstance(item, dict): |
|
|
|
|
|
item = _decode_dict(item) |
|
|
|
|
|
rv.append(item) |
|
|
|
|
|
return rv |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _decode_dict(data): |
|
|
|
|
|
rv = {} |
|
|
|
|
|
for key, value in data.iteritems(): |
|
|
|
|
|
if isinstance(key, unicode): |
|
|
|
|
|
key = key.encode('utf-8') |
|
|
|
|
|
if isinstance(value, unicode): |
|
|
|
|
|
value = value.encode('utf-8') |
|
|
|
|
|
elif isinstance(value, list): |
|
|
|
|
|
value = _decode_list(value) |
|
|
|
|
|
elif isinstance(value, dict): |
|
|
|
|
|
value = _decode_dict(value) |
|
|
|
|
|
rv[key] = value |
|
|
|
|
|
return rv |