windows: the kill switch

Upstream's killSwitch, on the Windows Filtering Platform: while the TUN or a
system-wide AmneziaWG profile is on, connections that would leave past it are
blocked at the ALE connect layers, while the tunnel runs, restarts or has
failed. Open: loopback, the private and reserved networks with
allowedSubnets, what leaves from the tunnels' own addresses, the tunnel's own
programs (the backend, its helpers, awg-tunnel; the service with
directFallbacks), NTP with allowTimeSync. Turning a tunnel off, or
proxy-ctl killswitch off / the Overview's Lift, lifts it until a tunnel is
turned on again.

The filters live in a dynamic WFP session of the service's: they go with
it, so stopping the service always gets the network back. Upstream holds
from boot; that needs persistent filters, for once these are seen to work
on real Windows (Wine has no WFP). A changed plan goes in under the other of
two sublayers before the old one goes, so nothing leaks between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 5.5 committed 2026-10-28 00:17:24 +03:00
1 parent ddc1bbe686
commit 32ff264c81
12 files changed
+557 -9

No files matched your search

+3 -2
View File
@@ -9,8 +9,9 @@ use serde::{Deserialize, Serialize};
pub struct KillSwitch {
/// Block outgoing traffic that bypasses the active global tunnel (TUN or a global
/// AmneziaWG profile), from the service's start until the tunnel is up, while it restarts
/// and after it fails. Windows Filtering Platform filters do it, so it holds even while
/// the service itself is stopped, until `proxy-ctl killswitch off`.
/// and after it fails. Windows Filtering Platform filters in the service's own session do
/// it: they go with the service. `proxy-ctl killswitch off`, or turning the tunnel off,
/// lifts it until a tunnel is turned on again.
pub enable: bool,
pub direct_fallbacks: bool,
pub allowed_subnets: Vec<String>,
@@ -119,7 +119,7 @@ pub fn validate(cfg: &Config) -> Vec<Issue> {
fn not_ported(cfg: &Config, v: &mut Issues) {
const IGNORED: &str = "is not on Windows yet: this release ignores it";
if cfg.kill_switch.enable {
v.warn("killSwitch.enable", "the kill switch is not on Windows yet: nothing blocks traffic that bypasses the tunnel");
v.warn("killSwitch.enable", "on Windows the kill switch holds while the service runs, not from boot as upstream's: stopping the service lifts it");
}
for (on, path, what) in [
(cfg.warp.enable && cfg.warp.as_amnezia_wg, "warp.asAmneziaWg", "WARP as an AmneziaWG profile"),
@@ -897,9 +897,9 @@ mod tests {
cfg.zapret.enable = true;
cfg.proxy.tun.enable = true;
let paths: Vec<String> = validate(&cfg).into_iter().filter(|i| i.severity == Severity::Warning && i.message.contains("Windows yet")).map(|i| i.path).collect();
assert!(paths.iter().any(|p| p == "killSwitch.enable"), "{paths:?}");
// The TUN beside zapret is: no warning for it any more.
assert!(!paths.iter().any(|p| p == "proxy.tun.enable"), "{paths:?}");
// Both are ported: the kill switch says how it differs, the TUN beside zapret nothing.
assert!(paths.is_empty(), "{paths:?}");
assert!(validate(&cfg).iter().any(|i| i.path == "killSwitch.enable" && i.message.contains("not from boot")));
}
#[test]