windows: zapret2's verdicts route the proxy; options kept to what they are
As upstream's direct-sync: from zapret2's lists and the detector's verdicts, two rule-sets sing-box reloads, rebuilt every ten seconds and before it starts: what zapret2 cannot fix (every strategy failed for a site, or an address leaves connections unanswered) through the proxy (zapret2.proxyFallback), after the explicit rules and autoProxy's; what it fixes direct, so it sees it (directSync), unless learned from transfers cut short. all-bypass and all-proxy as upstream. The options file winws2 reads (one a line) refuses an option holding a control character, which would read as more options than it is; and zapret2.ports.extraTcp/extraUdp, which join its options as written, are ports or ranges within 1-65535 (validated, and filtered again). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9eed225ccc
commit
514ffb97ca
10 files changed
+305
-27
No files matched your search
@@ -289,3 +289,29 @@ fn auto_proxy_never_routes_what_it_excludes() {
|
||||
);
|
||||
check_sing_box(&sb, &dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zapret2s_rule_sets_follow_autoproxy_and_the_mode() {
|
||||
let dir = scratch("zapret2-sync");
|
||||
let (direct, proxy) = (dir.join("direct.json"), dir.join("proxy.json"));
|
||||
std::fs::write(&direct, r#"{"version":1,"rules":[{"domain_suffix":["fixed.example"]}]}"#).unwrap();
|
||||
std::fs::write(&proxy, r#"{"version":1,"rules":[{"domain_suffix":["unfixable.example"]}]}"#).unwrap();
|
||||
let cfg = base();
|
||||
let mut e = env(&dir);
|
||||
e.windows = false;
|
||||
e.zapret2_direct_rule_set = Some(direct.to_string_lossy().into());
|
||||
e.zapret2_proxy_rule_set = Some(proxy.to_string_lossy().into());
|
||||
let render_with = |state: &State| render(&Input { cfg: &cfg, state, subscriptions: &BTreeMap::new(), env: &e, read_file: &no_files, tun: false }).unwrap().sing_box.unwrap();
|
||||
let sb = render_with(&State::default());
|
||||
let rules = sb["route"]["rules"].as_array().unwrap();
|
||||
let n = rules.len();
|
||||
assert_eq!(rules[n - 2], json!({ "rule_set": ["zapret-unfixable"], "outbound": "proxy" }));
|
||||
assert_eq!(rules[n - 1], json!({ "rule_set": ["zapret-hosts"], "outbound": "direct" }));
|
||||
check_sing_box(&sb, &dir);
|
||||
// all-proxy keeps no direct lists; all-bypass sends everything direct.
|
||||
let mut state = State { route_mode: Some(RouteMode::AllProxy), ..Default::default() };
|
||||
let tags = |sb: &Value| sb["route"]["rules"].as_array().unwrap().iter().filter_map(|r| r["rule_set"][0].as_str().map(str::to_owned)).collect::<Vec<_>>();
|
||||
assert_eq!(tags(&render_with(&state)), ["zapret-unfixable"]);
|
||||
state.route_mode = Some(RouteMode::AllBypass);
|
||||
assert!(tags(&render_with(&state)).is_empty());
|
||||
}
|
||||
Reference in new issue
Block a user