windows: zapret2 with z2k's strategies and upstream's Lua layers
The zapret2-extras component (tools/build-zapret2-extras.sh): z2k at upstream's pinned commit, its strategies made by its own generator as upstream's z2k-profiles.template.sh runs it, with tokens where upstream fills in the configuration at build time; its Lua, lists and fakes; and upstream's own Lua: the extended detector (detect.lua), the per-site key by public suffix, the fail stamp, every-change persistence and the strategy log. winws2 now runs, as upstream's nfqws2 does, with z2k's Lua for its strategies, then the layers: each site's working strategy kept across restarts (z2k's state layer), strategies keyed by site, and with autoHostlist.extendedDetection the detector learning in place of nfqws2's own (its last TLS profile, the stall watch where the learned sites are). Lua arguments name paths as Cygwin does (no colon); what winws2 writes stays under the Low-integrity folder. The server's TLS handshake and alert records reach the detectors through a WinDivert filter part: WinDivert has no per-flow packet window to hand them over by. Options go to winws2 in a file (@file): z2k's alone are 55 KB, past a Windows command line. Both sources, with every layer, verified by winws2's --dry-run under Wine (tools/winws-dry-run.sh). The DPI page picks the strategies and switches the detection. proxyFallback and the cutoff probe are said to be not on Windows yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0a7d8d99c0
commit
9eed225ccc
10 files changed
+471
-40
No files matched your search
+3
-3
@@ -21,7 +21,7 @@ tray icon) or with `proxy-ctl`, as upstream's is.
|
||||
| Local proxy | SOCKS5/HTTP on `127.0.0.1:1080` through sing-box (or the hybrid sing-box + XRay backend) |
|
||||
| Outbounds | links (vless/REALITY/TLS, vmess, trojan, shadowsocks, hysteria2, tuic, anytls, naive, socks, http), raw JSON, subscriptions, groups (failover, urltest, selector), chains, pins, route modes, routing rules by site, address, geodata, rule set or **program** |
|
||||
| zapret | Flowseal's [zapret-discord-youtube](https://github.com/Flowseal/zapret-discord-youtube) release: `winws.exe` with any of its `general*.bat` presets, your lists, the game filter, and `hostlistRules` (a strategy of its own for a group of sites, copied from a preset or given) |
|
||||
| zapret2 | `winws2.exe` from bol-van's [zapret-win-bundle](https://github.com/bol-van/zapret-win-bundle) with [nfqws2-keenetic](https://github.com/nfqws/nfqws2-keenetic)'s strategies and nfqws2's own learning of blocked sites |
|
||||
| zapret2 | `winws2.exe` from bol-van's [zapret-win-bundle](https://github.com/bol-van/zapret-win-bundle) with [nfqws2-keenetic](https://github.com/nfqws/nfqws2-keenetic)'s strategies or [z2k](https://github.com/necronicle/z2k)'s (made by z2k's own generator, per category: YouTube, Discord, QUIC, the RKN list), and upstream's Lua around them: each site's working strategy kept across restarts, strategies keyed by site (the public suffix list), and the extended detector, which also learns sites blocked only some of the time and requests that never get an answer. The server's TLS replies reach the detectors through a WinDivert filter part; a download stalling mid-way (the 16 KB cutoff) is not seen on Windows, as WinDivert cannot hand over a flow's first packets alone |
|
||||
| tg-ws-proxy | Flowseal's [tg-ws-proxy](https://github.com/Flowseal/tg-ws-proxy), the headless proxy, on a bundled Python |
|
||||
| Tor | `tor`: the Tor Project's own Windows build (the Expert Bundle, signed, pinned), with bridges (obfs4, webtunnel, snowflake, meek, conjure) and, with `asOutbound`, an outbound of the proxy |
|
||||
| AmneziaWG | `amneziaWg` profiles, from a `.conf`, an AmneziaVPN `vpn://` link or settings. Without `asOutbound`, a **system-wide VPN**: amneziawg-windows's tunnel (amneziawg-go on Wintun, built from its source) as a Windows service of its own, with its routes, DNS and, for one peer that takes everything, its firewall blocking what leaves outside the tunnel; on and off in the app or `proxy-ctl awg on|off`. As outbounds: `"userspace"` (wireproxy-awg, built from upstream's source, AmneziaWG's obfuscation kept, no driver) or `"singBox"` (plain WireGuard). WARP devices take either kind too |
|
||||
@@ -33,8 +33,8 @@ tray icon) or with `proxy-ctl`, as upstream's is.
|
||||
| The app | **Proxy Suite** in the Start Menu, and a tray icon from sign-in: the proxy, DPI bypass and Telegram proxy at a glance and a click; outbounds, subscriptions and the routing mode; zapret's presets and sites; tg-ws-proxy's links; whitelist-bypass's joiners and creators (links, logins); autoProxy's routes, probes and exits; the logs; **every option** in its JSON editor, checked by the service before it takes it; the system proxy |
|
||||
|
||||
Not in this release, still to come: Tor's onion service,
|
||||
the kill switch, server inbounds, the XRay-only backend, zapret2's extended detection and z2k
|
||||
strategies. Their options are accepted (they are upstream's), but the
|
||||
the kill switch, server inbounds, the XRay-only backend, zapret2's proxyFallback (the proxy
|
||||
carrying what it cannot fix) and its 16 KB cutoff probe. Their options are accepted (they are upstream's), but the
|
||||
service says, in its status and in the app, that it does not run them yet.
|
||||
|
||||
Needs 64-bit Windows 10 (1903 or later) or 11.
|
||||
|
||||
@@ -126,6 +126,13 @@
|
||||
"bundled": true,
|
||||
"sources": []
|
||||
},
|
||||
"zapret2-extras": {
|
||||
"version": "2026.10.27+z2k.7beb975",
|
||||
"license": "MIT (z2k, proxy-suite's Lua); MPL-2.0 (the public suffix list)",
|
||||
"homepage": "https://github.com/necronicle/z2k",
|
||||
"bundled": true,
|
||||
"sources": []
|
||||
},
|
||||
"amneziawg": {
|
||||
"version": "0-unstable-2026-08-14+e90531d",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,21 +1,47 @@
|
||||
//! For tools/winws-dry-run.sh: winws2's arguments as the service builds them, one per line.
|
||||
//! `zapret2_args <component dir> <component dir as Windows sees it> <state dir as Windows sees it>`
|
||||
//! `zapret2_args <component dir> <component dir as Windows sees it> <state dir as Windows sees it>
|
||||
//! [<extras dir> <extras dir as Windows sees it> <extras dir as Cygwin sees it> keenetic|z2k]`
|
||||
|
||||
use ps_core::config::Zapret2;
|
||||
use ps_core::zapret2::{Paths, args, keenetic};
|
||||
use ps_core::config::{StrategySource, Zapret2};
|
||||
use ps_core::zapret2::{Extras, Paths, args, keenetic, z2k};
|
||||
|
||||
fn main() {
|
||||
let a: Vec<String> = std::env::args().collect();
|
||||
let conf = std::fs::read_to_string(std::path::Path::new(&a[1]).join("keenetic").join("nfqws2.conf")).unwrap();
|
||||
let (comp, state) = (&a[2], &a[3]);
|
||||
let source = keenetic(&conf, &format!("{comp}keenetic\\")).unwrap();
|
||||
let mut z = Zapret2 { domains: vec!["rutracker.org".into()], ..Default::default() };
|
||||
let mut source = keenetic(&conf, &format!("{comp}keenetic\\")).unwrap();
|
||||
let mut extras = None;
|
||||
if let [_, _, _, _, dir, win, cyg, kind] = &a[..] {
|
||||
let read = |f: &str| std::fs::read_to_string(std::path::Path::new(dir).join("z2k").join(f)).unwrap();
|
||||
if kind == "z2k" {
|
||||
z.strategy_source = StrategySource::Z2k;
|
||||
source = z2k(
|
||||
&read("profiles.plain"),
|
||||
&read("profiles.learn"),
|
||||
&read("blobs"),
|
||||
&read("ports"),
|
||||
&format!("{cyg}z2k"),
|
||||
&format!("{cyg}z2k/root"),
|
||||
&format!("{cyg}z2k/files/lua/"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
let state_cyg = format!("/cygdrive/{}", state.replace(':', "").replace('\\', "/").to_lowercase());
|
||||
extras = Some(Extras {
|
||||
lua: format!("{win}lua\\"),
|
||||
z2k_lua: format!("{win}z2k\\files\\lua\\"),
|
||||
auto_lua: format!("{state_cyg}learned/zapret-hosts-auto.txt"),
|
||||
exclude_lua: vec![format!("{state_cyg}zapret-hosts-user-exclude.txt")],
|
||||
});
|
||||
}
|
||||
let paths = Paths {
|
||||
lua: format!("{comp}lua\\"),
|
||||
user: format!("{state}zapret-hosts-user.txt"),
|
||||
exclude: format!("{state}zapret-hosts-user-exclude.txt"),
|
||||
auto: format!("{state}learned\\zapret-hosts-auto.txt"),
|
||||
extras,
|
||||
};
|
||||
let z = Zapret2 { domains: vec!["rutracker.org".into()], ..Default::default() };
|
||||
for arg in args(&z, &source, &paths, false).unwrap() {
|
||||
println!("{arg}");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{Backend, Config, GroupStrategy, Selection, StrategySource, ZapretDefaultDomains, ZapretEngine, ZapretPreset};
|
||||
use super::{Backend, Config, GroupStrategy, Selection, ZapretDefaultDomains, ZapretEngine, ZapretPreset};
|
||||
use crate::derived::{self, BUILTIN_TAGS};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -138,11 +138,11 @@ fn not_ported(cfg: &Config, v: &mut Issues) {
|
||||
v.warn("zapret.zapret-discord-youtube.includeExtraUpstreamLists", "Flowseal's Windows release has no instagram, soundcloud or twitter list: ignored");
|
||||
}
|
||||
if z.enable && z.engine == ZapretEngine::Zapret2 {
|
||||
if z.zapret2.strategy_source == StrategySource::Z2k && z.zapret2.profiles.is_none() {
|
||||
v.warn("zapret.zapret2.strategySource", "z2k's strategies are not on Windows yet: zapret2 does not start with them (nfqws2-keenetic's, or your own profiles, do)");
|
||||
if z.zapret2.proxy_fallback {
|
||||
v.warn("zapret.zapret2.proxyFallback", "the proxy carrying what zapret2 cannot fix is not on Windows yet: such sites stay direct");
|
||||
}
|
||||
if z.zapret2.auto_hostlist.extended_detection {
|
||||
v.warn("zapret.zapret2.autoHostlist.extendedDetection", "the extended detection is not on Windows yet: nfqws2's own learning is used");
|
||||
if z.zapret2.cutoff.enable {
|
||||
v.warn("zapret.zapret2.cutoff.enable", "the 16 KB cutoff probe is not on Windows yet");
|
||||
}
|
||||
}
|
||||
if z.enable && cfg.proxy.tun.enable {
|
||||
|
||||
@@ -34,14 +34,59 @@ fn patch(what: &str, from: &str, to: &str, text: &str) -> Result<String, String>
|
||||
}
|
||||
}
|
||||
|
||||
/// nfqws2-keenetic's strategies, as upstream's sources.nix takes them.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
/// A strategy source, as upstream's sources.nix takes it: nfqws2-keenetic's or z2k's.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct Source {
|
||||
/// In nfqws2's order: UDP, QUIC, TCP. Hostlist markers still in.
|
||||
/// In nfqws2's order. Hostlist markers (and z2k's tokens) still in.
|
||||
pub profiles: Vec<String>,
|
||||
/// z2k: its profiles with the extended detector learning in its last place.
|
||||
pub learn_profiles: Option<Vec<String>>,
|
||||
pub blob_args: Vec<String>,
|
||||
pub tcp_ports: String,
|
||||
pub udp_ports: String,
|
||||
/// Lua its strategies need, loaded after zapret2's own (z2k's detectors).
|
||||
pub lua_init: Vec<String>,
|
||||
/// winws2 options it runs with.
|
||||
pub daemon_args: Vec<String>,
|
||||
/// z2k's: its profiles carry @HSUF@, @ESUF@ and the learner's tokens.
|
||||
pub z2k: bool,
|
||||
}
|
||||
|
||||
/// z2k's Lua, in its S99zapret2 order (upstream's sources.nix): z2k-range-rand resolves the
|
||||
/// ranges its strategies write; without it each fake goes once.
|
||||
pub const Z2K_LUA: [&str; 6] = ["z2k-alert", "z2k-quic-silence", "z2k-tcp16", "z2k-fooling-ext", "z2k-range-rand", "z2k-modern-core"];
|
||||
|
||||
/// z2k's strategies, as its generator made them (tools/build-zapret2-extras.sh): `plain` and
|
||||
/// `learn` its two profile sets, `blobs` its fake payloads, `ports` its NFQWS2_PORTS_*;
|
||||
/// `z2k_dir` where its files are and `root_dir` the tree its generator wrote, as winws2 reads
|
||||
/// them, and `lua` its `files/lua/` likewise (with a trailing separator).
|
||||
pub fn z2k(plain: &str, learn: &str, blobs: &str, ports: &str, z2k_dir: &str, root_dir: &str, lua: &str) -> Result<Source, String> {
|
||||
let fill = |t: &str| t.replace("@ROOT@", root_dir).replace("@Z2K@", z2k_dir);
|
||||
let split = |t: &str| -> Vec<String> { fill(t).split(" --new ").map(|p| p.trim().to_owned()).filter(|p| !p.is_empty()).collect() };
|
||||
let (plain, learn) = (split(plain), split(learn));
|
||||
if plain.is_empty() || !plain.iter().any(|p| p.contains("--lua-desync=circular")) {
|
||||
return Err("z2k's generated profiles are empty: is the zapret2-extras component installed?".into());
|
||||
}
|
||||
let port = |name: &str| -> Result<String, String> {
|
||||
ports
|
||||
.lines()
|
||||
.find_map(|l| l.strip_prefix(&format!("{name}=")))
|
||||
.map(|v| v.trim().to_owned())
|
||||
.filter(|v| !v.is_empty())
|
||||
.ok_or_else(|| format!("z2k's ports: no {name}"))
|
||||
};
|
||||
Ok(Source {
|
||||
profiles: plain,
|
||||
learn_profiles: Some(learn),
|
||||
blob_args: words(&fill(blobs)).into_iter().map(str::to_owned).collect(),
|
||||
tcp_ports: port("NFQWS2_PORTS_TCP")?,
|
||||
udp_ports: port("NFQWS2_PORTS_UDP")?.replace(':', "-"),
|
||||
lua_init: Z2K_LUA.iter().map(|n| format!("{lua}{n}.lua")).collect(),
|
||||
// As its S99zapret2 runs nfqws2: a connection without SNI takes the name last seen
|
||||
// on that address, so it still meets its site's profile and strategy.
|
||||
daemon_args: vec!["--ipcache-hostname=1".into()],
|
||||
z2k: true,
|
||||
})
|
||||
}
|
||||
|
||||
/// `conf`: its `etc/nfqws2/nfqws2.conf`; `dir`: where its `etc/nfqws2/` is (as winws2 will
|
||||
@@ -94,6 +139,7 @@ pub fn keenetic(conf: &str, dir: &str) -> Result<Source, String> {
|
||||
blob_args,
|
||||
tcp_ports: bare("TCP_PORTS")?.trim().to_owned(),
|
||||
udp_ports: bare("UDP_PORTS")?.trim().replace(':', "-"),
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -108,6 +154,22 @@ pub struct Paths {
|
||||
pub exclude: String,
|
||||
/// `zapret-hosts-auto.txt`, in a directory labelled Low integrity.
|
||||
pub auto: String,
|
||||
/// The zapret2-extras component, when installed: upstream's Lua layers and z2k's.
|
||||
pub extras: Option<Extras>,
|
||||
}
|
||||
|
||||
/// Where the zapret2-extras component's files are, as winws2 reads them.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Extras {
|
||||
/// proxy-suite's own Lua (detect.lua, …), with a trailing separator.
|
||||
pub lua: String,
|
||||
/// z2k's `files/lua/`, with a trailing separator: its state layer persists strategies
|
||||
/// whichever the source.
|
||||
pub z2k_lua: String,
|
||||
/// The auto list and the lists the learner never learns from, as Lua arguments take
|
||||
/// paths: without a colon, so Cygwin's `/cygdrive/c/…` on Windows.
|
||||
pub auto_lua: String,
|
||||
pub exclude_lua: Vec<String>,
|
||||
}
|
||||
|
||||
/// A hostlist entry as nfqws2 takes one: a name (`^` for an exact match), nothing that could
|
||||
@@ -119,8 +181,9 @@ pub fn host_entry_ok(entry: &str) -> bool {
|
||||
&& entry.chars().enumerate().all(|(i, c)| c.is_ascii_alphanumeric() || matches!(c, '.' | '-' | '_' | '*') || (c == '^' && i == 0))
|
||||
}
|
||||
|
||||
/// What `<HOSTLIST>` and `<HOSTLIST_NOAUTO>` expand to (zapret2's filter_apply_hostlist_target).
|
||||
fn hostlist_args(z: &Zapret2, p: &Paths) -> (String, String) {
|
||||
/// What `<HOSTLIST>` and `<HOSTLIST_NOAUTO>` expand to (zapret2's filter_apply_hostlist_target),
|
||||
/// and the configuration's own sites and exclusions, which join every profile that takes a list.
|
||||
fn hostlist_args(z: &Zapret2, p: &Paths) -> (String, String, String) {
|
||||
let a = &z.auto_hostlist;
|
||||
let base = format!("--hostlist={} --hostlist-exclude={}", p.user, p.exclude);
|
||||
let (with_auto, no_auto) = if a.enable {
|
||||
@@ -156,7 +219,57 @@ fn hostlist_args(z: &Zapret2, p: &Paths) -> (String, String) {
|
||||
if !excluded.is_empty() {
|
||||
statics.push_str(&format!(" --hostlist-exclude-domains={}", excluded.join(",")));
|
||||
}
|
||||
(with_auto + &statics, no_auto + &statics)
|
||||
(with_auto, no_auto, statics)
|
||||
}
|
||||
|
||||
/// The extended detector's arguments (upstream's learnArgs and stallWatch), when it learns.
|
||||
fn detector(z: &Zapret2, x: &Extras) -> (String, String) {
|
||||
let a = &z.auto_hostlist;
|
||||
let mut learn = vec![
|
||||
format!("auto={}", x.auto_lua),
|
||||
format!("exclude={}", x.exclude_lua.join(",")),
|
||||
format!("fails={}", a.fail_threshold),
|
||||
format!("time={}", a.fail_time),
|
||||
format!("inseq={}", a.incoming_maxseq),
|
||||
format!("retrans={}", a.retrans_threshold),
|
||||
// How many of the server's packets it watches (upstream's NFQUEUE window).
|
||||
"win=32".into(),
|
||||
];
|
||||
let excluded: Vec<&str> = z.exclude_domains.iter().map(String::as_str).filter(|d| host_entry_ok(d)).collect();
|
||||
if !excluded.is_empty() {
|
||||
learn.push(format!("exclude_domains={}", excluded.join(",")));
|
||||
}
|
||||
if z.strategy_log {
|
||||
learn.push("log".into());
|
||||
}
|
||||
let mut watch = vec![format!("fails={}", a.fail_threshold), format!("time={}", a.fail_time), "win=32".into()];
|
||||
if z.strategy_log {
|
||||
watch.push("log".into());
|
||||
}
|
||||
(
|
||||
learn.join(":"),
|
||||
format!("--in-range=-s65536 --payload=all --lua-desync=ps_watch:{} --in-range=x --payload=all", watch.join(":")),
|
||||
)
|
||||
}
|
||||
|
||||
/// A WinDivert filter part for the server's packets that begin a TLS handshake or alert
|
||||
/// record, on `ports`: what the detectors judge a site by (its ServerHello, a refusal), where
|
||||
/// nfqws2 is handed a flow's first packets by a queue window WinDivert has no means for.
|
||||
fn tls_reply_filter(ports: &str) -> Option<String> {
|
||||
let conds: Vec<String> = ports
|
||||
.split(',')
|
||||
.filter_map(|p| match p.split_once('-') {
|
||||
Some((a, b)) => Some(format!("(tcp.SrcPort >= {} and tcp.SrcPort <= {})", a.trim().parse::<u16>().ok()?, b.trim().parse::<u16>().ok()?)),
|
||||
None => Some(format!("tcp.SrcPort == {}", p.trim().parse::<u16>().ok()?)),
|
||||
})
|
||||
.collect();
|
||||
if conds.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(format!(
|
||||
"inbound and tcp.PayloadLength >= 6 and (tcp.Payload[0] == 0x16 or tcp.Payload[0] == 0x15) and tcp.Payload[1] == 0x03 and ({})",
|
||||
conds.join(" or ")
|
||||
))
|
||||
}
|
||||
|
||||
/// Detector settings a circular instance leaves unset come from autoHostlist.
|
||||
@@ -230,29 +343,91 @@ pub(crate) fn merge_ports(lists: &[&str]) -> String {
|
||||
|
||||
/// winws2's whole command line.
|
||||
pub fn args(z: &Zapret2, source: &Source, p: &Paths, debug_packets: bool) -> Result<Vec<String>, String> {
|
||||
if z.strategy_source != StrategySource::Nfqws2Keenetic && z.profiles.is_none() {
|
||||
return Err("only the nfqws2-keenetic strategies are there on Windows yet (zapret.zapret2.strategySource)".into());
|
||||
if z.strategy_source == StrategySource::Z2k && z.profiles.is_none() && !source.z2k {
|
||||
return Err("z2k's strategies need the zapret2-extras component (proxy-ctl components)".into());
|
||||
}
|
||||
let (with_auto, no_auto) = hostlist_args(z, p);
|
||||
let render = |profile: &str| {
|
||||
let (with_auto, no_auto, statics) = hostlist_args(z, p);
|
||||
// The extended detector learns in place of nfqws2's own learning: with the source's own
|
||||
// strategies only, and the component installed.
|
||||
let learning = p.extras.as_ref().filter(|_| z.auto_hostlist.enable && z.auto_hostlist.extended_detection && z.profiles.is_none());
|
||||
let (learn_args, stall_watch) = learning.map(|x| detector(z, x)).unwrap_or_default();
|
||||
let exclude_suffix = {
|
||||
let mut e = format!("--hostlist-exclude={}", p.exclude);
|
||||
let excluded: Vec<&str> = z.exclude_domains.iter().map(String::as_str).filter(|d| host_entry_ok(d)).collect();
|
||||
if !excluded.is_empty() {
|
||||
e.push_str(&format!(" --hostlist-exclude-domains={}", excluded.join(",")));
|
||||
}
|
||||
e
|
||||
};
|
||||
let render = |profile: &str| -> String {
|
||||
if source.z2k && z.profiles.is_none() {
|
||||
// z2k's profiles name the lists themselves; the markers take only ours, and the
|
||||
// configuration's sites go where its generator left @HSUF@.
|
||||
return profile
|
||||
.replace("<HOSTLIST_NOAUTO>", &no_auto)
|
||||
.replace("<HOSTLIST>", &with_auto)
|
||||
.replace("@HSUF@", statics.trim())
|
||||
.replace("@ESUF@", &exclude_suffix)
|
||||
.replace("@STALLWATCH@", &stall_watch)
|
||||
.replace(":win=32@LEARNEXTRA@", &learn_args.split(":win=32").nth(1).map(|rest| format!(":win=32{rest}")).unwrap_or_else(|| ":win=32".into()))
|
||||
.replace("@AUTO@", learning.map_or("", |x| x.auto_lua.as_str()))
|
||||
.replace("@EXCLUDE@", &learning.map(|x| x.exclude_lua.join(",")).unwrap_or_default())
|
||||
.replace("@FAILS@", &z.auto_hostlist.fail_threshold.to_string())
|
||||
.replace("@TIME@", &z.auto_hostlist.fail_time.to_string())
|
||||
.replace("@INSEQ@", &z.auto_hostlist.incoming_maxseq.to_string())
|
||||
.replace("@RETRANS@", &z.auto_hostlist.retrans_threshold.to_string());
|
||||
}
|
||||
// nfqws2-keenetic: with the extended detector, its learning profile only reads the
|
||||
// auto list (upstream's sourceProfiles).
|
||||
let profile = if learning.is_some() { profile.replace("<HOSTLIST>", "<HOSTLIST_NOAUTO>") } else { profile.to_owned() };
|
||||
profile
|
||||
.replace("<HOSTLIST_NOAUTO>", &no_auto)
|
||||
.replace("<HOSTLIST>", &with_auto)
|
||||
.replace("<STALLWATCH> ", "")
|
||||
.replace("<STALLWATCH>", "")
|
||||
.replace("<HOSTLIST_NOAUTO>", &(no_auto.clone() + &statics))
|
||||
.replace("<HOSTLIST>", &(with_auto.clone() + &statics))
|
||||
.replace("<STALLWATCH> ", &if stall_watch.is_empty() { String::new() } else { format!("{stall_watch} ") })
|
||||
.replace("<STALLWATCH>", &stall_watch)
|
||||
};
|
||||
let profiles: Vec<String> = match &z.profiles {
|
||||
Some(own) => own.iter().map(|x| render(x)).collect(),
|
||||
None => source.profiles.iter().map(|x| render(x)).collect(),
|
||||
let mut profiles: Vec<String> = match (&z.profiles, &source.learn_profiles) {
|
||||
(Some(own), _) => own.iter().map(|x| render(x)).collect(),
|
||||
(None, Some(learn)) if learning.is_some() => learn.iter().map(|x| render(x)).collect(),
|
||||
(None, _) => source.profiles.iter().map(|x| render(x)).collect(),
|
||||
};
|
||||
// After every source profile, so it only takes what none of them did: ps_learn, the TLS
|
||||
// sites in no list (z2k's places its own).
|
||||
if learning.is_some() && !source.z2k {
|
||||
profiles.push(format!(
|
||||
"--filter-tcp=443 --filter-l7=tls --in-range=-s65536 --out-range=-s32768 --payload=all --lua-desync=ps_learn:{learn_args}"
|
||||
));
|
||||
}
|
||||
|
||||
let mut opt: Vec<String> = Vec::new();
|
||||
if debug_packets {
|
||||
opt.push("--debug=1".into());
|
||||
}
|
||||
if z.profiles.is_none() {
|
||||
opt.extend(source.daemon_args.iter().cloned());
|
||||
}
|
||||
for lua in ["zapret-lib.lua", "zapret-antidpi.lua", "zapret-auto.lua"] {
|
||||
opt.push(format!("--lua-init=@{}{lua}", p.lua));
|
||||
}
|
||||
if z.profiles.is_none() {
|
||||
opt.extend(source.lua_init.iter().map(|f| format!("--lua-init=@{f}")));
|
||||
}
|
||||
// Upstream's layers, in its order: the per-site key, the fail stamp, z2k's state layer
|
||||
// (each site's strategy kept across restarts) and its every-change writes, the detector
|
||||
// (after z2k-alert.lua, whose detector it wraps), the strategy log.
|
||||
if let Some(x) = &p.extras {
|
||||
let mut layers = vec![
|
||||
format!("{}public-suffix-hostkey.lua", x.lua),
|
||||
format!("{}fail-stamp.lua", x.lua),
|
||||
format!("{}z2k-state-persist.lua", x.z2k_lua),
|
||||
format!("{}persist-every.lua", x.lua),
|
||||
format!("{}detect.lua", x.lua),
|
||||
];
|
||||
if z.strategy_log {
|
||||
layers.push(format!("{}strategy-log.lua", x.lua));
|
||||
}
|
||||
opt.extend(layers.into_iter().map(|f| format!("--lua-init=@{f}")));
|
||||
}
|
||||
for (name, file) in &z.blobs {
|
||||
opt.push(format!("--blob={name}:@{file}"));
|
||||
}
|
||||
@@ -313,6 +488,9 @@ pub fn args(z: &Zapret2, source: &Source, p: &Paths, debug_packets: bool) -> Res
|
||||
let (wf_tcp, wf_udp) = (merge_ports(&tcp_all), merge_ports(&udp_all));
|
||||
if !wf_tcp.is_empty() {
|
||||
opt.push(format!("--wf-tcp-out={wf_tcp}"));
|
||||
if let Some(part) = tls_reply_filter(&wf_tcp) {
|
||||
opt.push(format!("--wf-raw-part={part}"));
|
||||
}
|
||||
}
|
||||
if !wf_udp.is_empty() {
|
||||
opt.push(format!("--wf-udp-out={wf_udp}"));
|
||||
@@ -364,9 +542,63 @@ UDP_PORTS=443,590:600
|
||||
user: r"C:\s\user.txt".into(),
|
||||
exclude: r"C:\s\exclude.txt".into(),
|
||||
auto: r"C:\s\learned\auto.txt".into(),
|
||||
extras: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn extras() -> Extras {
|
||||
Extras {
|
||||
lua: r"C:\x\lua\".into(),
|
||||
z2k_lua: r"C:\x\z2k\files\lua\".into(),
|
||||
auto_lua: "/cygdrive/c/s/learned/auto.txt".into(),
|
||||
exclude_lua: vec!["/cygdrive/c/s/exclude.txt".into()],
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_extended_detector_learns_in_place_of_nfqws2() {
|
||||
let z = Zapret2 { strategy_log: true, ..Default::default() };
|
||||
let s = keenetic(CONF, r"C:\z2\keenetic\").unwrap();
|
||||
let p = Paths { extras: Some(extras()), ..paths() };
|
||||
let a = args(&z, &s, &p, false).unwrap();
|
||||
let inits: Vec<&String> = a.iter().filter(|x| x.starts_with("--lua-init=")).collect();
|
||||
assert_eq!(inits.len(), 3 + 6, "zapret's, then upstream's layers: {inits:?}");
|
||||
assert_eq!(inits[3], r"--lua-init=@C:\x\lua\public-suffix-hostkey.lua");
|
||||
assert_eq!(inits[5], r"--lua-init=@C:\x\z2k\files\lua\z2k-state-persist.lua");
|
||||
assert!(inits[7].ends_with("detect.lua") && inits[8].ends_with("strategy-log.lua"));
|
||||
let learn = a.iter().find(|x| x.starts_with("--lua-desync=ps_learn:")).expect("a learning profile");
|
||||
assert!(learn.starts_with("--lua-desync=ps_learn:auto=/cygdrive/c/s/learned/auto.txt:exclude=/cygdrive/c/s/exclude.txt:fails="), "{learn}");
|
||||
assert!(learn.ends_with(":win=32:log"));
|
||||
assert!(a.iter().any(|x| x.starts_with("--lua-desync=ps_watch:")), "the stall watch, where <STALLWATCH> was");
|
||||
assert!(!a.iter().any(|x| x.starts_with("--hostlist-auto=")), "nfqws2's own learning is off");
|
||||
let raw = a.iter().find(|x| x.starts_with("--wf-raw-part=")).expect("the TLS replies' filter");
|
||||
assert!(raw.contains("tcp.Payload[0] == 0x16") && raw.contains("tcp.SrcPort == 443"), "{raw}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn z2k_fills_its_tokens() {
|
||||
let plain = "--filter-tcp=443 --hostlist-exclude=@ROOT@/lists/whitelist.txt @ESUF@ --lua-desync=circular:fails=3 --new --filter-tcp=443 --filter-l7=tls <HOSTLIST> @HSUF@";
|
||||
let learn = "--filter-tcp=443 @STALLWATCH@ --lua-desync=circular:fails=3 --new --filter-tcp=443 --lua-desync=ps_learn:auto=@AUTO@:exclude=@ROOT@/lists/whitelist.txt,@EXCLUDE@:fails=@FAILS@:time=@TIME@:inseq=@INSEQ@:retrans=@RETRANS@:win=32@LEARNEXTRA@";
|
||||
let s = z2k(plain, learn, "--blob=a:@@Z2K@/files/fake/a.bin", "NFQWS2_PORTS_TCP=80,443\nNFQWS2_PORTS_UDP=443\n", "/cygdrive/c/x/z2k", "/cygdrive/c/x/z2k/root", "/cygdrive/c/x/z2k/files/lua/").unwrap();
|
||||
assert_eq!(s.blob_args, ["--blob=a:@/cygdrive/c/x/z2k/files/fake/a.bin"]);
|
||||
assert!(s.lua_init[0].ends_with("z2k-alert.lua") && s.daemon_args == ["--ipcache-hostname=1"]);
|
||||
let mut z = Zapret2 { strategy_source: StrategySource::Z2k, ..Default::default() };
|
||||
z.domains = vec!["mine.example".into()];
|
||||
// Without the detector: the plain set, our lists where the markers are.
|
||||
z.auto_hostlist.extended_detection = false;
|
||||
let a = args(&z, &s, &Paths { extras: Some(extras()), ..paths() }, false).unwrap().join(" ");
|
||||
assert!(a.contains("--hostlist-exclude=/cygdrive/c/x/z2k/root/lists/whitelist.txt --hostlist-exclude=C:\\s\\exclude.txt"), "{a}");
|
||||
assert!(a.contains("--hostlist-auto=C:\\s\\learned\\auto.txt") && a.contains("--hostlist-domains=mine.example"), "{a}");
|
||||
assert!(a.contains("--lua-init=@/cygdrive/c/x/z2k/files/lua/z2k-alert.lua"));
|
||||
// With it: the learning set, every token filled.
|
||||
z.auto_hostlist.extended_detection = true;
|
||||
let a = args(&z, &s, &Paths { extras: Some(extras()), ..paths() }, false).unwrap().join(" ");
|
||||
assert!(!a.contains('@') || !a.contains("@AUTO@"), "{a}");
|
||||
assert!(a.contains("ps_learn:auto=/cygdrive/c/s/learned/auto.txt:exclude=/cygdrive/c/x/z2k/root/lists/whitelist.txt,/cygdrive/c/s/exclude.txt:fails=3"), "{a}");
|
||||
assert!(a.contains("--lua-desync=ps_watch:"), "{a}");
|
||||
assert!(!a.contains("@STALLWATCH@") && !a.contains("@LEARNEXTRA@") && !a.contains("@HSUF@") && !a.contains("@ESUF@"), "{a}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keenetic_is_read_and_patched_as_upstream_does() {
|
||||
let s = keenetic(CONF, r"C:\z2\keenetic\").unwrap();
|
||||
|
||||
@@ -15,6 +15,7 @@ use super::widgets::{card, hint, page, state_tag};
|
||||
use crate::model::Model;
|
||||
|
||||
const ENGINES: [(&str, &str); 2] = [("zapret-discord-youtube", "Flowseal's presets (zapret)"), ("zapret2", "zapret2")];
|
||||
const SOURCES: [(&str, &str); 2] = [("nfqws2-keenetic", "nfqws2-keenetic"), ("z2k", "z2k (per category: YouTube, Discord, QUIC, the RKN list)")];
|
||||
const GAME_FILTERS: [(&str, &str); 4] = [("null", "Off"), ("all", "TCP and UDP"), ("tcp", "TCP only"), ("udp", "UDP only")];
|
||||
|
||||
/// Preset names as the service matches them: without spaces, any case.
|
||||
@@ -180,7 +181,7 @@ impl Render for DpiPage {
|
||||
.child(engines)
|
||||
.child(hint(
|
||||
if engine == "zapret2" {
|
||||
"zapret2 (winws2) with nfqws2-keenetic's strategies; it learns which sites are blocked as it goes."
|
||||
"zapret2 (winws2): it learns which sites are blocked as it goes, rotates each one's strategy until one works, and keeps it across restarts."
|
||||
} else {
|
||||
"Flowseal's zapret-discord-youtube: winws with one of its presets, for YouTube, Discord and the sites in its lists."
|
||||
},
|
||||
@@ -189,9 +190,35 @@ impl Render for DpiPage {
|
||||
);
|
||||
|
||||
if engine == "zapret2" {
|
||||
let model = self.model.clone();
|
||||
let source = config["zapret"]["zapret2"]["strategySource"].as_str().unwrap_or("nfqws2-keenetic");
|
||||
let sources = RadioGroup::horizontal("strategy-source")
|
||||
.children(SOURCES.map(|(_, label)| label))
|
||||
.selected_index(SOURCES.iter().position(|(v, _)| *v == source))
|
||||
.on_change(move |ix, _, cx| {
|
||||
let (value, label) = SOURCES[*ix];
|
||||
model.update(cx, |m, cx| {
|
||||
m.edit(
|
||||
format!("Strategies: {label}"),
|
||||
move |c| {
|
||||
edits::set_path(c, &["zapret", "zapret2", "strategySource"], value.into());
|
||||
Ok(())
|
||||
},
|
||||
cx,
|
||||
)
|
||||
})
|
||||
});
|
||||
body = body.child(
|
||||
card("zapret2", None, cx)
|
||||
.child(div().text_sm().child("Strategies"))
|
||||
.child(sources)
|
||||
.child(self.option_switch("autohostlist", "Learn which sites are blocked", &["zapret", "zapret2", "autoHostlist", "enable"], &config))
|
||||
.child(self.option_switch(
|
||||
"extended-detection",
|
||||
"Extended detection: also sites blocked only some of the time, and requests that never get an answer",
|
||||
&["zapret", "zapret2", "autoHostlist", "extendedDetection"],
|
||||
&config,
|
||||
))
|
||||
.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)),
|
||||
);
|
||||
|
||||
@@ -146,19 +146,43 @@ pub async fn enable_tcp_timestamps() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The unit for zapret2: winws2 with nfqws2-keenetic's strategies (ps_core::zapret2), its
|
||||
/// lists in the service's `zapret2\\` directory, the learned one where winws2 can still write
|
||||
/// once it runs at Low integrity.
|
||||
/// The unit for zapret2: winws2 with nfqws2-keenetic's or z2k's strategies
|
||||
/// (ps_core::zapret2), upstream's Lua layers from the zapret2-extras component when it is
|
||||
/// installed, its lists in the service's `zapret2\\` directory, and what winws2 writes (the
|
||||
/// learned list, each site's strategy, the detector's verdicts) where it can still write once
|
||||
/// it runs at Low integrity.
|
||||
pub fn zapret2_unit(cfg: &Config, paths: &Paths, program: PathBuf) -> Result<UnitSpec> {
|
||||
use ps_core::config::StrategySource;
|
||||
use ps_core::zapret2;
|
||||
let z = &cfg.zapret.zapret2;
|
||||
let component = paths.bin().join("zapret2");
|
||||
let conf = std::fs::read_to_string(component.join("keenetic").join("nfqws2.conf")).context("reading nfqws2-keenetic's nfqws2.conf")?;
|
||||
let source = zapret2::keenetic(&conf, &with_sep(&component.join("keenetic"))).map_err(anyhow::Error::msg)?;
|
||||
let extras_dir = paths.bin().join("zapret2-extras");
|
||||
let extras_there = extras_dir.join("lua").join("detect.lua").is_file();
|
||||
let keenetic_dir = component.join("keenetic");
|
||||
let source = if z.strategy_source == StrategySource::Z2k && extras_there {
|
||||
let z2k = extras_dir.join("z2k");
|
||||
let read = |name: &str| std::fs::read_to_string(z2k.join(name)).with_context(|| format!("reading z2k's {name}"));
|
||||
zapret2::z2k(
|
||||
&read("profiles.plain")?,
|
||||
&read("profiles.learn")?,
|
||||
&read("blobs")?,
|
||||
&read("ports")?,
|
||||
&lua_path(&z2k),
|
||||
&lua_path(&z2k.join("root")),
|
||||
&with_sep_lua(&z2k.join("files").join("lua")),
|
||||
)
|
||||
.map_err(anyhow::Error::msg)?
|
||||
} else {
|
||||
let conf = std::fs::read_to_string(keenetic_dir.join("nfqws2.conf")).context("reading nfqws2-keenetic's nfqws2.conf")?;
|
||||
zapret2::keenetic(&conf, &with_sep(&keenetic_dir)).map_err(anyhow::Error::msg)?
|
||||
};
|
||||
|
||||
let state = paths.root.join("zapret2");
|
||||
let learned = state.join("learned");
|
||||
std::fs::create_dir_all(&learned)?;
|
||||
let circular = learned.join("circular");
|
||||
let fallback = learned.join("run");
|
||||
std::fs::create_dir_all(&circular)?;
|
||||
std::fs::create_dir_all(&fallback)?;
|
||||
#[cfg(windows)]
|
||||
low_integrity(&learned)?;
|
||||
let user = state.join("zapret-hosts-user.txt");
|
||||
@@ -170,23 +194,93 @@ pub fn zapret2_unit(cfg: &Config, paths: &Paths, program: PathBuf) -> Result<Uni
|
||||
std::fs::write(f, b"")?;
|
||||
}
|
||||
}
|
||||
let extras = extras_there.then(|| {
|
||||
// Never learned by the detector, as the source's own learning never learned them.
|
||||
let mut exclude_lua = Vec::new();
|
||||
if !source.z2k {
|
||||
exclude_lua.push(lua_path(&keenetic_dir.join("lists").join("exclude.list")));
|
||||
}
|
||||
exclude_lua.push(lua_path(&exclude));
|
||||
zapret2::Extras {
|
||||
lua: with_sep(&extras_dir.join("lua")),
|
||||
z2k_lua: with_sep(&extras_dir.join("z2k").join("files").join("lua")),
|
||||
auto_lua: lua_path(&auto),
|
||||
exclude_lua,
|
||||
}
|
||||
});
|
||||
let p = zapret2::Paths {
|
||||
lua: with_sep(&component.join("lua")),
|
||||
user: user.to_string_lossy().into_owned(),
|
||||
exclude: exclude.to_string_lossy().into_owned(),
|
||||
auto: auto.to_string_lossy().into_owned(),
|
||||
extras,
|
||||
};
|
||||
let argv = zapret2::args(z, &source, &p, cfg.debug.zapret2.packets).map_err(anyhow::Error::msg)?;
|
||||
// Read inside winws2 by z2k's state layer, the detector and the per-site key.
|
||||
let mut env = Vec::new();
|
||||
if extras_there {
|
||||
env.push(("Z2K_STATE_DIR_OVERRIDE".to_owned(), lua_path(&circular)));
|
||||
env.push(("Z2K_AUTOCIRCULAR_FALLBACK_OVERRIDE".to_owned(), lua_path(&fallback)));
|
||||
env.push(("PROXY_SUITE_ZAPRET2_VERDICTS".to_owned(), lua_path(&learned.join("verdicts.tsv"))));
|
||||
env.push(("PROXY_SUITE_PUBLIC_SUFFIXES".to_owned(), lua_path(&extras_dir.join("public_suffixes.txt"))));
|
||||
}
|
||||
let generation = {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut h = Sha256::new();
|
||||
for a in &argv {
|
||||
for a in argv.iter().chain(env.iter().map(|(_, v)| v)) {
|
||||
h.update(a.as_bytes());
|
||||
h.update(b"\n");
|
||||
}
|
||||
h.finalize().iter().map(|b| format!("{b:02x}")).collect()
|
||||
};
|
||||
Ok(UnitSpec { name: UNIT.into(), program, args: argv, env: Vec::new(), cwd: Some(component), generation })
|
||||
// In a file winws2 reads (`@file`, its only argument): z2k's strategies alone run past
|
||||
// the 32767 characters a Windows command line holds.
|
||||
let file = paths.run().join("winws2.conf");
|
||||
write_atomic(&file, options_file(&argv).as_bytes()).with_context(|| format!("writing {}", file.display()))?;
|
||||
Ok(UnitSpec { name: UNIT.into(), program, args: vec![format!("@{}", file.display())], env, cwd: Some(component), generation })
|
||||
}
|
||||
|
||||
/// winws2's options as its `@file` takes them: one a line, quoted when it holds a space.
|
||||
pub fn options_file(argv: &[String]) -> String {
|
||||
let mut out = String::new();
|
||||
for a in argv {
|
||||
if a.contains(char::is_whitespace) || a.contains('"') {
|
||||
out.push('"');
|
||||
out.push_str(&a.replace('\\', "\\\\").replace('"', "\\\""));
|
||||
out.push('"');
|
||||
} else {
|
||||
out.push_str(a);
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A path as winws2's Lua takes it in a colon-separated argument, or opens it from the
|
||||
/// environment: Cygwin's `/cygdrive/c/…` on Windows (winws2 is a Cygwin program), as it is
|
||||
/// elsewhere.
|
||||
fn lua_path(p: &Path) -> String {
|
||||
let s = p.to_string_lossy().into_owned();
|
||||
if cfg!(windows) { cygwin(&s) } else { s }
|
||||
}
|
||||
|
||||
fn with_sep_lua(p: &Path) -> String {
|
||||
let mut s = lua_path(p);
|
||||
if !s.ends_with('/') && !s.ends_with('\\') {
|
||||
s.push(if cfg!(windows) { '/' } else { std::path::MAIN_SEPARATOR });
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
/// `C:\\a\\b` as Cygwin names it: `/cygdrive/c/a/b`.
|
||||
fn cygwin(path: &str) -> String {
|
||||
let path = path.trim_start_matches(r"\\?\");
|
||||
match path.as_bytes() {
|
||||
[d, b':', rest @ ..] if d.is_ascii_alphabetic() => {
|
||||
format!("/cygdrive/{}{}", (*d as char).to_ascii_lowercase(), String::from_utf8_lossy(rest).replace('\\', "/"))
|
||||
}
|
||||
_ => path.replace('\\', "/"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A Low mandatory label on `dir`, inherited below it: what a Low-integrity process (winws2,
|
||||
@@ -220,3 +314,20 @@ fn low_integrity(dir: &Path) -> Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn options_go_one_a_line_quoted_when_spaced() {
|
||||
let argv: Vec<String> = ["--filter-tcp=443", "--wf-raw-part=inbound and tcp.Payload[0] == 0x16", r#"--x="a""#].map(String::from).into();
|
||||
assert_eq!(options_file(&argv), "--filter-tcp=443\n\"--wf-raw-part=inbound and tcp.Payload[0] == 0x16\"\n\"--x=\\\"a\\\"\"\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cygwin_names_drives_and_separators() {
|
||||
assert_eq!(cygwin(r"C:\ProgramData\ProxySuite\zapret2\learned"), "/cygdrive/c/ProgramData/ProxySuite/zapret2/learned");
|
||||
assert_eq!(cygwin(r"\\?\D:\x"), "/cygdrive/d/x");
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ The desktop app: Proxy Suite now has a window and a tray icon, besides `proxy-ct
|
||||
`install.cmd` puts it in the Start Menu and starts it at every sign-in, in the tray.
|
||||
|
||||
### Also
|
||||
- zapret2: z2k's strategies (`strategySource = "z2k"`), made by z2k's own generator; upstream's Lua around either source: each site's working strategy kept across restarts, strategies keyed by site, and the extended detector (`autoHostlist.extendedDetection`), which also learns sites blocked only some of the time and requests that never get an answer. On the DPI bypass page too.
|
||||
- zapret's `hostlistRules`: a group of sites with its own strategy, copied from a preset (or another one, `configName`) or given as `nfqwsArgs`, ahead of the preset's own; every preset with them checked by Flowseal's `winws.exe`.
|
||||
- The SSH tunnel (`sshProxy`): Windows' own OpenSSH as a SOCKS listener for other programs, and, with `asOutbound`, an outbound of the proxy. Needs Windows' "OpenSSH Client" (there by default since Windows 10 1809).
|
||||
- Tor (`tor`): the Tor Project's own Windows build, with bridges (obfs4, webtunnel, snowflake, meek, conjure) and, with `asOutbound`, an outbound of the proxy.
|
||||
@@ -40,7 +41,7 @@ Download `ProxySuite-0.2.0-pre.1-windows-x64-setup.exe` and run it (its SHA-256
|
||||
The zip is still there, the same files with `install.cmd`.
|
||||
|
||||
### Not yet
|
||||
Tor's onion service, the kill switch, server inbounds, the XRay-only backend, zapret2's extended detection and the z2k strategies.
|
||||
Tor's onion service, the kill switch, server inbounds, the XRay-only backend, zapret2's proxyFallback and its 16 KB cutoff probe.
|
||||
|
||||
### Note
|
||||
Unlike upstream, the signed-in user may change every setting by default (`userControl`), except the ones that could run programs or read files as SYSTEM: those always need an administrator. On a shared computer, restrict `userControl.scopes`.
|
||||
@@ -22,6 +22,7 @@ tools/build-tg-ws-proxy.sh "$DIST/components/tg-ws-proxy"
|
||||
tools/build-wireproxy-awg.sh "$DIST/components/wireproxy-awg" windows
|
||||
tools/build-whitelist-bypass.sh "$DIST/components/whitelist-bypass" windows
|
||||
tools/build-amneziawg.sh "$DIST/components/amneziawg"
|
||||
tools/build-zapret2-extras.sh "$DIST/components/zapret2-extras"
|
||||
cargo build -q --release -p ps-service
|
||||
target/release/proxy-suite-service stage-components --to "$DIST/components" --cache "$CACHE"
|
||||
rm -rf "$DIST"/components/*.old "$DIST"/components/*.staging
|
||||
@@ -59,6 +60,9 @@ echo "== THIRD-PARTY.md"
|
||||
echo "- **zapret2** (winws2.exe, its Lua) and **nfqws2-keenetic** (its strategies, lists, blobs): MIT, https://github.com/bol-van/zapret2, https://github.com/nfqws/nfqws2-keenetic"
|
||||
echo "- **wintun** (inside sing-box): WireGuard's prebuilt-binary license, https://www.wintun.net"
|
||||
echo "- **amneziawg-go** (inside wireproxy-awg, with the suite's patch, and inside amneziawg's awg-tunnel.exe): MIT, https://github.com/amnezia-vpn/amneziawg-go"
|
||||
echo "- **z2k** (zapret2-extras: its strategies, made by its own generator, its Lua and lists): MIT, https://github.com/necronicle/z2k"
|
||||
echo "- **The public suffix list** (zapret2-extras' public_suffixes.txt, derived): MPL-2.0, https://publicsuffix.org"
|
||||
echo "- **proxy-suite's zapret2 Lua** (zapret2-extras' lua/: the extended detector and the layers around z2k's state): MIT, this repository's modules/proxy-suite/zapret2"
|
||||
echo "- **Wintun** (amneziawg's wintun.dll, as WireGuard LLC builds and signs it): its prebuilt-binaries license, components/amneziawg/wintun-LICENSE.txt"
|
||||
echo "- **Go modules** (inside wireproxy-awg and whitelist-bypass, e.g. Pion's WebRTC): as each project's go.mod pins them, under their own licenses (MIT, BSD-3-Clause, Apache-2.0)"
|
||||
echo "- **lyrebird** and **conjure** (Tor's pluggable transports, in the Expert Bundle): their licenses are in components/tor/docs"
|
||||
|
||||
@@ -59,4 +59,27 @@ if out=$(cd "$Z2" && wine ./winws2.exe --dry-run "${args[@]}" 2>&1) && grep -q "
|
||||
else
|
||||
fail=$((fail + 1)); echo "FAIL: zapret2"; grep -v -i cygwin <<<"$out" | tail -4
|
||||
fi
|
||||
# With the zapret2-extras component: upstream's Lua layers loaded and the extended detector
|
||||
# learning, for nfqws2-keenetic's strategies and for z2k's, with the environment the service
|
||||
# gives winws2.
|
||||
X="$STAGE/zapret2-extras"
|
||||
if [ -d "$X" ]; then
|
||||
cyg() { echo "/cygdrive/z$(realpath "$1")"; }
|
||||
mkdir -p "$WORK/z2/learned/circular" "$WORK/z2/learned/run"
|
||||
for kind in keenetic z2k; do
|
||||
# Through an options file (@file), as the service starts winws2: z2k's run past the
|
||||
# 32767 characters of a Windows command line. One a line, quoted when it holds a space.
|
||||
{ echo --dry-run; target/debug/examples/zapret2_args "$Z2" "$(win "$Z2")" "$(win "$WORK/z2")" "$X" "$(win "$X")" "$(cyg "$X")/" "$kind"; } |
|
||||
python3 -I -c 'import sys
|
||||
for a in sys.stdin.read().splitlines():
|
||||
print(("\"" + a.replace("\\", "\\\\").replace("\"", "\\\"") + "\"") if (" " in a or "\"" in a) else a)' >"$WORK/winws2.conf"
|
||||
if out=$(cd "$Z2" && Z2K_STATE_DIR_OVERRIDE="$(cyg "$WORK/z2/learned/circular")" Z2K_AUTOCIRCULAR_FALLBACK_OVERRIDE="$(cyg "$WORK/z2/learned/run")" \
|
||||
PROXY_SUITE_ZAPRET2_VERDICTS="$(cyg "$WORK/z2/learned")/verdicts.tsv" PROXY_SUITE_PUBLIC_SUFFIXES="$(cyg "$X")/public_suffixes.txt" \
|
||||
WINEDEBUG=-all wine ./winws2.exe "@$(win "$WORK")winws2.conf" 2>&1) && grep -q "parameters verified" <<<"$out"; then
|
||||
echo "zapret2 ($kind, extended detection, upstream's Lua layers): verified by winws2.exe, $(grep -c -- '--lua-init' "$WORK/winws2.conf") Lua files, $(wc -l <"$WORK/winws2.conf") options"
|
||||
else
|
||||
fail=$((fail + 1)); echo "FAIL: zapret2 ($kind with the extras)"; grep -v -i cygwin <<<"$out" | tail -6
|
||||
fi
|
||||
done
|
||||
fi
|
||||
[ "$fail" = 0 ]
|
||||
Reference in new issue
Block a user