windows: zapret-discord-youtube and tg-ws-proxy
zapret: Flowseal's release run as its service.bat runs it: the preset's winws.exe line (continuations, cmd's caret escapes, %BIN%, %LISTS%, the game filter) as winws's arguments, the user's domains and addresses in the lists upstream's module puts them in (kept in the service's own run directory, the verified release untouched), TCP timestamps on, and zapret's sites in the proxy's direct list. tools/winws-dry-run.sh has the release's own winws.exe verify every preset's arguments under Wine: all 22, both game filters. tg-ws-proxy: Flowseal's headless proxy on the embeddable CPython 3.12 with hash-pinned win_amd64 wheels (tools/build-tg-ws-proxy.sh), run with upstream's flags; its relay goes direct under the TUN. Runs under Wine. proxy-ctl: zapret status|on|off|preset|game-filter, components list|install. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
817de77d28
commit
9b0d7021f9
12 files changed
+873
-1
No files matched your search
@@ -42,6 +42,34 @@ enum Cmd {
|
||||
#[command(subcommand)]
|
||||
verb: ConfigVerb,
|
||||
},
|
||||
/// DPI bypass: status, on, off, or the presets and the one to use.
|
||||
Zapret {
|
||||
#[command(subcommand)]
|
||||
verb: Option<ZapretVerb>,
|
||||
},
|
||||
/// The backend programs: what is installed, and installing them (administrator).
|
||||
Components {
|
||||
#[command(subcommand)]
|
||||
verb: Option<ComponentsVerb>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum ZapretVerb {
|
||||
Status,
|
||||
On,
|
||||
Off,
|
||||
/// Use this preset (zapret-discord-youtube), e.g. "general (ALT9)".
|
||||
Preset { name: String },
|
||||
/// Which game traffic to handle: all, tcp, udp or null.
|
||||
GameFilter { filter: String },
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum ComponentsVerb {
|
||||
List,
|
||||
/// Fetch, verify and install (all, or the named).
|
||||
Install { names: Vec<String> },
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@@ -630,6 +658,76 @@ async fn proxy(ctl: &Ctl, verb: Option<ProxyVerb>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn zapret(ctl: &Ctl, verb: Option<ZapretVerb>) -> Result<()> {
|
||||
match verb.unwrap_or(ZapretVerb::Status) {
|
||||
ZapretVerb::Status => {
|
||||
let s = ctl.call(Request::Status).await?;
|
||||
let z = &s["zapret"];
|
||||
if ctl.json {
|
||||
ctl.print(z);
|
||||
} else if z["enabled"] == true {
|
||||
println!("zapret: {} ({}, {})", z["state"].as_str().unwrap_or("?"), z["engine"].as_str().unwrap_or("?"), z["preset"].as_str().unwrap_or("?"));
|
||||
} else {
|
||||
println!("zapret: off");
|
||||
}
|
||||
}
|
||||
v @ (ZapretVerb::On | ZapretVerb::Off) => {
|
||||
let on = matches!(v, ZapretVerb::On);
|
||||
ctl.edit(|c| {
|
||||
c["zapret"]["enable"] = on.into();
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
ZapretVerb::Preset { name } => {
|
||||
ctl.edit(|c| {
|
||||
c["zapret"]["zapret-discord-youtube"]["configName"] = name.clone().into();
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
ZapretVerb::GameFilter { filter } => {
|
||||
if !matches!(filter.as_str(), "all" | "tcp" | "udp" | "null") {
|
||||
bail!("the game filter is all, tcp, udp or null");
|
||||
}
|
||||
ctl.edit(|c| {
|
||||
c["zapret"]["zapret-discord-youtube"]["gameFilter"] = filter.clone().into();
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn components(ctl: &Ctl, verb: Option<ComponentsVerb>) -> Result<()> {
|
||||
match verb.unwrap_or(ComponentsVerb::List) {
|
||||
ComponentsVerb::List => {
|
||||
let r = ctl.call(Request::Components).await?;
|
||||
if ctl.json {
|
||||
ctl.print(&r);
|
||||
return Ok(());
|
||||
}
|
||||
for c in r.as_array().into_iter().flatten() {
|
||||
let installed = c["installed"].as_str().unwrap_or("not installed");
|
||||
let want = c["version"].as_str().unwrap_or("");
|
||||
let note = if installed == want { "" } else { " (update with proxy-ctl components install)" };
|
||||
println!("{:14} {:22} installed {installed}{note}", c["name"].as_str().unwrap_or(""), want);
|
||||
}
|
||||
}
|
||||
ComponentsVerb::Install { names } => {
|
||||
let r = ctl.call(Request::ComponentsInstall { names }).await?;
|
||||
for c in r.as_array().into_iter().flatten() {
|
||||
match c["error"].as_str() {
|
||||
Some(e) => println!("{}: {e}", c["name"].as_str().unwrap_or("")),
|
||||
None => println!("{} {} installed", c["name"].as_str().unwrap_or(""), c["version"].as_str().unwrap_or("")),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn real_main() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
let addr = match cli.socket {
|
||||
@@ -662,6 +760,8 @@ async fn real_main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
Cmd::Proxy(p) => proxy(&ctl, p.verb).await?,
|
||||
Cmd::Zapret { verb } => zapret(&ctl, verb).await?,
|
||||
Cmd::Components { verb } => components(&ctl, verb).await?,
|
||||
Cmd::Config { verb } => match verb {
|
||||
ConfigVerb::Get => {
|
||||
let c = ctl.call(Request::ConfigGet).await?;
|
||||
|
||||
Reference in new issue
Block a user