Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions server/http/net.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
Expand Down
16 changes: 10 additions & 6 deletions server/http/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.NetworkInterfaceInfo[]> = os.networkInterfaces()): string[] {
Expand Down