mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
refactor: update MitmServerCard and MitmToolCard to use modalError instead of message for error handling
- Replaced message state with modalError in both components for better error management. - Removed unused message display logic and adjusted action handling to improve clarity. - Enhanced error handling in doAction and doDnsAction functions to ignore errors gracefully. - Updated API call responses to streamline user feedback on actions.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { cleanupProviderConnections, getSettings, updateSettings, getApiKeys } from "@/lib/localDb";
|
||||
import { enableTunnel } from "@/lib/tunnel/tunnelManager";
|
||||
import { enableTunnel, isTunnelManuallyDisabled, isTunnelReconnecting } from "@/lib/tunnel/tunnelManager";
|
||||
import { killCloudflared, isCloudflaredRunning, ensureCloudflared } from "@/lib/tunnel/cloudflared";
|
||||
import { getMitmStatus, startMitm, loadEncryptedPassword, initDbHooks } from "@/mitm/manager";
|
||||
import { fileURLToPath } from "url";
|
||||
@@ -135,12 +135,20 @@ function startWatchdog() {
|
||||
if (g.watchdogInterval) return;
|
||||
g.watchdogInterval = setInterval(async () => {
|
||||
try {
|
||||
if (isTunnelManuallyDisabled()) return;
|
||||
if (isTunnelReconnecting()) return;
|
||||
if (g.tunnelRestartInProgress) return;
|
||||
const settings = await getSettings();
|
||||
if (!settings.tunnelEnabled) return;
|
||||
if (isCloudflaredRunning()) return;
|
||||
console.log("[Watchdog] Tunnel process is down, attempting recovery...");
|
||||
await enableTunnel();
|
||||
console.log("[Watchdog] Tunnel recovered");
|
||||
g.tunnelRestartInProgress = true;
|
||||
try {
|
||||
await enableTunnel();
|
||||
console.log("[Watchdog] Tunnel recovered");
|
||||
} finally {
|
||||
g.tunnelRestartInProgress = false;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("[Watchdog] Recovery failed:", err.message);
|
||||
}
|
||||
@@ -173,6 +181,7 @@ function startNetworkMonitor() {
|
||||
|
||||
g.networkMonitorInterval = setInterval(async () => {
|
||||
try {
|
||||
if (isTunnelManuallyDisabled()) return;
|
||||
const settings = await getSettings();
|
||||
if (!settings.tunnelEnabled) return;
|
||||
|
||||
@@ -190,6 +199,7 @@ function startNetworkMonitor() {
|
||||
|
||||
// Skip if restart already in progress or restarted recently
|
||||
if (g.tunnelRestartInProgress) return;
|
||||
if (isTunnelReconnecting()) return;
|
||||
if (now - g.lastTunnelRestartAt < NETWORK_RESTART_COOLDOWN_MS) return;
|
||||
|
||||
const reason = wasSleep && networkChanged ? "sleep/wake + network change"
|
||||
|
||||
Reference in New Issue
Block a user