This commit is contained in:
@Ga_ryo_ 2017-11-29 17:16:39 +09:00 committed by Maximilian Hils
parent 5067438ec1
commit d181b4643f

View File

@ -1,6 +1,7 @@
import subprocess import subprocess
from . import pf from . import pf
import re
""" """
Doing this the "right" way by using DIOCNATLOOK on the pf device turns out 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") STATECMD = ("sudo", "-n", "/sbin/pfctl", "-s", "state")
ipv4_mapped = re.compile("^::ffff:\d+.\d+.\d+.\d+$")
def original_addr(csock): def original_addr(csock):
@ -33,4 +35,6 @@ def original_addr(csock):
raise RuntimeError( raise RuntimeError(
"Insufficient privileges to access pfctl. " "Insufficient privileges to access pfctl. "
"See http://docs.mitmproxy.org/en/latest/transparent/osx.html for details.") "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) return pf.lookup(peer[0], peer[1], stxt)