rename is_tunnel to _is_tunnel
https://github.com/shadowsocks/shadowsocks/pull/759
This commit is contained in:
parent
b447c044c7
commit
408d03c556
3 changed files with 10 additions and 10 deletions
|
@ -119,7 +119,7 @@ class TCPRelayHandler(object):
|
||||||
self.tunnel_remote = config.get('tunnel_remote', "8.8.8.8")
|
self.tunnel_remote = config.get('tunnel_remote', "8.8.8.8")
|
||||||
self.tunnel_remote_port = config.get('tunnel_remote_port', 53)
|
self.tunnel_remote_port = config.get('tunnel_remote_port', 53)
|
||||||
self.tunnel_port = config.get('tunnel_port', 53)
|
self.tunnel_port = config.get('tunnel_port', 53)
|
||||||
self.is_tunnel = server.is_tunnel
|
self._is_tunnel = server._is_tunnel
|
||||||
|
|
||||||
# TCP Relay works as either sslocal or ssserver
|
# TCP Relay works as either sslocal or ssserver
|
||||||
# if is_local, this is sslocal
|
# if is_local, this is sslocal
|
||||||
|
@ -297,7 +297,7 @@ class TCPRelayHandler(object):
|
||||||
@shell.exception_handle(self_=True, destroy=True, conn_err=True)
|
@shell.exception_handle(self_=True, destroy=True, conn_err=True)
|
||||||
def _handle_stage_addr(self, data):
|
def _handle_stage_addr(self, data):
|
||||||
if self._is_local:
|
if self._is_local:
|
||||||
if self.is_tunnel:
|
if self._is_tunnel:
|
||||||
# add ss header to data
|
# add ss header to data
|
||||||
tunnel_remote = self.tunnel_remote
|
tunnel_remote = self.tunnel_remote
|
||||||
tunnel_remote_port = self.tunnel_remote_port
|
tunnel_remote_port = self.tunnel_remote_port
|
||||||
|
@ -359,7 +359,7 @@ class TCPRelayHandler(object):
|
||||||
self._stage = STAGE_DNS
|
self._stage = STAGE_DNS
|
||||||
if self._is_local:
|
if self._is_local:
|
||||||
# jump over socks5 response
|
# jump over socks5 response
|
||||||
if not self.is_tunnel:
|
if not self._is_tunnel:
|
||||||
# forward address to remote
|
# forward address to remote
|
||||||
self._write_to_sock((b'\x05\x00\x00\x01'
|
self._write_to_sock((b'\x05\x00\x00\x01'
|
||||||
b'\x00\x00\x00\x00\x10\x10'),
|
b'\x00\x00\x00\x00\x10\x10'),
|
||||||
|
@ -572,7 +572,7 @@ class TCPRelayHandler(object):
|
||||||
return
|
return
|
||||||
elif is_local and self._stage == STAGE_INIT:
|
elif is_local and self._stage == STAGE_INIT:
|
||||||
# jump over socks5 init
|
# jump over socks5 init
|
||||||
if self.is_tunnel:
|
if self._is_tunnel:
|
||||||
self._handle_stage_addr(data)
|
self._handle_stage_addr(data)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -715,7 +715,7 @@ class TCPRelay(object):
|
||||||
self._closed = False
|
self._closed = False
|
||||||
self._eventloop = None
|
self._eventloop = None
|
||||||
self._fd_to_handlers = {}
|
self._fd_to_handlers = {}
|
||||||
self.is_tunnel = False
|
self._is_tunnel = False
|
||||||
|
|
||||||
self._timeout = config['timeout']
|
self._timeout = config['timeout']
|
||||||
self._timeouts = [] # a list for all the handlers
|
self._timeouts = [] # a list for all the handlers
|
||||||
|
|
|
@ -48,13 +48,13 @@ def main():
|
||||||
(_config['local_address'], _config['local_port'],
|
(_config['local_address'], _config['local_port'],
|
||||||
_config['tunnel_remote'], _config['tunnel_remote_port']))
|
_config['tunnel_remote'], _config['tunnel_remote_port']))
|
||||||
tunnel_tcp_server = tcprelay.TCPRelay(_config, dns_resolver, True)
|
tunnel_tcp_server = tcprelay.TCPRelay(_config, dns_resolver, True)
|
||||||
tunnel_tcp_server.is_tunnel = True
|
tunnel_tcp_server._is_tunnel = True
|
||||||
tunnel_tcp_server.add_to_loop(loop)
|
tunnel_tcp_server.add_to_loop(loop)
|
||||||
logging.info("starting udp tunnel at %s:%d forward to %s:%d" %
|
logging.info("starting udp tunnel at %s:%d forward to %s:%d" %
|
||||||
(_config['local_address'], _config['local_port'],
|
(_config['local_address'], _config['local_port'],
|
||||||
_config['tunnel_remote'], _config['tunnel_remote_port']))
|
_config['tunnel_remote'], _config['tunnel_remote_port']))
|
||||||
tunnel_udp_server = udprelay.UDPRelay(_config, dns_resolver, True)
|
tunnel_udp_server = udprelay.UDPRelay(_config, dns_resolver, True)
|
||||||
tunnel_udp_server.is_tunnel = True
|
tunnel_udp_server._is_tunnel = True
|
||||||
tunnel_udp_server.add_to_loop(loop)
|
tunnel_udp_server.add_to_loop(loop)
|
||||||
|
|
||||||
def handler(signum, _):
|
def handler(signum, _):
|
||||||
|
|
|
@ -98,7 +98,7 @@ class UDPRelay(object):
|
||||||
self.tunnel_remote = config.get('tunnel_remote', "8.8.8.8")
|
self.tunnel_remote = config.get('tunnel_remote', "8.8.8.8")
|
||||||
self.tunnel_remote_port = config.get('tunnel_remote_port', 53)
|
self.tunnel_remote_port = config.get('tunnel_remote_port', 53)
|
||||||
self.tunnel_port = config.get('tunnel_port', 53)
|
self.tunnel_port = config.get('tunnel_port', 53)
|
||||||
self.is_tunnel = False
|
self._is_tunnel = False
|
||||||
self._dns_resolver = dns_resolver
|
self._dns_resolver = dns_resolver
|
||||||
self._password = common.to_bytes(config['password'])
|
self._password = common.to_bytes(config['password'])
|
||||||
self._method = config['method']
|
self._method = config['method']
|
||||||
|
@ -156,7 +156,7 @@ class UDPRelay(object):
|
||||||
if self._stat_callback:
|
if self._stat_callback:
|
||||||
self._stat_callback(self._listen_port, len(data))
|
self._stat_callback(self._listen_port, len(data))
|
||||||
if self._is_local:
|
if self._is_local:
|
||||||
if self.is_tunnel:
|
if self._is_tunnel:
|
||||||
# add ss header to data
|
# add ss header to data
|
||||||
tunnel_remote = self.tunnel_remote
|
tunnel_remote = self.tunnel_remote
|
||||||
tunnel_remote_port = self.tunnel_remote_port
|
tunnel_remote_port = self.tunnel_remote_port
|
||||||
|
@ -280,7 +280,7 @@ class UDPRelay(object):
|
||||||
if header_result is None:
|
if header_result is None:
|
||||||
return
|
return
|
||||||
addrtype, dest_addr, dest_port, header_length = header_result
|
addrtype, dest_addr, dest_port, header_length = header_result
|
||||||
if self.is_tunnel:
|
if self._is_tunnel:
|
||||||
# remove ss header
|
# remove ss header
|
||||||
response = data[header_length:]
|
response = data[header_length:]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue