fix(vpn-status): reconcile against live TUN interface; replace PID-as-truth (spec 007)#20
Merged
Conversation
…-truth (spec 007) The status command now uses the tunnel interface existence as the authoritative 'connected' signal instead of a recorded PID, which was an openconnect-era artifact. - Add privilege-free interface_exists() + interface_ipv4() to netlink.rs - Introduce pure evaluate_status() + StatusVerdict (PID is not an input) - Rewrite run_vpn_status(): Connected/Stale/NotConnected from interface truth - Live IP read from the interface; recorded IP as fallback - PID shown as advisory '(not running)' when owner is gone - 6 unit tests (incl. PID-independence) + 2 adapter tests (loopback) - Non-Linux: graceful no-op; corrupt state: clear error, no panic Spec: specs/007-fix-vpn-status/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
akon vpn statuswas misreporting the connection state. The status command inherited the openconnect-era PID model — it checked whether a recorded PID was alive to decide "connected". In the native backend the akon process is the VPN client, so a stale/dead/mismatched PID made status report "stale" even with a live tunnel.Root cause
The state file's
pidfield was the sole liveness signal. It could be dead (a previous session crashed, the binary was upgraded, or the VPN was started by an older binary) whiletun0was very much alive.Fix
The TUN interface is now the ground truth for connection status. Changes:
interface_exists()andinterface_ipv4()tonetlink.rs(viaif_nametoindex/getifaddrs) — no root, nosudo.evaluate_status(record, interface_present, live_ip) → StatusVerdictfunction. The PID is not an input to the verdict — it is only shown as an advisory note.run_vpn_statusreconciles the persisted state-machine snapshot against the live interface. The displayed IP is read live from the interface (recorded IP as fallback).Tests
evaluate_statuscovering Connected / Stale / NotConnected and PID-independenceinterface_exists("lo")/interface_ipv4("lo")) — no root, no hangSpec:
specs/007-fix-vpn-status/