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

@@ -88,7 +88,14 @@ export function App() {
setMetrics(value);
setConnected(value.active);
} catch {
setMetrics({ active: false, rxBytes: 0, txBytes: 0 });
try {
const active = await invoke<boolean>("tunnel_status");
setConnected(active);
setMetrics((current) => ({ ...current, active }));
} catch {
setMetrics({ active: false, rxBytes: 0, txBytes: 0 });
setConnected(false);
}
}
}
@@ -122,15 +129,16 @@ export function App() {
async function waitForTunnelStatus(expected: boolean) {
for (let attempt = 0; attempt < 8; attempt += 1) {
try {
const value = await invoke<TunnelMetrics>("tunnel_metrics");
setMetrics(value);
setConnected(value.active);
if (value.active === expected) {
return value.active;
const active = await invoke<boolean>("tunnel_status");
setConnected(active);
if (active === expected) {
await refreshTunnelMetrics();
return active;
}
} catch {
if (!expected) {
setMetrics({ active: false, rxBytes: 0, txBytes: 0 });
setConnected(false);
return false;
}
}
@@ -138,11 +146,11 @@ export function App() {
await new Promise((resolve) => window.setTimeout(resolve, 500));
}
return invoke<TunnelMetrics>("tunnel_metrics")
.then((value) => {
setMetrics(value);
setConnected(value.active);
return value.active;
return invoke<boolean>("tunnel_status")
.then(async (active) => {
setConnected(active);
await refreshTunnelMetrics();
return active;
})
.catch(() => false);
}