- hostlistRules (zapret-discord-youtube): a group of sites with its own strategy, as upstream's patch-zapret-config.py makes them: the preset's profiles for the rule's family (or another preset's, with configName; Discord's voice profile with it), pointed at the rule's own list with the standard excludes, or the rule's nfqwsArgs; ahead of the preset's own. WinDivert's filter takes the ports they add. Rules with enableDirectSync join the direct list. Names of zapret's own lists, and the instagram/soundcloud/twitter families (not in Flowseal's Windows release), are refused. Every preset with sample rules checked by winws.exe --dry-run (tools/winws-dry-run.sh); one without the profile a rule copies is refused, as upstream refuses it. - The SSH tunnel (sshProxy): Windows' own OpenSSH (System32) as ssh -N -D, with upstream's options and only the configured key offered (IdentitiesOnly: an agent's keys used up the server's tries); the key copied below the protected state root, as Windows' OpenSSH wants it and sing-box's SSH outbound reads it; the server's keys from hostKey, hostKeyFile or knownHostsFile. End to end on Linux against an sshd of the test's own: a page through each, two logins with the copied key. - The dev shell has OpenSSH, for that test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.5 KiB
Rust
48 lines
2.5 KiB
Rust
//! For tools/winws-dry-run.sh: a preset's winws arguments as the service builds them, one
|
|
//! per line. `zapret_args <release dir> <release dir as Windows sees it> <lists dir as Windows
|
|
//! sees it> <preset> <game filter> [<hostlistRules JSON> <lists dir>]`, Windows paths with a
|
|
//! trailing separator. With rules, their lists are written into the lists dir.
|
|
|
|
use ps_core::config::{GameFilter, HostlistRule};
|
|
use ps_core::zapret::{ReleaseLists, expand, find_preset, preset_args, rule, rule_lists, with_rules};
|
|
|
|
fn main() {
|
|
let a: Vec<String> = std::env::args().collect();
|
|
let (release, win_root, win_lists, preset, game) = (&a[1], &a[2], &a[3], &a[4], &a[5]);
|
|
let release = std::path::Path::new(release);
|
|
let files: Vec<String> = std::fs::read_dir(release).unwrap().filter_map(|e| e.ok()?.file_name().into_string().ok()).collect();
|
|
let game: GameFilter = serde_json::from_value(serde_json::json!(game)).unwrap();
|
|
let bin = format!("{win_root}bin\\");
|
|
let ex = |args: &[String]| expand(args, &bin, win_lists, win_root, game);
|
|
let args_of = |name: &str| -> Result<Vec<String>, String> {
|
|
let file = find_preset(&files, name)?;
|
|
Ok(ex(&preset_args(&std::fs::read_to_string(release.join(file)).unwrap())?))
|
|
};
|
|
let mut args = args_of(preset).unwrap();
|
|
if let (Some(json), Some(lists)) = (a.get(6), a.get(7)) {
|
|
let read = |f: &str| std::fs::read_to_string(release.join("lists").join(f)).unwrap_or_default();
|
|
let (general, google, ipset_all) = (read("list-general.txt"), read("list-google.txt"), read("ipset-all.txt"));
|
|
let release_lists = ReleaseLists { general: &general, google: &google, ipset_all: &ipset_all };
|
|
let raw: Vec<HostlistRule> = serde_json::from_str(&std::fs::read_to_string(json).unwrap()).unwrap();
|
|
let rules: Vec<_> = raw.iter().map(|r| rule(r, &release_lists).unwrap()).collect();
|
|
for r in &rules {
|
|
let (list, ipset) = rule_lists(r);
|
|
for (file, entries) in [(list, &r.domains), (ipset, &r.ips)] {
|
|
if !entries.is_empty() {
|
|
std::fs::write(std::path::Path::new(lists).join(file), format!("{}\n", entries.join("\n"))).unwrap();
|
|
}
|
|
}
|
|
}
|
|
args = match with_rules(args, &rules, win_lists, &args_of, &ex) {
|
|
Ok(a) => a,
|
|
Err(e) => {
|
|
eprintln!("{e}");
|
|
std::process::exit(2);
|
|
}
|
|
};
|
|
}
|
|
for arg in args {
|
|
println!("{arg}");
|
|
}
|
|
}
|