windows: zapret2's verdicts route the proxy; options kept to what they are
As upstream's direct-sync: from zapret2's lists and the detector's verdicts, two rule-sets sing-box reloads, rebuilt every ten seconds and before it starts: what zapret2 cannot fix (every strategy failed for a site, or an address leaves connections unanswered) through the proxy (zapret2.proxyFallback), after the explicit rules and autoProxy's; what it fixes direct, so it sees it (directSync), unless learned from transfers cut short. all-bypass and all-proxy as upstream. The options file winws2 reads (one a line) refuses an option holding a control character, which would read as more options than it is; and zapret2.ports.extraTcp/extraUdp, which join its options as written, are ports or ranges within 1-65535 (validated, and filtered again). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9eed225ccc
commit
514ffb97ca
10 files changed
+305
-27
No files matched your search
@@ -137,13 +137,8 @@ fn not_ported(cfg: &Config, v: &mut Issues) {
|
||||
if z.enable && z.engine == ZapretEngine::DiscordYoutube && z.discord_youtube.include_extra_upstream_lists {
|
||||
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.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.cutoff.enable {
|
||||
v.warn("zapret.zapret2.cutoff.enable", "the 16 KB cutoff probe is not on Windows yet");
|
||||
}
|
||||
if z.enable && z.engine == ZapretEngine::Zapret2 && 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 {
|
||||
v.warn("proxy.tun.enable", "TUN and zapret together: zapret's packets are not kept off the TUN on Windows yet; use one or the other");
|
||||
@@ -504,6 +499,26 @@ fn tunnels(cfg: &Config, v: &mut Issues) {
|
||||
|
||||
fn zapret(cfg: &Config, v: &mut Issues) {
|
||||
let z = &cfg.zapret;
|
||||
// They join winws2's options as written.
|
||||
let p = &z.zapret2.ports;
|
||||
for (path, values) in [("zapret.zapret2.ports.extraTcp", &p.extra_tcp), ("zapret.zapret2.ports.extraUdp", &p.extra_udp)] {
|
||||
for value in values {
|
||||
let text = match value {
|
||||
serde_json::Value::String(s) => s.clone(),
|
||||
other => other.to_string(),
|
||||
};
|
||||
if !crate::zapret2::port_spec_ok(text.trim()) {
|
||||
v.error(path, format!("'{text}' is not a port or a range (N, or N-M, within 1-65535)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (path, list) in [("zapret.zapret2.ports.tcp", &p.tcp), ("zapret.zapret2.ports.udp", &p.udp)] {
|
||||
if let Some(list) = list
|
||||
&& !list.split(',').all(|x| crate::zapret2::port_spec_ok(x.trim().replace(':', "-").as_str()))
|
||||
{
|
||||
v.error(path, "ports and ranges, comma-separated (N, or N-M, within 1-65535)");
|
||||
}
|
||||
}
|
||||
if !z.enable {
|
||||
return;
|
||||
}
|
||||
@@ -773,6 +788,16 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zapret2_extra_ports_are_ports() {
|
||||
let mut cfg = Config::default();
|
||||
cfg.zapret.zapret2.ports.extra_tcp = vec![serde_json::json!(8443), serde_json::json!("50000-50099"), serde_json::json!("443\n--lua-init=@x.lua")];
|
||||
cfg.zapret.zapret2.ports.udp = Some("443,590:600".into());
|
||||
let errs = errors(&cfg);
|
||||
assert_eq!(errs.iter().filter(|e| e.starts_with("zapret.zapret2.ports")).count(), 1, "{errs:?}");
|
||||
assert!(crate::zapret2::port_spec_ok("1-65535") && !crate::zapret2::port_spec_ok("0") && !crate::zapret2::port_spec_ok("9-1") && !crate::zapret2::port_spec_ok("443 x"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn whitelist_bypass_names_are_checked_while_it_is_off() {
|
||||
let mut cfg = Config::default();
|
||||
|
||||
Reference in new issue
Block a user