From e51a2ef5cc40835ea1f0b105c1a5a6ac21068688 Mon Sep 17 00:00:00 2001 From: Connor Burgess Date: Tue, 1 Dec 2026 15:50:10 +0700 Subject: [PATCH 1/2] net: a Kubernetes CNI interface sorts after the real ones among the receiver's LAN addresses Symptom: on a Linux machine that is also a Kubernetes node (k3s, kubeadm, kube-router), the phone step's Wi-Fi QR code and address, the Connect page's base, the `sink add` command and the CLI's `trust` line could name a pod address (10.42.0.0 on flannel.1, 10.42.0.1 on cni0...), which the phone cannot reach. With eth0 192.168.1.40, cni0 10.42.0.1 and flannel.1 10.42.0.0, lanAddresses() returned ["10.42.0.0", "10.42.0.1", "192.168.1.40"]. Cause: lanAddresses() recognises a virtual interface by the start of its name, and the list knows container runtimes and hypervisors but no Kubernetes network plugin. cni0, flannel.1, cilium_host, Calico's tunl0, vxlan.calico and wireguard.cali, weave, antrea-gw0, ovn-k8s-mp0 and kube-bridge each matched nothing, so each was unshifted like a real interface, and the last one the OS listed came first. Fix: the same regex also knows cni, flannel, cilium, tunl0, vxlan.calico, wireguard.cali, weave, antrea-gw, ovn-k8s and kube-, anchored at the start of the name and case-insensitive as before. Nothing else changes: real interfaces keep their unshift order, a self-assigned address stays last, and no address is dropped. tunl0 is the kernel's IP-in-IP device, which in practice gets an address from Calico; the pattern is tunl0, not tunl, so a tunnel someone named themselves stays real, as does a VPN (tun0, wg0). Tests cover a Flannel node with Calico, Weave and kube-router interfaces, and a node with Cilium, Antrea and OVN-Kubernetes host interfaces. Signed-off-by: Connor Burgess --- server/http/net.test.ts | 33 +++++++++++++++++++++++++++++++++ server/http/net.ts | 16 ++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) 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[] { From 3915844e3d9abf0c5594c53a165ee5ea010d79ca Mon Sep 17 00:00:00 2001 From: Connor Burgess Date: Sat, 5 Dec 2026 07:19:25 +0700 Subject: [PATCH 2/2] docs: record the fix under Unreleased Signed-off-by: Connor Burgess --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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