This commit is contained in:
yashksaini-coder
2025-08-24 21:17:29 +05:30
parent b38d504fc1
commit 88a1f0a390

View File

@ -71,16 +71,22 @@ def get_available_interfaces(port: int, protocol: str = "tcp") -> list[Multiaddr
if seen_v4 and "127.0.0.1" not in seen_v4: if seen_v4 and "127.0.0.1" not in seen_v4:
addrs.append(Multiaddr(f"/ip4/127.0.0.1/{protocol}/{port}")) addrs.append(Multiaddr(f"/ip4/127.0.0.1/{protocol}/{port}"))
seen_v6: set[str] = set() # TODO: IPv6 support temporarily disabled due to libp2p handshake issues
for ip in _safe_get_network_addrs(6): # IPv6 connections fail during protocol negotiation (SecurityUpgradeFailure)
seen_v6.add(ip) # Re-enable IPv6 support once the following issues are resolved:
addrs.append(Multiaddr(f"/ip6/{ip}/{protocol}/{port}")) # - libp2p security handshake over IPv6
# - multiselect protocol over IPv6
# IPv6 enumeration (optional: only include if we have at least one global or # - connection establishment over IPv6
# loopback) #
# Optionally ensure IPv6 loopback when any IPv6 present but loopback missing # seen_v6: set[str] = set()
if seen_v6 and "::1" not in seen_v6: # for ip in _safe_get_network_addrs(6):
addrs.append(Multiaddr(f"/ip6/::1/{protocol}/{port}")) # seen_v6.add(ip)
# addrs.append(Multiaddr(f"/ip6/{ip}/{protocol}/{port}"))
#
# # Always include IPv6 loopback for testing purposes when IPv6 is available
# # This ensures IPv6 functionality can be tested even without global IPv6 addresses
# if "::1" not in seen_v6:
# addrs.append(Multiaddr(f"/ip6/::1/{protocol}/{port}"))
# Fallback if nothing discovered # Fallback if nothing discovered
if not addrs: if not addrs:
@ -141,4 +147,4 @@ __all__ = [
"get_available_interfaces", "get_available_interfaces",
"get_optimal_binding_address", "get_optimal_binding_address",
"expand_wildcard_address", "expand_wildcard_address",
] ]