mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
commit
1a45cf17b3
@ -1,3 +1,4 @@
|
|||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@ -8,6 +9,9 @@ def lookup(address, port, s):
|
|||||||
|
|
||||||
Returns an (address, port) tuple, or None.
|
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()
|
s = s.decode()
|
||||||
spec = "%s:%s" % (address, port)
|
spec = "%s:%s" % (address, port)
|
||||||
for i in s.split("\n"):
|
for i in s.split("\n"):
|
||||||
|
@ -15,6 +15,7 @@ class TestLookup:
|
|||||||
d = f.read()
|
d = f.read()
|
||||||
|
|
||||||
assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
|
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"):
|
with pytest.raises(Exception, match="Could not resolve original destination"):
|
||||||
pf.lookup("192.168.1.112", 40000, d)
|
pf.lookup("192.168.1.112", 40000, d)
|
||||||
with pytest.raises(Exception, match="Could not resolve original destination"):
|
with pytest.raises(Exception, match="Could not resolve original destination"):
|
||||||
|
Loading…
Reference in New Issue
Block a user