From 29304452f79571a576ce2687b1727995403605d1 Mon Sep 17 00:00:00 2001 From: faumaray Date: Wed, 28 Oct 2026 00:23:39 +0300 Subject: [PATCH] windows: the kill switch holds to AmneziaWG tunnels already up when the service starts From the security review of aa44527: a profile turned on by hand keeps its tunnel (a Windows service of its own) running across a restart of this service, but only autostart profiles were wanted on at start: such a tunnel fell out of the kill switch. Running ones count at start too. Co-Authored-By: Claude Opus 5.5 --- windows/crates/ps-service/src/service.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/windows/crates/ps-service/src/service.rs b/windows/crates/ps-service/src/service.rs index 4be5cda..d4385e9 100644 --- a/windows/crates/ps-service/src/service.rs +++ b/windows/crates/ps-service/src/service.rs @@ -260,8 +260,11 @@ impl Service { let cfg = self.cfg().clone(); let boot = !self.awg_vpn_started; self.awg_vpn_started = true; + // At start: the autostart profiles, and any tunnel already up (turned on before this + // service restarted: an update, a crash), are wanted on. if boot { - self.awg_wanted.extend(crate::awgvpn::profiles(&cfg).into_iter().filter(|v| v.autostart).map(|v| v.iface)); + let running = |iface: &str| matches!(crate::awgvpn::state(iface).as_str(), "active" | "activating"); + self.awg_wanted.extend(crate::awgvpn::profiles(&cfg).into_iter().filter(|v| v.autostart || running(&v.iface)).map(|v| v.iface)); } if !cfg!(windows) { if !crate::awgvpn::profiles(&cfg).is_empty() {