|
@ -94,6 +94,8 @@ BUF_SIZE = 32 * 1024 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TCPRelayHandler(object): |
|
|
class TCPRelayHandler(object): |
|
|
|
|
|
support_ipv6 = None |
|
|
|
|
|
|
|
|
def __init__(self, server, fd_to_handlers, loop, local_sock, config, |
|
|
def __init__(self, server, fd_to_handlers, loop, local_sock, config, |
|
|
dns_resolver, is_local): |
|
|
dns_resolver, is_local): |
|
|
self._server = server |
|
|
self._server = server |
|
@ -351,13 +353,21 @@ class TCPRelayHandler(object): |
|
|
# TODO use logging when debug completed |
|
|
# TODO use logging when debug completed |
|
|
self.destroy() |
|
|
self.destroy() |
|
|
|
|
|
|
|
|
def _is_support_ipv6(self): |
|
|
def _has_ipv6_addr(self, addr_list): |
|
|
local = socket.gethostbyaddr(socket.gethostname()) |
|
|
for item in addr_list: |
|
|
for ip in local: |
|
|
if type(item) is list: |
|
|
if ':' in ip: |
|
|
if self._has_ipv6_addr(item): |
|
|
|
|
|
return True |
|
|
|
|
|
elif ':' in item: |
|
|
return True |
|
|
return True |
|
|
return False |
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def _is_support_ipv6(self): |
|
|
|
|
|
if TCPRelayHandler.support_ipv6 is None: |
|
|
|
|
|
local = socket.gethostbyaddr(socket.gethostname()) |
|
|
|
|
|
TCPRelayHandler.support_ipv6 = self._has_ipv6_addr(local) |
|
|
|
|
|
return TCPRelayHandler.support_ipv6 |
|
|
|
|
|
|
|
|
def _create_remote_socket(self, ip, port): |
|
|
def _create_remote_socket(self, ip, port): |
|
|
if self._remote_udp: |
|
|
if self._remote_udp: |
|
|
if self._is_support_ipv6(): |
|
|
if self._is_support_ipv6(): |
|
|