windows: the app's whitelist-bypass page, and its icon
A page for whitelist-bypass: on or off; joiners with their state and the call link to join; creators with theirs, their call link to copy, a new call, and their login (a cookies export picked from disk, or DION's and Bitrix's email and password); adding and removing either. The app carries an icon now (tools/make-icon.py draws it; llvm-rc makes it the exe's resource 1, where GPUI, Explorer and the Start Menu take it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6e54f963d
commit
ae31e499ca
8 files changed
+524
-4
No files matched your search
@@ -235,6 +235,39 @@ pub fn set_path(c: &mut Value, path: &[&str], value: Value) {
|
||||
*cur = value;
|
||||
}
|
||||
|
||||
/// whitelist-bypass's platforms, as its options name them.
|
||||
pub const WL_PLATFORMS: [&str; 5] = ["wbstream", "telemost", "dion", "bitrix", "vk"];
|
||||
|
||||
/// A whitelist-bypass joiner or creator (`role`: "joiners" or "creators") on `platform`. A name
|
||||
/// is one of either: `proxy-ctl wl` takes them by name alone.
|
||||
pub fn add_wl(c: &mut Value, role: &str, name: &str, platform: &str) -> Result<()> {
|
||||
if !matches!(role, "joiners" | "creators") {
|
||||
bail!("a whitelist-bypass role is joiners or creators");
|
||||
}
|
||||
if !ps_core::config::path_name_ok(name) {
|
||||
bail!("a name takes letters, digits, '.', '_' and '-', and no leading dot");
|
||||
}
|
||||
if !WL_PLATFORMS.contains(&platform) {
|
||||
bail!("no platform '{platform}': {}", WL_PLATFORMS.join(", "));
|
||||
}
|
||||
if role == "joiners" && platform == "vk" {
|
||||
bail!("VK has no joiner, only creators");
|
||||
}
|
||||
let wl = &c["whitelistBypass"];
|
||||
if wl["joiners"].get(name).is_some() || wl["creators"].get(name).is_some() {
|
||||
bail!("'{name}' is taken");
|
||||
}
|
||||
set_path(c, &["whitelistBypass", role, name], json!({ "platform": platform }));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn remove_wl(c: &mut Value, role: &str, name: &str) -> Result<()> {
|
||||
match c.get_mut("whitelistBypass").and_then(|w| w.get_mut(role)).and_then(Value::as_object_mut).and_then(|o| o.remove(name)) {
|
||||
Some(_) => Ok(()),
|
||||
None => bail!("no whitelist-bypass {} '{name}'", role.trim_end_matches('s')),
|
||||
}
|
||||
}
|
||||
|
||||
/// 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<()> {
|
||||
@@ -259,6 +292,22 @@ pub fn set_zapret_sites(c: &mut Value, engine: &str, domains: &[String], exclude
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn whitelist_bypass_entries_are_added_once_and_removed() {
|
||||
let mut c = json!({});
|
||||
add_wl(&mut c, "joiners", "wl", "wbstream").unwrap();
|
||||
add_wl(&mut c, "creators", "laptop", "vk").unwrap();
|
||||
assert_eq!(c["whitelistBypass"]["joiners"]["wl"], json!({ "platform": "wbstream" }));
|
||||
assert!(add_wl(&mut c, "creators", "wl", "dion").is_err(), "a name is one of either");
|
||||
assert!(add_wl(&mut c, "joiners", "phone", "vk").is_err(), "VK has no joiner");
|
||||
assert!(add_wl(&mut c, "joiners", "phone", "zoom").is_err());
|
||||
assert!(add_wl(&mut c, "joiners", "../x", "wbstream").is_err());
|
||||
assert!(add_wl(&mut c, "joiners", "CON", "wbstream").is_err());
|
||||
remove_wl(&mut c, "joiners", "wl").unwrap();
|
||||
assert!(remove_wl(&mut c, "joiners", "wl").is_err());
|
||||
assert_eq!(c["whitelistBypass"]["creators"]["laptop"]["platform"], "vk");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn outbounds_are_added_once_and_removed() {
|
||||
let mut c = json!({});
|
||||
|
||||
Reference in new issue
Block a user