Browse Source

read black_hostname_list from config

akkariiin/master
Akkariiin 8 years ago
parent
commit
a1b2513a82
  1. 10
      shadowsocks/shell.py

10
shadowsocks/shell.py

@ -26,7 +26,6 @@ import logging
from shadowsocks.common import to_bytes, to_str, IPNetwork, PortRange
from shadowsocks import encrypt
VERBOSE_LEVEL = 5
verbose = 0
@ -52,6 +51,7 @@ def print_exception(e):
import traceback
traceback.print_exc()
def __version():
version_str = ''
try:
@ -65,9 +65,11 @@ def __version():
pass
return version_str
def print_shadowsocks():
print('ShadowsocksR %s' % __version())
def log_shadowsocks_version():
logging.info('ShadowsocksR %s' % __version())
@ -84,6 +86,7 @@ def find_config():
return sub_find(user_config_path) or sub_find(config_path)
def check_config(config, is_local):
if config.get('daemon', None) == 'stop':
# no need to specify configuration for daemon stop
@ -160,7 +163,6 @@ def get_config(is_local):
if config_path is None:
config_path = find_config()
if config_path:
logging.debug('loading config from %s' % config_path)
with open(config_path, 'rb') as f:
@ -170,7 +172,6 @@ def get_config(is_local):
logging.error('found an error in config.json: %s', str(e))
sys.exit(1)
v_count = 0
for key, value in optlist:
if key == '-p':
@ -260,6 +261,7 @@ def get_config(is_local):
config['server'] = to_str(config['server'])
else:
config['server'] = to_str(config.get('server', '0.0.0.0'))
config['black_hostname_list'] = config.get('black_hostname_list', [])
try:
config['forbidden_ip'] = \
IPNetwork(config.get('forbidden_ip', '127.0.0.0/8,::1/128'))
@ -398,6 +400,7 @@ def _decode_dict(data):
rv[key] = value
return rv
class JSFormat:
def __init__(self):
self.state = 0
@ -435,6 +438,7 @@ class JSFormat:
return "\n"
return ""
def remove_comment(json):
fmt = JSFormat()
return "".join([fmt.push(c) for c in json])

Loading…
Cancel
Save