correct IPv4/IPv6 address output

This commit is contained in:
Peter Bieringer
2024-03-14 05:55:45 +01:00
parent efd562b38d
commit b16bc212f6

View File

@@ -67,6 +67,9 @@ def format_address(address: ADDRESS_TYPE) -> str:
if not isinstance(host, str):
raise NotImplementedError("Unsupported address format: %r" %
(address,))
if host.find(":") == -1:
return "%s:%d" % (host, port)
else:
return "[%s]:%d" % (host, port)