windows: helper programs go direct from the TUN only; the service's fetches too
The rule that sends the helpers' own connections direct (the sidecar, wireproxy, tg-ws-proxy, Tor, whitelist-bypass, the cutoff probe) now names the TUN's inbound and is left out without the TUN. sing-box looks a connection's program up on every inbound once a rule names one, so the service's fetches through the local listener, sent there to go through the proxy, went direct once the cutoff probe put the service's program in the list. Under the TUN the service's direct fetches now always leave directly, as fetch::Route::Direct means. README: the updater's verified and unverified parts; the cutoff probe's port count as measured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9de863c4b
commit
2dd563ed61
4 files changed
+35
-12
No files matched your search
@@ -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<String>) -> Vec<Value> {
|
||||
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 {
|
||||
|
||||
@@ -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::<Vec<_>>()
|
||||
};
|
||||
// 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"]));
|
||||
}
|
||||
Reference in new issue
Block a user