From 4b52f833769ae9240c959bb70d5772ef742e66af Mon Sep 17 00:00:00 2001 From: breakwa11 Date: Tue, 16 Jun 2015 13:10:43 +0800 Subject: [PATCH] udp ipv6 --- shadowsocks/tcprelay.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 070e234..66fef68 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -352,8 +352,14 @@ class TCPRelayHandler(object): self.destroy() def _create_remote_socket(self, ip, port): + addrs = None if self._remote_udp: - addrs = socket.getaddrinfo(ip, port, 0, socket.SOCK_DGRAM, socket.SOL_UDP) + try: + addrs = socket.getaddrinfo("::", 0, 0, socket.SOCK_DGRAM, socket.SOL_UDP) + except Exception as e: + pass + if addrs is None: + addrs = socket.getaddrinfo("0.0.0.0", 0, 0, socket.SOCK_DGRAM, socket.SOL_UDP) else: addrs = socket.getaddrinfo(ip, port, 0, socket.SOCK_STREAM, socket.SOL_TCP) if len(addrs) == 0: