feat: add fallback tunnel status check and improve Windows service command calls

Add fallback to tunnel_status when metrics query fails in current_metrics function, returning zero bytes with actual tunnel state. Update waitForTunnelStatus in frontend to use tunnel_status instead of tunnel_metrics for status polling and refresh metrics separately on success. Change CloseRequested window event handler to call app_handle().exit(0) instead of no-op. Replace "sc" with "sc.exe" in all Windows service command
This commit is contained in:
2026-03-18 09:53:46 +01:00
parent eff143d5b3
commit 3d70655cfa
3 changed files with 40 additions and 20 deletions

View File

@@ -479,7 +479,7 @@ fn connect_to_service() -> Result<TcpStream, String> {
#[cfg(target_os = "windows")]
fn start_windows_service() -> Result<(), String> {
let status = Command::new("sc")
let status = Command::new("sc.exe")
.arg("start")
.arg(SERVICE_NAME)
.creation_flags(CREATE_NO_WINDOW)
@@ -610,7 +610,7 @@ fn tunnel_service_is_active(profile: &Path) -> Result<bool, String> {
{
let tunnel_name = tunnel_name(profile)?;
let service_name = format!("WireGuardTunnel${}", tunnel_name);
let output = Command::new("sc")
let output = Command::new("sc.exe")
.arg("query")
.arg(&service_name)
.creation_flags(CREATE_NO_WINDOW)
@@ -659,7 +659,7 @@ fn describe_windows_tunnel_state(profile: &Path) -> String {
Err(err) => return err,
};
let service_name = format!("WireGuardTunnel${}", tunnel_name);
let output = Command::new("sc")
let output = Command::new("sc.exe")
.arg("query")
.arg(&service_name)
.creation_flags(CREATE_NO_WINDOW)