From d181b4643fbf1dcafecbf7bd06e8cbe2e8d5e09d Mon Sep 17 00:00:00 2001 From: "@Ga_ryo_" Date: Wed, 29 Nov 2017 17:16:39 +0900 Subject: [PATCH] Fix #2594 --- mitmproxy/platform/osx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mitmproxy/platform/osx.py b/mitmproxy/platform/osx.py index f9de1fbf3..40a742e99 100644 --- a/mitmproxy/platform/osx.py +++ b/mitmproxy/platform/osx.py @@ -1,6 +1,7 @@ import subprocess from . import pf +import re """ Doing this the "right" way by using DIOCNATLOOK on the pf device turns out @@ -15,6 +16,7 @@ from . import pf """ STATECMD = ("sudo", "-n", "/sbin/pfctl", "-s", "state") +ipv4_mapped = re.compile("^::ffff:\d+.\d+.\d+.\d+$") def original_addr(csock): @@ -33,4 +35,6 @@ def original_addr(csock): raise RuntimeError( "Insufficient privileges to access pfctl. " "See http://docs.mitmproxy.org/en/latest/transparent/osx.html for details.") + if ipv4_mapped.match(peer[0]): + return pf.lookup(peer[0].replace("::ffff:", ""), peer[1], stxt) return pf.lookup(peer[0], peer[1], stxt)