Browse Source

add ignore_bind list

dev
BreakWa11 9 years ago
parent
commit
be922ba7c2
  1. 6
      shadowsocks/shell.py
  2. 4
      shadowsocks/tcprelay.py

6
shadowsocks/shell.py

@ -261,6 +261,12 @@ def get_config(is_local):
except Exception as e:
logging.error(e)
sys.exit(2)
try:
config['ignore_bind'] = \
IPNetwork(config.get('ignore_bind', '127.0.0.0/8,::1/128'))
except Exception as e:
logging.error(e)
sys.exit(2)
config['server_port'] = config.get('server_port', 8388)
logging.getLogger('').handlers = []

4
shadowsocks/tcprelay.py

@ -140,6 +140,7 @@ class TCPRelayHandler(object):
self._redir_list = config.get('redirect', ["0.0.0.0:0"])
self._bind = config.get('out_bind', '')
self._bindv6 = config.get('out_bindv6', '')
self._ignore_bind_list = config.get('ignore_bind', [])
self._fastopen_connected = False
self._data_to_write_to_local = []
@ -528,6 +529,9 @@ class TCPRelayHandler(object):
bind_addr = self._local_sock.getsockname()[0]
bind_addr = bind_addr.replace("::ffff:", "")
if bind_addr in self._ignore_bind_list:
bind_addr = None
if bind_addr:
local_addrs = socket.getaddrinfo(bind_addr, port, 0, socket.SOCK_STREAM, socket.SOL_TCP)
if local_addrs[0][0] == af:
logging.debug("bind %s" % (bind_addr,))

Loading…
Cancel
Save