diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-12-12 22:40:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-12 22:40:47 +0100 |
commit | 1a45cf17b3b628e82e282bc3abfe14b5506e3877 (patch) | |
tree | 8f78258cc2c86c318cc4206182693bfea995ba82 | |
parent | 8e9194c2b4b8c1b82832cdab1b364f3300e2d3fd (diff) | |
parent | 0fb48bc6a72bdd6a88e0b9ddbdd64db58a57daf4 (diff) | |
download | mitmproxy-1a45cf17b3b628e82e282bc3abfe14b5506e3877.tar.gz mitmproxy-1a45cf17b3b628e82e282bc3abfe14b5506e3877.tar.bz2 mitmproxy-1a45cf17b3b628e82e282bc3abfe14b5506e3877.zip |
Merge pull request #2643 from Ga-ryo/master
Fix #2594
-rw-r--r-- | mitmproxy/platform/pf.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/platform/test_pf.py | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/mitmproxy/platform/pf.py b/mitmproxy/platform/pf.py index c0397d78..bb5eb515 100644 --- a/mitmproxy/platform/pf.py +++ b/mitmproxy/platform/pf.py @@ -1,3 +1,4 @@ +import re import sys @@ -8,6 +9,9 @@ def lookup(address, port, s): Returns an (address, port) tuple, or None. """ + # We may get an ipv4-mapped ipv6 address here, e.g. ::ffff:127.0.0.1. + # Those still appear as "127.0.0.1" in the table, so we need to strip the prefix. + address = re.sub("^::ffff:(?=\d+.\d+.\d+.\d+$)", "", address) s = s.decode() spec = "%s:%s" % (address, port) for i in s.split("\n"): diff --git a/test/mitmproxy/platform/test_pf.py b/test/mitmproxy/platform/test_pf.py index 3292d345..b048a697 100644 --- a/test/mitmproxy/platform/test_pf.py +++ b/test/mitmproxy/platform/test_pf.py @@ -15,6 +15,7 @@ class TestLookup: d = f.read() assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80) + assert pf.lookup("::ffff:192.168.1.111", 40000, d) == ("5.5.5.5", 80) with pytest.raises(Exception, match="Could not resolve original destination"): pf.lookup("192.168.1.112", 40000, d) with pytest.raises(Exception, match="Could not resolve original destination"): |