diff --git a/CHANGELOG.md b/CHANGELOG.md index 5299e266..333085ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to `sessionpipe-gui`. The format follows ## [Unreleased] +### Fixed + +- Kubernetes pod interfaces sort after physical LAN interfaces in receiver addresses. + ## [0.8.18] - 2026-12-04 ### Fixed diff --git a/server/http/net.test.ts b/server/http/net.test.ts index f48d4b4a..b4645d05 100644 --- a/server/http/net.test.ts +++ b/server/http/net.test.ts @@ -69,6 +69,39 @@ describe("lanAddresses", () => { "172.17.0.1", ]); }); + it("sorts a Kubernetes node's CNI, Flannel, Calico, Weave and kube-router interfaces after the wired one", () => { + // k3s with Flannel: cni0 and flannel.1 hold pod addresses, listed after eth0. + const list = lanAddresses({ + lo: [v4("127.0.0.1", true)], + eth0: [v4("192.168.1.40")], + cni0: [v4("10.42.0.1")], + "flannel.1": [v4("10.42.0.0")], + tunl0: [v4("10.244.1.1")], + "vxlan.calico": [v4("10.244.0.192")], + "wireguard.cali": [v4("10.244.0.193")], + weave: [v4("10.32.0.1")], + "kube-bridge": [v4("10.85.0.1")], + }); + expect(list).toEqual([ + "192.168.1.40", + "10.42.0.1", + "10.42.0.0", + "10.244.1.1", + "10.244.0.192", + "10.244.0.193", + "10.32.0.1", + "10.85.0.1", + ]); + }); + it("sorts Cilium's, Antrea's and OVN-Kubernetes' host interfaces after the wired one", () => { + const list = lanAddresses({ + eth0: [v4("192.168.1.40")], + cilium_host: [v4("10.0.0.5")], + "antrea-gw0": [v4("10.10.0.1")], + "ovn-k8s-mp0": [v4("10.244.2.2")], + }); + expect(list).toEqual(["192.168.1.40", "10.0.0.5", "10.10.0.1", "10.244.2.2"]); + }); it("matches a virtual name whatever its case; a localized Windows name keeps its prefix", () => { const list = lanAddresses({ WLAN: [v4("192.168.178.20")], diff --git a/server/http/net.ts b/server/http/net.ts index 64fa2c4d..396e32ca 100644 --- a/server/http/net.ts +++ b/server/http/net.ts @@ -43,15 +43,19 @@ export const isLinkLocal = (ip: string): boolean => ip.startsWith("169.254."); /** An interface a container runtime or a hypervisor made, by the start of its name: the * Docker, Podman, libvirt, LXC, LXD, Incus and Multipass bridges, Linux veth pairs, macOS * utun and bridge interfaces, VMware and VirtualBox host-side adapters on any OS, Windows' - * "vEthernet (…)" switches (WSL 2, Hyper-V). Case-insensitive: Windows names mix case, and - * a localized Windows name changes the part in parentheses, not the prefix. A VPN's - * interface (tun0, wg0, Tailscale) counts as real. */ + * "vEthernet (…)" switches (WSL 2, Hyper-V), and a Kubernetes node's pod interfaces: the + * CNI bridge (cni0), Flannel's flannel.1, Cilium's cilium_host, Calico's tunl0, + * vxlan.calico and wireguard.cali, Weave's weave, Antrea's antrea-gw0, OVN-Kubernetes' + * ovn-k8s-mp0 and kube-router's kube-bridge (tunl0 is the kernel's IP-in-IP device: + * whatever holds its address, a phone on the LAN does not reach it there). Case-insensitive: + * Windows names mix case, and a localized Windows name changes the part in parentheses, not + * the prefix. A VPN's interface (tun0, wg0, Tailscale) counts as real. */ const VIRTUAL_NAME = - /^(docker|podman|br-|veth|utun|vmnet|vmware|vboxnet|virtualbox|bridge|virbr|lxcbr|lxdbr|incusbr|mpqemubr|hyper-v)/i; + /^(docker|podman|br-|veth|utun|vmnet|vmware|vboxnet|virtualbox|bridge|virbr|lxcbr|lxdbr|incusbr|mpqemubr|hyper-v|cni|flannel|cilium|tunl0|vxlan\.calico|wireguard\.cali|weave|antrea-gw|ovn-k8s|kube-)/i; /** IPv4 addresses of this machine on its networks, most likely LAN first: real interfaces - * before virtual ones (Docker, WSL 2, Hyper-V, VirtualBox, VMware, libvirt, LXD), and a - * self-assigned address last of all. A virtual interface is never dropped: a Hyper-V + * before virtual ones (Docker, WSL 2, Hyper-V, VirtualBox, VMware, libvirt, LXD, Kubernetes), + * and a self-assigned address last of all. A virtual interface is never dropped: a Hyper-V * external switch carries the host's own LAN address on "vEthernet (External…)", so a * machine with nothing but virtual names still lists every address, in the OS's order. */ export function lanAddresses(ifaces: NodeJS.Dict = os.networkInterfaces()): string[] {