Automatically select IPv6 address for IPv6-only interfaces

This commit is contained in:
Mark Qvist 2024-11-20 19:16:15 +01:00
parent 1282061701
commit 212af2f43b
1 changed files with 1 additions and 1 deletions

View File

@ -422,7 +422,7 @@ class TCPServerInterface(Interface):
if len(ifaddr) < 1: if len(ifaddr) < 1:
raise SystemError(f"No addresses available on specified kernel interface \"{name}\" for TCPServerInterface to bind to") raise SystemError(f"No addresses available on specified kernel interface \"{name}\" for TCPServerInterface to bind to")
if prefer_ipv6 and netinfo.AF_INET6 in ifaddr: if (prefer_ipv6 or not netinfo.AF_INET in ifaddr) and netinfo.AF_INET6 in ifaddr:
bind_ip = ifaddr[netinfo.AF_INET6][0]["addr"] bind_ip = ifaddr[netinfo.AF_INET6][0]["addr"]
if bind_ip.lower().startswith("fe80::"): if bind_ip.lower().startswith("fe80::"):
# We'll need to add the interface as scope for link-local addresses # We'll need to add the interface as scope for link-local addresses