fix: update interface detection code to support additional interfaces Docker adds.
Release / release (push) Successful in 17s

This commit is contained in:
slawek committed 2026-10-23 13:43:46 +02:00
1 parent 2e0cee10ac
commit 64da0cf97f
3 files changed
+27 -3

No files matched your search

@@ -309,12 +309,22 @@ def detect_interfaces():
return external, candidates[0]
def _is_virtual(name):
"""True for an interface the kernel creates without a device behind it.
Loopback, bridges, veth pairs and tunnels live under /sys/devices/virtual,
which is where the Docker bridge is; a NIC of the virtual machine does not.
"""
link = pathlib.Path('/sys/class/net') / name
return '/devices/virtual/' in str(link.resolve())
def _addressed_interfaces():
"""Interface names holding at least one IPv4 address, excluding loopback."""
"""Names of the NICs holding at least one IPv4 address; virtual interfaces are left out."""
names = []
for line in _ip_route('-o', '-4', 'addr', 'show').splitlines():
fields = line.split()
if len(fields) >= 4 and fields[1] != 'lo' and fields[1] not in names:
if len(fields) >= 4 and fields[1] not in names and not _is_virtual(fields[1]):
names.append(fields[1])
return names