aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-12-26 18:35:25 +0100
committerMaximilian Hils <git@maximilianhils.com>2017-12-26 20:01:37 +0100
commitddb8f43b87306437a8eb720072857bde1f2dcf9b (patch)
treed2f58e1679594ca8e6c67d4a0b3ea4f7ffcb9e44
parent5661b40942d0ddcac14a2eb3e8a9ff30b7eaca06 (diff)
downloadmitmproxy-ddb8f43b87306437a8eb720072857bde1f2dcf9b.tar.gz
mitmproxy-ddb8f43b87306437a8eb720072857bde1f2dcf9b.tar.bz2
mitmproxy-ddb8f43b87306437a8eb720072857bde1f2dcf9b.zip
Display "*" when listening on all interfaces
The set of people who understand "0.0.0.0" (and/or "::") is a subset of the set of people who understand "*", so we can make things easier to understand by using the less technical notation. Empirical Evidence: - https://discourse.mitmproxy.org/t/unable-to-use-mitmproxy-on-windows/735 - https://discourse.mitmproxy.org/t/how-to-view-the-proxy-servers-url/23
-rw-r--r--mitmproxy/utils/human.py2
-rw-r--r--test/mitmproxy/utils/test_human.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/mitmproxy/utils/human.py b/mitmproxy/utils/human.py
index e2e3142a..b21ac0b8 100644
--- a/mitmproxy/utils/human.py
+++ b/mitmproxy/utils/human.py
@@ -80,6 +80,8 @@ def format_address(address: tuple) -> str:
"""
try:
host = ipaddress.ip_address(address[0])
+ if host.is_unspecified:
+ return "*:{}".format(address[1])
if isinstance(host, ipaddress.IPv4Address):
return "{}:{}".format(str(host), address[1])
# If IPv6 is mapped to IPv4
diff --git a/test/mitmproxy/utils/test_human.py b/test/mitmproxy/utils/test_human.py
index e8ffaad4..947cfa4a 100644
--- a/test/mitmproxy/utils/test_human.py
+++ b/test/mitmproxy/utils/test_human.py
@@ -54,3 +54,5 @@ def test_format_address():
assert human.format_address(("::ffff:127.0.0.1", "54010", "0", "0")) == "127.0.0.1:54010"
assert human.format_address(("127.0.0.1", "54010")) == "127.0.0.1:54010"
assert human.format_address(("example.com", "54010")) == "example.com:54010"
+ assert human.format_address(("::", "8080")) == "*:8080"
+ assert human.format_address(("0.0.0.0", "8080")) == "*:8080"