fix(tun): fall back to sidecar when service is absent

This commit is contained in:
wonfen
2026-08-18 11:05:53 +08:00
parent 4c1804baf4
commit 9fa0e91e25
4 changed files with 105 additions and 88 deletions
+3 -9
View File
@@ -31,7 +31,6 @@ pub fn init_work_dir_and_logger() -> anyhow::Result<()> {
AsyncHandler::block_on(async {
init_work_config().await;
logging!(info, Type::Setup, "Initializing logger");
// #[cfg(not(feature = "tokio-trace"))]
Logger::global().init().await?;
Ok(())
})
@@ -48,8 +47,7 @@ pub fn resolve_setup_async() {
AsyncHandler::spawn(|| async {
logging!(info, Type::ClashVergeRev, "Version: {}", env!("CARGO_PKG_VERSION"));
// Ahead of the window and init_timer: anything saved or deep-link-imported after the app
// is up is a deliberate choice. Config files already exist (init_work_dir_and_logger).
// Migrate before windows or timers can change the loaded config.
logging_error!(Type::Setup, init::migrate_short_update_intervals().await);
#[cfg(target_os = "macos")]
@@ -58,6 +56,7 @@ pub fn resolve_setup_async() {
init_service_manager().await;
let config_initialized = init_verge_config_before_window().await;
init_window().await;
feat::reconcile_startup_tun_availability().await;
init_resources().await;
if let Err(e) = init::init_dns_config().await {
logging!(warn, Type::Setup, "DNS config initialization failed: {}", e);
@@ -125,7 +124,6 @@ pub(super) async fn init_timer() {
}
pub(super) async fn init_hotkey() {
// if hotkey is not use by global, skip init it
let skip_register_hotkeys = !Config::verge().await.latest_arc().enable_global_hotkey.unwrap_or(true);
logging_error!(Type::Setup, Hotkey::global().init(skip_register_hotkeys).await);
}
@@ -146,16 +144,12 @@ async fn init_silent_updater() {
let app_handle = Handle::app_handle();
// Check for cached update and attempt install before main app initialization.
// If install succeeds:
// - Windows: NSIS takes over and the process exits automatically
// - macOS/Linux: binary is replaced, we restart the app
// Install cached updates before starting background checks.
if SilentUpdater::global().try_install_on_startup(app_handle).await {
logging!(info, Type::Setup, "Update installed at startup, restarting...");
feat::restart_app().await;
}
// No pending install — start background check/download loop
let app_handle = app_handle.clone();
tokio::spawn(async move {
SilentUpdater::global().start_background_check(app_handle).await;