Browse Source

Use IPNetwork supporting forbidden ip feature in config utils

This commit also make "forbidden_ip" field available in config file.
If no forbidden ip specified in command line and config file,
default to "127.0.0.0/8,::1".
master
Sunny 10 years ago
parent
commit
8af359ae05
  1. 3
      shadowsocks/utils.py

3
shadowsocks/utils.py

@ -29,7 +29,7 @@ import json
import sys import sys
import getopt import getopt
import logging import logging
from shadowsocks.common import to_bytes, to_str from shadowsocks.common import to_bytes, to_str, IPNetwork
VERBOSE_LEVEL = 5 VERBOSE_LEVEL = 5
@ -186,6 +186,7 @@ def get_config(is_local):
config['verbose'] = config.get('verbose', False) config['verbose'] = config.get('verbose', False)
config['local_address'] = config.get('local_address', '127.0.0.1') config['local_address'] = config.get('local_address', '127.0.0.1')
config['local_port'] = config.get('local_port', 1080) config['local_port'] = config.get('local_port', 1080)
config['forbidden_ip'] = IPNetwork(config.get('forbidden_ip', '127.0.0.0/8,::1'))
if is_local: if is_local:
if config.get('server', None) is None: if config.get('server', None) is None:
logging.error('server addr not specified') logging.error('server addr not specified')

Loading…
Cancel
Save