diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-12-13 13:50:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 13:50:43 +0100 |
commit | 5e0e08a4d604f126923b4c8c2bd40bc25cd5b022 (patch) | |
tree | 747e57aa0f08fb87b222752c48b14f755220597b | |
parent | 79cf6d2a5d3b54a07eb8de140ab4991c9674db79 (diff) | |
parent | 488ec6f3f1b413450facdd00422a67a5838cafef (diff) | |
download | mitmproxy-5e0e08a4d604f126923b4c8c2bd40bc25cd5b022.tar.gz mitmproxy-5e0e08a4d604f126923b4c8c2bd40bc25cd5b022.tar.bz2 mitmproxy-5e0e08a4d604f126923b4c8c2bd40bc25cd5b022.zip |
Merge pull request #2670 from Kriechi/fix-2664
fix #2664
-rw-r--r-- | test/mitmproxy/net/test_tcp.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/mitmproxy/net/test_tcp.py b/test/mitmproxy/net/test_tcp.py index 3e27929d..e9084be4 100644 --- a/test/mitmproxy/net/test_tcp.py +++ b/test/mitmproxy/net/test_tcp.py @@ -1,4 +1,5 @@ from io import BytesIO +import re import queue import time import socket @@ -95,7 +96,13 @@ class TestServerBind(tservers.ServerTestBase): class handler(tcp.BaseHandler): def handle(self): - self.wfile.write(str(self.connection.getpeername()).encode()) + # 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. + peername = self.connection.getpeername() + address = re.sub("^::ffff:(?=\d+.\d+.\d+.\d+$)", "", peername[0]) + port = peername[1] + + self.wfile.write(str((address, port)).encode()) self.wfile.flush() def test_bind(self): |