From 38fe2f244ae277ffe5b9618bca669da0bf659ad7 Mon Sep 17 00:00:00 2001 From: Simon Vermeersch Date: Sun, 13 Aug 2017 14:00:42 +0200 Subject: [PATCH] Fallback correctly to ipv4 when ipv6 is not supported --- mitmproxy/net/tcp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mitmproxy/net/tcp.py b/mitmproxy/net/tcp.py index 0c2f0e286..e109236e4 100644 --- a/mitmproxy/net/tcp.py +++ b/mitmproxy/net/tcp.py @@ -855,6 +855,8 @@ class TCPServer: if self.address[0] == 'localhost': raise socket.error("Binding to 'localhost' is prohibited. Please use '::1' or '127.0.0.1' directly.") + self.socket = None + try: # First try to bind an IPv6 socket, with possible IPv4 if the OS supports it. # This allows us to accept connections for ::1 and 127.0.0.1 on the same socket.