windows: autoProxy keeps to its exclusions, and its listing to its scope
proxy.autoProxy.exclude is never probed or routed: learn and probe requests for an excluded host are refused, and a site learned whole (example.com) routes no excluded name under it (intranet.example.com): the learned rule skips them. Without the secrets scope, proxy-ctl proxy auto lists the sites routed and counts: the hosts probed, those left to zapret and the sites behind each strike are browsing history, as the logs are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5a89b8d11d
commit
694e176353
5 files changed
+82
-12
No files matched your search
@@ -83,11 +83,22 @@ pub(super) fn apply(
|
||||
let at = pin_at.min(rules.len());
|
||||
rules.splice(at..at, pins);
|
||||
|
||||
// autoProxy.exclude is never routed by it: a site learned whole (example.com) must not take
|
||||
// an excluded name under it (intranet.example.com) along.
|
||||
let exclude: Vec<String> = input.cfg.proxy.auto_proxy.exclude.iter().map(|x| x.trim_start_matches('.').to_ascii_lowercase()).filter(|x| !x.is_empty()).collect();
|
||||
for e in exits {
|
||||
let (Some(tag), Some(path)) = (&e.rule_set, &e.path) else { continue };
|
||||
rule_sets.push(json!({ "type": "local", "format": "source", "tag": tag, "path": path }));
|
||||
if mode != RouteMode::AllBypass {
|
||||
rules.push(json!({ "rule_set": [tag], "outbound": e.tag }));
|
||||
rules.push(if exclude.is_empty() {
|
||||
json!({ "rule_set": [tag], "outbound": e.tag })
|
||||
} else {
|
||||
json!({
|
||||
"type": "logical", "mode": "and",
|
||||
"rules": [{ "rule_set": [tag] }, { "domain_suffix": exclude, "invert": true }],
|
||||
"outbound": e.tag,
|
||||
})
|
||||
});
|
||||
}
|
||||
dns_rules.push(json!({ "rule_set": [tag], "server": "remote" }));
|
||||
}
|
||||
|
||||
@@ -267,3 +267,25 @@ fn auto_proxy_adds_probe_listeners_and_learned_rules() {
|
||||
let sb = render_with(&state).sing_box.unwrap();
|
||||
assert!(!sb["route"]["rules"].as_array().unwrap().iter().any(|r| r["rule_set"] == json!(["autoproxy-1"]) && r.get("outbound").is_some()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn auto_proxy_never_routes_what_it_excludes() {
|
||||
let dir = scratch("autoproxy-exclude");
|
||||
let mut cfg = base();
|
||||
cfg.proxy.auto_proxy.enable = true;
|
||||
cfg.proxy.auto_proxy.max_exits = 2;
|
||||
cfg.proxy.auto_proxy.exclude = vec!["intranet.example.com".into()];
|
||||
let rules_dir = dir.join("rules");
|
||||
std::fs::create_dir_all(&rules_dir).unwrap();
|
||||
std::fs::write(rules_dir.join("rs-1.json"), r#"{"version":1,"rules":[{"domain_suffix":["example.com"]}]}"#).unwrap();
|
||||
let mut e = env(&dir);
|
||||
e.autoproxy_rules_dir = Some(rules_dir.to_string_lossy().into());
|
||||
e.windows = false;
|
||||
let r = render(&Input { cfg: &cfg, state: &State::default(), subscriptions: &BTreeMap::new(), env: &e, read_file: &no_files, tun: false }).unwrap();
|
||||
let sb = r.sing_box.unwrap();
|
||||
assert_eq!(
|
||||
sb["route"]["rules"].as_array().unwrap().last().unwrap(),
|
||||
&json!({ "type": "logical", "mode": "and", "rules": [{ "rule_set": ["autoproxy-1"] }, { "domain_suffix": ["intranet.example.com"], "invert": true }], "outbound": "nl" })
|
||||
);
|
||||
check_sing_box(&sb, &dir);
|
||||
}
|
||||
Reference in new issue
Block a user