windows: zapret2's 16 KB cutoff probe
Upstream's cutoff.nix and cutoff-probe.template.sh: z2k-detect (built from z2k's pinned source for Windows, in zapret2-extras) finds the networks this line cuts after ~16 KB, and with z2k's own strategies a whitelisted name per network; z2k-tcp16.lua inside winws2 reads the maps (Z2K_TCP16_*, their digest in the environment so a new map restarts winws2); what no name fixes goes to the zapret-cutoff rule-set for the proxy (cutoff.proxyFallback). Upstream keeps zapret2 off the probe with an nft cgroup rule. Here z2k-detect is patched to dial from a local port range (Z2K_TCP16_LOCAL_PORTS, 44000-47999, below Windows' dynamic range) and winws2 gets --wf-raw-filter leaving that range alone; under the TUN the probe and the service's own lookups of the line's network go direct. Rounds as upstream's timer: 5 min after start, every 10 min, probing when the line's network (ipinfo.io and ifconfig.co agreeing) changed or a day passed. Request::ZapretCutoff, proxy-ctl zapret cutoff [probe], a card on the DPI page. Verified live on a line that cuts (25 networks, a name for each), the Windows z2k-detect under Wine, winws2 --dry-run and --wf-save with the filter. gui-shot's scroll takes a count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d33f05c62c
commit
803e18db9d
19 files changed
+721
-18
No files matched your search
@@ -293,25 +293,29 @@ fn auto_proxy_never_routes_what_it_excludes() {
|
||||
#[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"));
|
||||
let (direct, proxy, cutoff) = (dir.join("direct.json"), dir.join("proxy.json"), dir.join("cutoff.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 cut = ps_core::zapret2::cutoff_rules("16509\n", "", "16509\t3.5.0.0/16\n16509\t2600:1f00::/32\n");
|
||||
std::fs::write(&cutoff, serde_json::to_vec(&cut).unwrap()).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());
|
||||
e.zapret2_cutoff_rule_set = Some(cutoff.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 - 3], json!({ "rule_set": ["zapret-unfixable"], "outbound": "proxy" }));
|
||||
assert_eq!(rules[n - 2], json!({ "rule_set": ["zapret-cutoff"], "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"]);
|
||||
assert_eq!(tags(&render_with(&state)), ["zapret-unfixable", "zapret-cutoff"]);
|
||||
state.route_mode = Some(RouteMode::AllBypass);
|
||||
assert!(tags(&render_with(&state)).is_empty());
|
||||
}
|
||||
Reference in new issue
Block a user