//! For tools/winws-dry-run.sh: winws2's arguments as the service builds them, one per line. //! `zapret2_args //! [ keenetic|z2k]` use ps_core::config::{StrategySource, Zapret2}; use ps_core::zapret2::{Extras, Paths, args, keenetic, z2k}; fn main() { let a: Vec = 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 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, }; for arg in args(&z, &source, &paths, false).unwrap() { println!("{arg}"); } }