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
@@ -1,6 +1,9 @@
|
||||
//! The DPI bypass: zapret with Flowseal's presets, or zapret2 with its strategies; and the
|
||||
//! sites it handles beside the lists it comes with.
|
||||
//! The DPI bypass: zapret with Flowseal's presets, or zapret2 with its strategies and its 16 KB
|
||||
//! cutoff probe; and the sites it handles beside the lists it comes with.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::component::button::Button;
|
||||
use gpui_kit::component::input::{Textarea, TextareaState};
|
||||
use gpui_kit::component::radio::RadioGroup;
|
||||
@@ -9,9 +12,10 @@ use gpui_kit::component::switch::Switch;
|
||||
use gpui_kit::component::*;
|
||||
use gpui_kit::*;
|
||||
use ps_client::edits;
|
||||
use ps_ipc::Request;
|
||||
use serde_json::Value;
|
||||
|
||||
use super::widgets::{card, hint, page, state_tag};
|
||||
use super::widgets::{Inactive as _, card, hint, page, state_tag};
|
||||
use crate::model::Model;
|
||||
|
||||
const ENGINES: [(&str, &str); 2] = [("zapret-discord-youtube", "Flowseal's presets (zapret)"), ("zapret2", "zapret2")];
|
||||
@@ -37,6 +41,9 @@ pub struct DpiPage {
|
||||
/// The engine and lists the text areas were last filled from: news from the service
|
||||
/// replaces what the user has not changed, never what they have.
|
||||
shown: (String, String, String),
|
||||
/// The cutoff probe's findings (`zapret-cutoff`), followed while it probes.
|
||||
cutoff: Value,
|
||||
_cutoff_poll: Option<Task<()>>,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
|
||||
@@ -63,11 +70,100 @@ impl DpiPage {
|
||||
}
|
||||
}),
|
||||
];
|
||||
let mut this = Self { model, preset, presets: Vec::new(), domains, exclude, shown: Default::default(), _subscriptions: subscriptions };
|
||||
let mut this = Self { model, preset, presets: Vec::new(), domains, exclude, shown: Default::default(), cutoff: Value::Null, _cutoff_poll: None, _subscriptions: subscriptions };
|
||||
this.sync(window, cx);
|
||||
this.follow_cutoff(false, cx);
|
||||
this
|
||||
}
|
||||
|
||||
/// The cutoff probe's findings, now and (`probe`: after starting it) every two seconds while
|
||||
/// it probes.
|
||||
fn follow_cutoff(&mut self, probe: bool, cx: &mut Context<Self>) {
|
||||
let bridge = self.model.read(cx).bridge().clone();
|
||||
let model = self.model.clone();
|
||||
self._cutoff_poll = Some(cx.spawn(async move |this, cx| {
|
||||
let mut probe = probe;
|
||||
loop {
|
||||
let r = bridge.call(Request::ZapretCutoff { probe }).await;
|
||||
let failed = probe && r.is_err();
|
||||
probe = false;
|
||||
let probing = r.as_ref().is_ok_and(|v| v["probing"] == true);
|
||||
let alive = this.update(cx, |this, cx| {
|
||||
match r {
|
||||
Ok(v) => this.cutoff = v,
|
||||
Err(e) if failed => model.update(cx, |_, cx| cx.emit(crate::model::Outcome::Failed(format!("The cutoff probe: {e:#}").into()))),
|
||||
Err(_) => {}
|
||||
}
|
||||
cx.notify();
|
||||
});
|
||||
if alive.is_err() || !probing {
|
||||
break;
|
||||
}
|
||||
cx.background_executor().timer(Duration::from_secs(2)).await;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/// zapret2's 16 KB cutoff probe: on or off, what it found, probe now.
|
||||
fn cutoff_card(&self, config: &Value, cx: &mut Context<Self>) -> Div {
|
||||
let c = &self.cutoff;
|
||||
let on = config["zapret"]["zapret2"]["cutoff"]["enable"] == true;
|
||||
let probing = c["probing"] == true;
|
||||
let probe = Button::new("cutoff-probe")
|
||||
.small()
|
||||
.icon(IconName::Gauge)
|
||||
.label(if probing { "Probing…" } else { "Probe now" })
|
||||
.inactive(probing || !on, cx)
|
||||
.on_click(cx.listener(|this, _, _, cx| this.follow_cutoff(true, cx)));
|
||||
let mut card = card("16 KB cutoff", Some(probe.into_any_element()), cx)
|
||||
.child(hint(
|
||||
"Some lines cut TLS to certain hosting networks after about 16 KB, which no strategy fixes. A probe finds them daily (and when the line's network changes) and, with z2k's strategies, a name that gets through for each, which z2k puts into a fake hello. Each probe makes thousands of short direct connections.",
|
||||
cx,
|
||||
))
|
||||
.child(self.option_switch("cutoff-on", "Probe this line", &["zapret", "zapret2", "cutoff", "enable"], config))
|
||||
.child(self.option_switch(
|
||||
"cutoff-fallback",
|
||||
"Send what no name fixes through the proxy (it sees addresses: the TUN, per-app routing)",
|
||||
&["zapret", "zapret2", "cutoff", "proxyFallback"],
|
||||
config,
|
||||
));
|
||||
if !on || c.is_null() {
|
||||
return card;
|
||||
}
|
||||
if c["installed"] != true {
|
||||
return card.child(hint("z2k-detect, the probe, is not installed (the zapret2-extras component).", cx));
|
||||
}
|
||||
if let Some(n) = c["note"].as_str().filter(|n| !n.is_empty() && (probing || !n.starts_with("probed"))) {
|
||||
card = card.child(hint(n.to_owned(), cx));
|
||||
}
|
||||
let Some(ts) = c["probed"].as_u64() else {
|
||||
return card.child(hint("Not probed yet: the first probe runs five minutes after the service starts.", cx));
|
||||
};
|
||||
let nets = c["networks"].as_array().cloned().unwrap_or_default();
|
||||
let named = nets.iter().filter(|n| n["name"].is_string()).count();
|
||||
let summary = match nets.len() {
|
||||
0 => format!("Probed {} from {}: no network is cut off on this line.", ps_client::utc(ts), c["egress"].as_str().unwrap_or("?")),
|
||||
n => format!("Probed {} from {}: {n} network(s) cut off, {named} with a name that gets through.", ps_client::utc(ts), c["egress"].as_str().unwrap_or("?")),
|
||||
};
|
||||
card = card.child(div().text_sm().child(summary));
|
||||
let fallback = if c["proxyFallback"] == true { "through the proxy" } else { "no name" };
|
||||
const SHOWN: usize = 8;
|
||||
for n in nets.iter().take(SHOWN) {
|
||||
card = card.child(
|
||||
div()
|
||||
.h_flex()
|
||||
.gap_2()
|
||||
.text_sm()
|
||||
.child(div().w(px(110.)).font_family("monospace").text_color(cx.theme().muted_foreground).child(format!("AS{}", n["asn"].as_str().unwrap_or("?"))))
|
||||
.child(n["name"].as_str().unwrap_or(fallback).to_owned()),
|
||||
);
|
||||
}
|
||||
if nets.len() > SHOWN {
|
||||
card = card.child(hint(format!("and {} more (proxy-ctl zapret cutoff).", nets.len() - SHOWN), cx));
|
||||
}
|
||||
card
|
||||
}
|
||||
|
||||
fn engine(config: &Value) -> String {
|
||||
config["zapret"]["engine"].as_str().unwrap_or("zapret-discord-youtube").to_owned()
|
||||
}
|
||||
@@ -222,6 +318,7 @@ impl Render for DpiPage {
|
||||
.child(self.option_switch("ipv6", "IPv6 too", &["zapret", "zapret2", "ipv6"], &config))
|
||||
.child(self.option_switch("strategy-log", "Log the strategy each site gets", &["zapret", "zapret2", "strategyLog"], &config)),
|
||||
);
|
||||
body = body.child(self.cutoff_card(&config, cx));
|
||||
} else {
|
||||
let model = self.model.clone();
|
||||
let filter = config["zapret"]["zapret-discord-youtube"]["gameFilter"].as_str().unwrap_or("null");
|
||||
|
||||
Reference in new issue
Block a user