from __future__ import annotations import subprocess def list_host_interfaces() -> list[str]: result = subprocess.run( ["ip", "-o", "link", "show"], capture_output=True, text=True, check=False, ) if result.returncode != 0: raise RuntimeError(f"Failed to list interfaces: {result.stderr.strip()}") interfaces: list[str] = [] seen = set() for line in result.stdout.splitlines(): parts = line.split(":", maxsplit=2) if len(parts) < 2: continue name = parts[1].strip().split("@", maxsplit=1)[0] if not name or name in seen: continue seen.add(name) interfaces.append(name) return interfaces