From 029000ff8d29d74cc589acf39806bb833fc3e900 Mon Sep 17 00:00:00 2001 From: Falseen Date: Fri, 17 Feb 2017 16:52:43 +0800 Subject: [PATCH] update the config name for tunnel ord name: tunnel_service tunnel_dns_server tunnel_dns_server_port tunnel_dns_local_port new name: both_tunnel_local tunnel_remote tunnel_remote_port tunnel_port --- config.json.example | 8 ++++---- shadowsocks/shell.py | 20 ++++++++++---------- shadowsocks/tunnel.py | 11 +++-------- shadowsocks/udprelay.py | 16 ++++++++-------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/config.json.example b/config.json.example index 95ac0f9..832cdd6 100644 --- a/config.json.example +++ b/config.json.example @@ -7,8 +7,8 @@ "method":"aes-256-cfb", "local_address":"127.0.0.1", "fast_open":false, - "tunnel_service":false, - "tunnel_dns_server":"8.8.8.8", - "tunnel_dns_server_port":53, - "tunnel_dns_local_port":53 + "both_tunnel_local":false, + "tunnel_remote":"8.8.8.8", + "tunnel_remote_port":53, + "tunnel_port":53 } diff --git a/shadowsocks/shell.py b/shadowsocks/shell.py index 4830fb9..78cf367 100644 --- a/shadowsocks/shell.py +++ b/shadowsocks/shell.py @@ -159,11 +159,11 @@ def check_config(config, is_local): if 'server_port' in config and type(config['server_port']) != list: config['server_port'] = int(config['server_port']) - if 'tunnel_dns_server_port' in config: - config['tunnel_dns_server_port'] = \ - int(config['tunnel_dns_server_port']) - if 'tunnel_dns_local_port' in config: - config['tunnel_dns_local_port'] = int(config['tunnel_dns_local_port']) + if 'tunnel_remote_port' in config: + config['tunnel_remote_port'] = \ + int(config['tunnel_remote_port']) + if 'tunnel_port' in config: + config['tunnel_port'] = int(config['tunnel_port']) if config.get('local_address', '') in [b'0.0.0.0']: logging.warn('warning: local set to listen on 0.0.0.0, it\'s not safe') @@ -303,11 +303,11 @@ def get_config(is_local): config['one_time_auth'] = config.get('one_time_auth', False) config['prefer_ipv6'] = config.get('prefer_ipv6', False) config['server_port'] = config.get('server_port', 8388) - config['tunnel_service'] = config.get('tunnel_service', False) - config['tunnel_dns_server'] = \ - to_str(config.get('tunnel_dns_server', "8.8.8.8")) - config['tunnel_dns_server_port'] = config.get('tunnel_dns_server_port', 53) - config['tunnel_dns_local_port'] = config.get('tunnel_dns_local_port', 53) + config['both_tunnel_local'] = config.get('both_tunnel_local', False) + config['tunnel_server'] = \ + to_str(config.get('tunnel_server', "8.8.8.8")) + config['tunnel_remote_port'] = config.get('tunnel_remote_port', 53) + config['tunnel_port'] = config.get('tunnel_port', 53) logging.getLogger('').handlers = [] logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE') diff --git a/shadowsocks/tunnel.py b/shadowsocks/tunnel.py index 8c9e7a4..55a9dcf 100644 --- a/shadowsocks/tunnel.py +++ b/shadowsocks/tunnel.py @@ -28,14 +28,9 @@ from shadowsocks import shell, daemon, eventloop, udprelay, asyncdns def get_tunnel_udp_server(config, dns_resolver): - if config["tunnel_service"]: - config["local_port"] = config.copy()["tunnel_dns_local_port"] - logging.info("starting tunnel at %s:%d" % \ - (config['local_address'], config['local_port'])) - else: - logging.info("tunnel_service is False") - return - + config["local_port"] = config.copy()["tunnel_port"] + logging.info("starting tunnel at %s:%d" % \ + (config['local_address'], config['local_port'])) # tcp_server = tcprelay.TCPRelay(config, dns_resolver, True) tunnel_udp_server = udprelay.UDPRelay(config, dns_resolver, True) tunnel_udp_server.is_tunnel = True diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index a1f1eea..2d85451 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -94,10 +94,10 @@ class UDPRelay(object): self._listen_port = config['server_port'] self._remote_addr = None self._remote_port = None - self.tunnel_service = config.get('tunnel_service', False) - self.tunnel_dns_server = config.get('tunnel_dns_server', "8.8.8.8") - self.tunnel_dns_server_port = config.get('tunnel_dns_server_port', 53) - self.tunnel_dns_local_port = config.get('tunnel_dns_local_port', 53) + self.both_tunnel_local = config.get('both_tunnel_local', False) + self.tunnel_remote = config.get('tunnel_remote', "8.8.8.8") + self.tunnel_remote_port = config.get('tunnel_remote_port', 53) + self.tunnel_port = config.get('tunnel_port', 53) self.is_tunnel = False self._dns_resolver = dns_resolver self._password = common.to_bytes(config['password']) @@ -158,10 +158,10 @@ class UDPRelay(object): if self._is_local: if self.is_tunnel: # add socks5 header to data - tunnel_dns_server = self.tunnel_dns_server - tunnel_dns_server_port = self.tunnel_dns_server_port - data = common.add_header(tunnel_dns_server, \ - tunnel_dns_server_port, data) + tunnel_remote = self.tunnel_remote + tunnel_remote_port = self.tunnel_remote_port + data = common.add_header(tunnel_remote, \ + tunnel_remote_port, data) else: frag = common.ord(data[2]) if frag != 0: