fix: upgrade mihomo core failed (#5646)

* fix: upgrade mihomo core failed

* fix: upgrade core failed when run core by service

* fix: app freeze when restart core on windows

* deps: bump clash-verge-rev-ipc version lock

---------

Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
oomeow
2025-12-03 21:48:30 +08:00
committed by GitHub
parent 29cf57d4b9
commit 9388b73c1f
9 changed files with 40 additions and 61 deletions

55
Cargo.lock generated
View File

@@ -147,7 +147,7 @@ dependencies = [
"objc2-foundation 0.3.2",
"parking_lot",
"percent-encoding",
"windows-sys 0.60.2",
"windows-sys 0.59.0",
"wl-clipboard-rs",
"x11rb",
]
@@ -1315,8 +1315,8 @@ dependencies = [
[[package]]
name = "clash_verge_service_ipc"
version = "2.0.21"
source = "git+https://github.com/clash-verge-rev/clash-verge-service-ipc#da00a684c2b9723d647ed4992714eb669fcbd8a2"
version = "2.0.22"
source = "git+https://github.com/clash-verge-rev/clash-verge-service-ipc#8a89e05f2dd7660b4031e965bf0448ea84765cf1"
dependencies = [
"anyhow",
"compact_str",
@@ -1375,7 +1375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
dependencies = [
"lazy_static",
"windows-sys 0.59.0",
"windows-sys 0.48.0",
]
[[package]]
@@ -2083,7 +2083,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users 0.5.2",
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -2356,7 +2356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -3445,7 +3445,7 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"socket2 0.5.10",
"socket2 0.4.10",
"tokio",
"tower-service",
"tracing",
@@ -3556,7 +3556,7 @@ dependencies = [
"tokio",
"tower-service",
"tracing",
"windows-registry 0.6.1",
"windows-registry",
]
[[package]]
@@ -3884,7 +3884,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
dependencies = [
"hermit-abi 0.5.2",
"libc",
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -4684,7 +4684,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -5178,7 +5178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
dependencies = [
"libc",
"windows-sys 0.61.2",
"windows-sys 0.48.0",
]
[[package]]
@@ -6007,7 +6007,7 @@ dependencies = [
"once_cell",
"socket2 0.6.1",
"tracing",
"windows-sys 0.60.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -6570,7 +6570,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.11.0",
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -7188,16 +7188,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "socket2"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "socket2"
version = "0.6.1"
@@ -7733,7 +7723,7 @@ dependencies = [
"thiserror 2.0.17",
"tracing",
"url",
"windows-registry 0.5.3",
"windows-registry",
"windows-result 0.3.4",
]
@@ -7846,7 +7836,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-mihomo"
version = "0.1.1"
source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo#24586eb0721314f88e65460b4ac01933b3376d3c"
source = "git+https://github.com/clash-verge-rev/tauri-plugin-mihomo#85fc6b364227e69f5b1cfeb8ca82642c153b5210"
dependencies = [
"base64 0.22.1",
"futures-util",
@@ -8089,7 +8079,7 @@ dependencies = [
"getrandom 0.3.4",
"once_cell",
"rustix 1.1.2",
"windows-sys 0.61.2",
"windows-sys 0.59.0",
]
[[package]]
@@ -9487,7 +9477,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.48.0",
]
[[package]]
@@ -9667,17 +9657,6 @@ dependencies = [
"windows-strings 0.4.2",
]
[[package]]
name = "windows-registry"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"
dependencies = [
"windows-link 0.2.1",
"windows-result 0.4.1",
"windows-strings 0.5.1",
]
[[package]]
name = "windows-result"
version = "0.3.4"

View File

@@ -23,6 +23,7 @@
- 修复在搜索框输入不完整正则直接崩溃
- 修复创建窗口时在非简体中文环境或深色主题下的短暂闪烁
- 修复更新时加载进度条异常
- 升级内核失败导致内核不可用问题
<details>
<summary><strong> ✨ 新增功能 </strong></summary>

View File

@@ -93,7 +93,7 @@ tauri-plugin-devtools = { version = "2.0.1" }
tauri-plugin-mihomo = { git = "https://github.com/clash-verge-rev/tauri-plugin-mihomo" }
clash_verge_logger = { git = "https://github.com/clash-verge-rev/clash-verge-logger" }
async-trait = "0.1.89"
clash_verge_service_ipc = { version = "2.0.21", features = [
clash_verge_service_ipc = { version = "2.0.22", features = [
"client",
], git = "https://github.com/clash-verge-rev/clash-verge-service-ipc" }
arc-swap = "1.7.1"

View File

@@ -1,6 +1 @@
use std::sync::Arc;
use clash_verge_logger::AsyncLogger;
use once_cell::sync::Lazy;
pub static CLASH_LOGGER: Lazy<Arc<AsyncLogger>> = Lazy::new(|| Arc::new(AsyncLogger::new()));
// TODO: global logger to record verge log message

View File

@@ -2,10 +2,8 @@ use super::{CoreManager, RunningMode};
use crate::cmd::StringifyErr as _;
use crate::config::{Config, IVerge};
use crate::core::handle::Handle;
use crate::core::{
logger::CLASH_LOGGER,
service::{SERVICE_MANAGER, ServiceStatus},
};
use crate::core::manager::CLASH_LOGGER;
use crate::core::service::{SERVICE_MANAGER, ServiceStatus};
use anyhow::Result;
use clash_verge_logging::{Type, logging};
use scopeguard::defer;
@@ -44,11 +42,6 @@ impl CoreManager {
pub async fn restart_core(&self) -> Result<()> {
logging!(info, Type::Core, "Restarting core");
self.stop_core().await?;
if SERVICE_MANAGER.lock().await.init().await.is_ok() {
let _ = SERVICE_MANAGER.lock().await.refresh().await;
}
self.start_core().await
}

View File

@@ -4,11 +4,15 @@ mod state;
use anyhow::Result;
use arc_swap::{ArcSwap, ArcSwapOption};
use clash_verge_logger::AsyncLogger;
use once_cell::sync::Lazy;
use std::{fmt, sync::Arc, time::Instant};
use tauri_plugin_shell::process::CommandChild;
use crate::singleton;
pub(crate) static CLASH_LOGGER: Lazy<Arc<AsyncLogger>> = Lazy::new(|| Arc::new(AsyncLogger::new()));
#[derive(Debug, serde::Serialize, PartialEq, Eq)]
pub enum RunningMode {
Service,

View File

@@ -1,8 +1,8 @@
use super::{CoreManager, RunningMode};
use crate::{
AsyncHandler,
config::Config,
core::{handle, logger::CLASH_LOGGER, service},
config::{Config, IClashTemp},
core::{handle, manager::CLASH_LOGGER, service},
logging,
utils::{dirs, init::sidecar_writer},
};
@@ -39,6 +39,12 @@ impl CoreManager {
dirs::path_to_str(&config_dir)?,
"-f",
dirs::path_to_str(&config_file)?,
if cfg!(windows) {
"-ext-ctl-pipe"
} else {
"-ext-ctl-unix"
},
&IClashTemp::guard_external_controller_ipc(),
])
.spawn()?;

View File

@@ -1,5 +1,5 @@
use crate::{
config::Config,
config::{Config, IClashTemp},
core::tray,
utils::{dirs, init::service_writer_config},
};
@@ -405,6 +405,7 @@ pub(super) async fn start_with_existing_service(config_file: &PathBuf) -> Result
core_config: CoreConfig {
config_path: dirs::path_to_str(config_file)?.into(),
core_path: dirs::path_to_str(&bin_path)?.into(),
core_ipc_path: IClashTemp::guard_external_controller_ipc(),
config_dir: dirs::path_to_str(&dirs::app_home_dir()?)?.into(),
},
log_config: service_writer_config().await?,

View File

@@ -635,13 +635,13 @@ fn create_subcreate_proxy_menu_item(
proxy_mode: &str,
current_profile_selected: &[PrfSelected],
proxy_group_order_map: Option<HashMap<String, usize>>,
proxy_nodes_data: Result<Proxies>,
proxy_nodes_data: Option<Proxies>,
) -> Vec<Submenu<Wry>> {
let proxy_submenus: Vec<Submenu<Wry>> = {
let mut submenus: Vec<(String, usize, Submenu<Wry>)> = Vec::new();
// TODO: 应用启动时,内核还未启动完全,无法获取代理节点信息
if let Ok(proxy_nodes_data) = proxy_nodes_data {
if let Some(proxy_nodes_data) = proxy_nodes_data {
for (group_name, group_data) in proxy_nodes_data.proxies.iter() {
// Filter groups based on mode
let should_show = match proxy_mode {
@@ -827,7 +827,7 @@ async fn create_tray_menu(
.unwrap_or_default()
};
let proxy_nodes_data = handle::Handle::mihomo().await.get_proxies().await;
let proxy_nodes_data = handle::Handle::mihomo().await.get_proxies().await.ok();
let runtime_proxy_groups_order = cmd::get_runtime_config()
.await
@@ -950,7 +950,7 @@ async fn create_tray_menu(
current_proxy_mode,
&current_profile_selected,
proxy_group_order_map,
proxy_nodes_data.map_err(anyhow::Error::from),
proxy_nodes_data,
);
let (proxies_menu, inline_proxy_items) = create_proxy_menu_item(