From d1ce1aa993eb431a0db9048a42830c1234571c29 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 2 Dec 2015 21:19:41 +0100 Subject: [PATCH] fix #839 --- libmproxy/proxy/modes/socks_proxy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libmproxy/proxy/modes/socks_proxy.py b/libmproxy/proxy/modes/socks_proxy.py index 1eb7db5bf..264c734ab 100644 --- a/libmproxy/proxy/modes/socks_proxy.py +++ b/libmproxy/proxy/modes/socks_proxy.py @@ -1,6 +1,6 @@ from __future__ import (absolute_import, print_function, division) -from netlib import socks +from netlib import socks, tcp from netlib.exceptions import TcpException from ...exceptions import Socks5ProtocolException @@ -50,7 +50,9 @@ class Socks5Proxy(Layer, ServerConnectionMixin): except (socks.SocksError, TcpException) as e: raise Socks5ProtocolException("SOCKS5 mode failure: %s" % repr(e)) - self.server_conn.address = connect_request.addr + # https://github.com/mitmproxy/mitmproxy/issues/839 + address_bytes = (connect_request.addr.host.encode("idna"), connect_request.addr.port) + self.server_conn.address = tcp.Address(address_bytes, connect_request.addr.use_ipv6) layer = self.ctx.next_layer(self) try: