diff --git a/windows/README.md b/windows/README.md index f77e293..9e27274 100644 --- a/windows/README.md +++ b/windows/README.md @@ -64,7 +64,8 @@ DPI bypass, which runs on Windows only, shows as inactive. | Windows build: service, named pipe, its ACL, caller identification, component hashes, supervisor | under Wine (`tools/wine-e2e.sh`) | | zapret arguments | **every** preset of the release, both game filters, checked by the release's own `winws.exe --dry-run` under Wine (`tools/winws-dry-run.sh`) | | zapret2 arguments | checked by `winws2.exe --dry-run` under Wine, the cutoff probe's filter part included | -| 16 KB cutoff probe | on this test machine's line, which does cut TLS at 16 KB to some networks: the service ran z2k-detect (its Linux build, the same patched source), which found 25 networks cut off and a name for each; its connections left from the probe's ports only; the maps, the line's network and the rule-set written, shown by `proxy-ctl zapret cutoff` and the app. The Windows build runs under Wine; winws2 leaving its connections alone needs real Windows | +| 16 KB cutoff probe | on this test machine's line, which does cut TLS at 16 KB to some networks: the service ran z2k-detect (its Linux build, the same patched source), which found 25 networks cut off and a name for each; its connections left from the probe's ports only; 157 distinct local ports of the probe's range were seen in use during its run; the maps, the line's network and the rule-set written, shown by `proxy-ctl zapret cutoff` and the app. The Windows build runs under Wine (it found the same networks, from the range's ports); winws2 leaving its connections alone needs real Windows (its filter, with the exclusion, saved by `winws2 --wf-save`) | +| Updates from the app | on Linux against a local stand-in for the releases API: a newer release found (and none for a pre-release's user beyond its channel, by unit tests), its setup program fetched and matched to its SHA-256, a wrong checksum refused, the app's states (found, fetching, installing) shown. Not verified: the setup run as SYSTEM by the service, and the app started again in the user's session afterwards, which need real Windows (the first chance is the update from 0.3.0-pre.1 to the release after it) | | tg-ws-proxy | runs and listens under Wine | | SSH tunnel | end to end on Linux: an sshd of the test's own, a page through the `ssh -D` listener and through sing-box's SSH outbound, each logging in with the service's copy of the key (`an_ssh_tunnel`) | | Tor | its Windows `tor.exe` (under Wine) accepts the torrc the service writes, bridges and transports included; on Linux the service runs Tor with it and Tor starts bootstrapping (where Tor's relays are blocked, it needs bridges) | diff --git a/windows/crates/ps-core/src/render/routing.rs b/windows/crates/ps-core/src/render/routing.rs index 7b301a7..4ffc738 100644 --- a/windows/crates/ps-core/src/render/routing.rs +++ b/windows/crates/ps-core/src/render/routing.rs @@ -142,8 +142,11 @@ pub(super) fn direct_match(input: &Input) -> RouteMatch { fn always_rules(input: &Input, known: &dyn Fn(&str) -> bool, warnings: &mut Vec) -> Vec { let cfg = input.cfg; let mut rules = Vec::new(); - if !input.env.direct_processes.is_empty() { - rules.push(json!({ "process_path": input.env.direct_processes, "outbound": "direct" })); + // Only what the TUN takes: sing-box looks a connection's program up on every inbound once a + // rule names one, and what the service sends through the local listener on purpose must + // keep going through the proxy. + if input.tun && !input.env.direct_processes.is_empty() { + rules.push(json!({ "inbound": ["tun-in"], "process_path": input.env.direct_processes, "outbound": "direct" })); } if cfg.per_app_routing.enable { for prof in &cfg.per_app_routing.profiles { diff --git a/windows/crates/ps-core/tests/render.rs b/windows/crates/ps-core/tests/render.rs index d201304..3872141 100644 --- a/windows/crates/ps-core/tests/render.rs +++ b/windows/crates/ps-core/tests/render.rs @@ -319,3 +319,20 @@ fn zapret2s_rule_sets_follow_autoproxy_and_the_mode() { state.route_mode = Some(RouteMode::AllBypass); assert!(tags(&render_with(&state)).is_empty()); } + +#[test] +fn helper_programs_go_direct_only_from_the_tun() { + let dir = scratch("direct-programs"); + let mut cfg = base(); + cfg.proxy.tun.enable = true; + let e = env(&dir); + let rules = |tun: bool| { + let sb = render(&Input { cfg: &cfg, state: &State::default(), subscriptions: &BTreeMap::new(), env: &e, read_file: &no_files, tun }).unwrap().sing_box.unwrap(); + sb["route"]["rules"].as_array().unwrap().iter().filter(|r| r.get("process_path").is_some() && r["outbound"] == "direct").cloned().collect::>() + }; + // Through the local listener a helper (the service's own fetches) goes where the rules say. + assert!(rules(false).is_empty()); + let under_tun = rules(true); + assert_eq!(under_tun.len(), 1); + assert_eq!(under_tun[0]["inbound"], json!(["tun-in"])); +} diff --git a/windows/crates/ps-service/src/service.rs b/windows/crates/ps-service/src/service.rs index 210ef25..3808520 100644 --- a/windows/crates/ps-service/src/service.rs +++ b/windows/crates/ps-service/src/service.rs @@ -127,15 +127,17 @@ impl Service { { direct.push(p.to_string_lossy().into_owned()); } - // The cutoff probe measures the line: its connections, and the service's own lookup of - // the line's network, leave directly. - if crate::cutoff::enabled(cfg) { - if let Some(p) = crate::cutoff::program(paths) { - direct.push(p.to_string_lossy().into_owned()); - } - if let Ok(me) = std::env::current_exe() { - direct.push(me.to_string_lossy().into_owned()); - } + // The cutoff probe measures the line: its connections leave directly. + if crate::cutoff::enabled(cfg) + && let Some(p) = crate::cutoff::program(paths) + { + direct.push(p.to_string_lossy().into_owned()); + } + // The service's own: what it fetches directly (fetch::Route::Direct, the line's network + // for the probe, a fallback past the proxy) leaves directly; through the proxy it goes + // to the local listener, which the TUN does not take. + if let Ok(me) = std::env::current_exe() { + direct.push(me.to_string_lossy().into_owned()); } let (zd, zi) = crate::zapret::direct_sync(cfg, &paths.bin()); Env {