Refine proxy routing and UI state handling

This commit is contained in:
2026-07-08 12:41:12 +03:00
parent 6439dbfeaa
commit ae13070eba
9 changed files with 1100 additions and 558 deletions

View File

@@ -55,7 +55,8 @@ noise
#[test]
fn safe_install_dir_allows_only_proxywarden_singbox_folder() {
assert!(
ensure_safe_singbox_install_dir(Path::new(r"C:\Program Files\ProxyWarden\sing-box")).is_ok()
ensure_safe_singbox_install_dir(Path::new(r"C:\Program Files\ProxyWarden\sing-box"))
.is_ok()
);
assert!(ensure_safe_singbox_install_dir(Path::new(r"C:\Windows")).is_err());
assert!(ensure_safe_singbox_install_dir(Path::new(r"C:\Program Files\sing-box")).is_err());
@@ -63,7 +64,12 @@ fn safe_install_dir_allows_only_proxywarden_singbox_folder() {
#[test]
fn service_control_script_targets_named_service_and_action() {
let script = service_control_script(SingBoxServiceAction::Start, "ProxyWardenSingBox", None, None);
let script = service_control_script(
SingBoxServiceAction::Start,
"ProxyWardenSingBox",
None,
None,
);
assert!(script.contains("$serviceName = 'ProxyWardenSingBox'"));
assert!(script.contains("$action = 'start'"));
@@ -84,9 +90,9 @@ fn service_control_script_syncs_generated_config_before_start() {
assert!(script.contains(
"$configSource = 'C:\\ProgramData\\ProxyWarden\\generated\\sing-box-config.json'"
));
assert!(script.contains(
"$configTarget = 'C:\\Program Files\\ProxyWarden\\sing-box\\config.json'"
));
assert!(
script.contains("$configTarget = 'C:\\Program Files\\ProxyWarden\\sing-box\\config.json'")
);
assert!(script.contains("Copy-Item -LiteralPath $configSource"));
assert!(script.contains("'config_sync_failed'"));
}
@@ -119,7 +125,9 @@ fn detected_singbox(binary_exists: bool, wrapper_exists: bool, running: bool) ->
DetectedSingBox {
install_dir: PathBuf::from(r"C:\Program Files\ProxyWarden\sing-box"),
executable_path: PathBuf::from(r"C:\Program Files\ProxyWarden\sing-box\sing-box.exe"),
wrapper_path: PathBuf::from(r"C:\Program Files\ProxyWarden\sing-box\ProxyWardenSingBox.exe"),
wrapper_path: PathBuf::from(
r"C:\Program Files\ProxyWarden\sing-box\ProxyWardenSingBox.exe",
),
binary_exists,
wrapper_exists,
running,