Skip to content

net: a Kubernetes CNI interface sorts after the real ones among the receiver's LAN addresses - #260

Open
connorburgess wants to merge 3 commits into
spacesheep-dev:mainfrom
connorburgess:net-kubernetes-cni-sorts-after
Open

connorburgess wants to merge 3 commits into
spacesheep-dev:mainfrom
connorburgess:net-kubernetes-cni-sorts-after

Conversation

@connorburgess

@connorburgess connorburgess commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Updated against v0.8.18 / main d16a2c01 on 2026-12-05. Current validation and refresh details.

What

On a Linux machine that is also a Kubernetes node, the receiver now lists its real LAN address before the node's pod interfaces. This affects 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. Before this change, any of them could name a pod address that a phone on the Wi-Fi cannot reach.

Why

lanAddresses() in server/http/net.ts decides whether an interface is virtual by the start of its name. The list (last extended in #70) covers container runtimes and hypervisors, but no Kubernetes network plugin. Every interface that matches nothing is unshifted as a real one, so whichever one the OS lists last comes first. On a k3s node with Flannel (eth0 192.168.1.40, cni0 10.42.0.1, flannel.1 10.42.0.0), lanAddresses() returned ["10.42.0.0", "10.42.0.1", "192.168.1.40"]. info.urls.lan[0] (server/app.ts) was then a pod address.

The same regex now also recognises these names, anchored at the start and case-insensitive as before:

  • cni: the CNI bridge plugin's cni0, and Podman 3's cni-podman0
  • flannel: flannel.1
  • cilium: cilium_host
  • tunl0, vxlan.calico, wireguard.cali: Calico in IP-in-IP, VXLAN or WireGuard mode
  • weave: Weave Net
  • antrea-gw: antrea-gw0
  • ovn-k8s: OVN-Kubernetes' ovn-k8s-mp0
  • kube-: kube-router's kube-bridge

Nothing else changes. Real interfaces keep their order, a self-assigned 169.254 address stays last, and no address is dropped, so a node whose only interfaces have these names still lists every address. A VPN's interface (tun0, wg0, Tailscale) still counts as real.

tunl0 is the kernel's IP-in-IP fallback device. In practice Calico's IP-in-IP mode (the default in the calico.yaml manifest) is what gives it an address, and whatever gives it one, a phone on the LAN can't reach that address. The pattern is tunl0, not tunl, so a tunnel someone named themselves is left alone. I left out kube-ipvs0: kube-proxy creates it as a dummy device that stays down, and Node's os.networkInterfaces() doesn't list interfaces that are down.

An entry is now included under Unreleased in CHANGELOG.md. Other open PRs also add release notes; those entries may need combining as the PRs land.

Original proof (before the v0.8.18 refresh)

Two new cases in server/http/net.test.ts:

  • A Flannel node that also carries Calico, Weave and kube-router interfaces.
  • A node with Cilium, Antrea and OVN-Kubernetes host interfaces.

Both fail on main's net.ts and pass with this change.

With server/http/net.ts from main (4ab6eae) and the new tests:

 FAIL  server/http/net.test.ts > lanAddresses > sorts a Kubernetes node's CNI, Flannel, Calico, Weave and kube-router interfaces after the wired one
AssertionError: expected [ '10.85.0.1', '10.32.0.1', …(6) ] to deeply equal [ '192.168.1.40', '10.42.0.1', …(6) ]
 FAIL  server/http/net.test.ts > lanAddresses > sorts Cilium's, Antrea's and OVN-Kubernetes' host interfaces after the wired one
AssertionError: expected [ '10.244.2.2', '10.10.0.1', …(2) ] to deeply equal [ '192.168.1.40', '10.0.0.5', …(2) ]

- Expected
+ Received

  [
-   "192.168.1.40",
-   "10.0.0.5",
-   "10.10.0.1",
    "10.244.2.2",
+   "10.10.0.1",
+   "10.0.0.5",
+   "192.168.1.40",
  ]

      Tests  2 failed | 7 passed (9)

With this branch:

$ npx vitest run server/http/net.test.ts
 Test Files  1 passed (1)
      Tests  9 passed (9)
$ npm run typecheck
(no output, exit 0)
$ npm run lint
Checked 973 files in 258ms. No fixes applied.
Found 135 warnings.
(none in server/http/net.ts or net.test.ts)
$ npm test
 FAIL  server/control/remote.parity.test.ts > the receiver's wiring and a page's, through one script > machines, sends, refusals, jobs, a restart, a revoked key, a disconnect and another account: row for row
TestTimeoutError: Test timed out in 15000ms.
 Test Files  1 failed | 245 passed (246)
      Tests  1 failed | 3362 passed | 2 skipped (3365)

That one failure is unrelated to this change. It is a 15 s timeout in the full parallel run on this machine, and unmodified main (4ab6eae) fails the same way:

$ npm test   # on main
 FAIL  server/control/remote.parity.test.ts > the receiver's wiring and a page's, through one script > machines, sends, refusals, jobs, a restart, a revoked key, a disconnect and another account: row for row
TestTimeoutError: Test timed out in 15000ms.
 Test Files  1 failed | 245 passed (246)
      Tests  1 failed | 3360 passed | 2 skipped (3363)

Run alone, it passes on both main and this branch:

$ npx vitest run server/control/remote.parity.test.ts
      Tests  11 passed (11)

Checklist

  • Every commit is signed off (git commit -s): the DCO is the only paperwork.
  • npm run typecheck && npm run lint && npm test pass; npm run test:e2e for a UI change. (No UI change. The one npm test timeout above happens on main too and passes alone.)
  • New source files start with // SPDX-License-Identifier: Apache-2.0. (No new files.)
  • No secret, real address, hostname or home path in code, fixtures or screenshots (screenshots come from --demo). (Addresses in the tests are private-range examples.)
  • A change to shared/* names the wire-contract change in the description. (No shared/* change.)
  • A line under Unreleased in CHANGELOG.md.

…eceiver'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 <connorburgesscodes@gmail.com>
@graphide-review

Copy link
Copy Markdown
Contributor

Open in GraphideGraphide review

TL;DR

  • People running the receiver on a Kubernetes machine will now see their real Wi-Fi address first, so the phone QR code, Connect page and setup commands point to something a phone can actually reach. Nobody else sees a change.
  • The review found no problems. It notes that no addresses are removed and that reordering them alone won't trigger a certificate re-issue.
  • Ship it: the review says safe to merge, with top confidence (5 of 5).

Merge  nothing found that needs a look first

lanAddresses() in server/http/net.ts decides whether an interface is virtual by the start of its name. Real interfaces go first, virtual ones after them, and 169.254 link-local addresses last. Kubernetes network plugins were not in the list, so on a k3s or Flannel node a pod address could come first. That address then ended up in the QR code, the Connect page, sink add and the CLI's trust line. The change adds the common CNI name prefixes to the case-insensitive regex, updates the doc comments and adds two test cases for Kubernetes nodes. Addresses are still never dropped. The TLS SAN comparison (sameSet) ignores order, so moving addresses around does not by itself cause a certificate to be re-issued.

No findings sure enough to post from reading the change.

Merge confidence 5 of 5

Where to read first
  1. server/http/net.ts:53 - the VIRTUAL_NAME regex with the new Kubernetes prefixes (cni, flannel, cilium, tunl0, vxlan.calico, wireguard.cali, weave, antrea-gw, ovn-k8s, kube-)
  2. server/http/net.ts:61 - lanAddresses(): real interfaces are unshifted, virtual ones pushed and link-local addresses kept for last; this decides the final order
  3. server/http/net.test.ts:72 - new test for a Flannel, Calico, Weave and kube-router node
  4. server/http/net.test.ts:96 - new test for Cilium, Antrea and OVN-Kubernetes host interfaces
  5. server/app.ts:553 - where lanAddresses() feeds info.urls.lan, whose first entry the phone step and the CLI use
Tests and reach

Reach: no graph yet, so this review could not trace what the change reaches.

Stages: 141 s
Stage State Seconds
diff done 0.0
reach skipped 100.4
risks skipped 0.0
ci skipped 0.0
find done 41.0
agent skipped 0.0
slop skipped 0.0
scenarios skipped 0.0
verify skipped 0.0
prove skipped 0.0
score done 0.0

Reviewed e51a2ef in 141 s · graph check: no graph yet, so this review ran without it · Full report · For agents: gr review findings spacesheep-dev/sessionpipe-gui 260

Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
@connorburgess

Copy link
Copy Markdown
Contributor Author

The Kubernetes interface ordering fix still applies to SessionPipe GUI v0.8.18. Merged current main (d16a2c01) into this branch; the refreshed head is 3915844e. The affected files have not changed upstream, and the original change is preserved.

Added the previously deferred Unreleased changelog entry.

Validation on this head, macOS / Node 22.23.2:

  • npm run typecheck, npm run lint, and npm run build passed. Lint has the same 135 warnings and one informational diagnostic as current main, with no errors.
  • npx vitest run --maxWorkers=2 server/http/net.test.ts: 9 tests passed.

GitHub CI run 47453786130 for head 3915844e passed: typecheck · lint · unit · build, all three desktop e2e shards, e2e (phone · duo), e2e (control channel), and the aggregate typecheck · lint · unit · build · e2e gate.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant