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
@@ -135,6 +135,19 @@ enum ZapretVerb {
|
||||
Preset { name: String },
|
||||
/// Which game traffic to handle: all, tcp, udp or null.
|
||||
GameFilter { filter: String },
|
||||
/// zapret2's 16 KB cutoff probe: the networks this line cuts off, and the names that get
|
||||
/// through (status), or probe the line now (probe).
|
||||
Cutoff {
|
||||
#[command(subcommand)]
|
||||
verb: Option<CutoffVerb>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum CutoffVerb {
|
||||
Status,
|
||||
/// Probe the line now: a few minutes, thousands of short direct connections.
|
||||
Probe,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@@ -668,8 +681,60 @@ async fn auto(ctl: &Ctl, verb: Option<AutoVerb>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The cutoff probe's findings, as upstream's `proxy-ctl zapret cutoff` prints them.
|
||||
fn print_cutoff(r: &Value) {
|
||||
if let Some(n) = r["note"].as_str().filter(|n| !n.is_empty()) {
|
||||
println!("Note: {n}");
|
||||
}
|
||||
let Some(ts) = r["probed"].as_u64() else {
|
||||
println!("Not probed yet.");
|
||||
return;
|
||||
};
|
||||
println!("Probed: {} from {}", ps_client::utc(ts), r["egress"].as_str().unwrap_or("?"));
|
||||
let nets = r["networks"].as_array().cloned().unwrap_or_default();
|
||||
if nets.is_empty() {
|
||||
println!("Cutoff: none on this line");
|
||||
return;
|
||||
}
|
||||
println!("Cutoff: {} network(s)", nets.len());
|
||||
let fallback = if r["proxyFallback"] == true { "no name - proxy fallback" } else { "no name" };
|
||||
for n in nets {
|
||||
println!(" AS{:<8} {}", n["asn"].as_str().unwrap_or("?"), n["name"].as_str().unwrap_or(fallback));
|
||||
}
|
||||
}
|
||||
|
||||
async fn cutoff(ctl: &Ctl, verb: Option<CutoffVerb>) -> Result<()> {
|
||||
let probe = matches!(verb, Some(CutoffVerb::Probe));
|
||||
let mut r = ctl.call(Request::ZapretCutoff { probe }).await?;
|
||||
if probe {
|
||||
if !ctl.json {
|
||||
println!("Probing this line; this takes a few minutes...");
|
||||
}
|
||||
// Until the round it asked for has begun and ended.
|
||||
let mut began = false;
|
||||
for _ in 0..1800 {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
r = ctl.call(Request::ZapretCutoff { probe: false }).await?;
|
||||
let probing = r["probing"] == true;
|
||||
began |= probing;
|
||||
if began && !probing || !began && r["note"].as_str().is_some_and(|n| !n.is_empty() && !n.starts_with("probed")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ctl.json {
|
||||
ctl.print(&r);
|
||||
} else if r["enabled"] != true {
|
||||
println!("The cutoff probe needs zapret.engine = \"zapret2\" with zapret2.cutoff.enable.");
|
||||
} else {
|
||||
print_cutoff(&r);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn zapret(ctl: &Ctl, verb: Option<ZapretVerb>) -> Result<()> {
|
||||
match verb.unwrap_or(ZapretVerb::Status) {
|
||||
ZapretVerb::Cutoff { verb } => return cutoff(ctl, verb).await,
|
||||
ZapretVerb::Status => {
|
||||
let s = ctl.call(Request::Status).await?;
|
||||
let z = &s["zapret"];
|
||||
|
||||
Reference in new issue
Block a user