windows: the app's DPI bypass page
zapret on or off and its engine; for Flowseal's presets, the preset (the release's own list, matched as the service matches names) and game traffic; for zapret2, learning, IPv6 and the strategy log; the sites to handle besides the engine's lists and the sites to leave alone; TCP timestamps. News from the service replaces what the user has not changed, never what they are typing; a save shows the list as saved. ps-client: set_path for any one option, set_zapret_sites (tidied, deduplicated). gui-shot.sh takes ordered steps: click, type, key, wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d3ba00087d
commit
c9ce7a1982
6 files changed
+328
-11
No files matched your search
@@ -222,6 +222,39 @@ pub fn set_tg_ws_proxy_enabled(c: &mut Value, on: bool) {
|
||||
c["tgWsProxy"]["enable"] = on.into();
|
||||
}
|
||||
|
||||
/// Any option by its path, e.g. `["zapret", "zapret2", "ipv6"]`; the objects above it are
|
||||
/// made when missing.
|
||||
pub fn set_path(c: &mut Value, path: &[&str], value: Value) {
|
||||
let mut cur = c;
|
||||
for p in path {
|
||||
if !cur.is_object() {
|
||||
*cur = json!({});
|
||||
}
|
||||
cur = &mut cur[*p];
|
||||
}
|
||||
*cur = value;
|
||||
}
|
||||
|
||||
/// The sites an engine also handles and those it leaves alone: for `zapret-discord-youtube`
|
||||
/// beside its release's lists, for `zapret2` beside its strategies' own.
|
||||
pub fn set_zapret_sites(c: &mut Value, engine: &str, domains: &[String], exclude: &[String]) -> Result<()> {
|
||||
if !matches!(engine, "zapret-discord-youtube" | "zapret2") {
|
||||
bail!("the engine is zapret-discord-youtube or zapret2");
|
||||
}
|
||||
let clean = |list: &[String]| -> Vec<Value> {
|
||||
let mut out: Vec<Value> = Vec::new();
|
||||
for d in list.iter().map(|d| d.trim().trim_start_matches('.').to_lowercase()).filter(|d| !d.is_empty()) {
|
||||
if !out.contains(&Value::from(d.as_str())) {
|
||||
out.push(d.into());
|
||||
}
|
||||
}
|
||||
out
|
||||
};
|
||||
c["zapret"][engine]["domains"] = Value::Array(clean(domains));
|
||||
c["zapret"][engine]["excludeDomains"] = Value::Array(clean(exclude));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -265,6 +298,17 @@ mod tests {
|
||||
assert_eq!(c["proxy"]["routing"]["rules"][0]["disabled"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paths_and_site_lists() {
|
||||
let mut c = json!({ "zapret": null });
|
||||
set_path(&mut c, &["zapret", "zapret2", "ipv6"], true.into());
|
||||
assert_eq!(c["zapret"]["zapret2"]["ipv6"], true);
|
||||
set_zapret_sites(&mut c, "zapret2", &[" .Example.com".into(), "".into(), "example.com".into()], &["bank.example".into()]).unwrap();
|
||||
assert_eq!(c["zapret"]["zapret2"]["domains"], json!(["example.com"]));
|
||||
assert_eq!(c["zapret"]["zapret2"]["excludeDomains"], json!(["bank.example"]));
|
||||
assert!(set_zapret_sites(&mut c, "goodbyedpi", &[], &[]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zapret_settings_are_checked() {
|
||||
let mut c = json!({});
|
||||
|
||||
Reference in new issue
Block a user