mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 07:03:45 +08:00
perf: Disable Tun mode before shutting down
This commit is contained in:
parent
8092e5c3a8
commit
9731c8a750
@ -37,7 +37,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
reqwest = { version = "0.12", features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.12", features = ["json", "rustls-tls"] }
|
||||||
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
||||||
auto-launch = { git="https://github.com/zzzgydi/auto-launch", branch = "main" }
|
auto-launch = { git="https://github.com/zzzgydi/auto-launch", branch = "main" }
|
||||||
tauri = { version = "1.6", features = [ "fs-read-file", "fs-exists", "path-all", "protocol-asset", "dialog-open", "notification-all", "icon-png", "icon-ico", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all", "devtools"] }
|
tauri = { version = "1.6", features = [ "http-all", "fs-read-file", "fs-exists", "path-all", "protocol-asset", "dialog-open", "notification-all", "icon-png", "icon-ico", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all", "devtools"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
runas = "=1.2.0"
|
runas = "=1.2.0"
|
||||||
|
@ -5,6 +5,7 @@ use crate::{config::*, utils::dirs};
|
|||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use serde_yaml::Mapping;
|
||||||
use std::{fs, io::Write, sync::Arc, time::Duration};
|
use std::{fs, io::Write, sync::Arc, time::Duration};
|
||||||
use sysinfo::{Pid, System};
|
use sysinfo::{Pid, System};
|
||||||
use tauri::api::process::{Command, CommandChild, CommandEvent};
|
use tauri::api::process::{Command, CommandChild, CommandEvent};
|
||||||
@ -232,6 +233,16 @@ impl CoreManager {
|
|||||||
|
|
||||||
/// 停止核心运行
|
/// 停止核心运行
|
||||||
pub fn stop_core(&self) -> Result<()> {
|
pub fn stop_core(&self) -> Result<()> {
|
||||||
|
// 关闭tun模式
|
||||||
|
tauri::async_runtime::block_on(async move {
|
||||||
|
let mut disable = Mapping::new();
|
||||||
|
let mut tun = Mapping::new();
|
||||||
|
tun.insert("enable".into(), false.into());
|
||||||
|
disable.insert("tun".into(), tun.into());
|
||||||
|
log::debug!(target: "app", "disable tun mode");
|
||||||
|
let _ = clash_api::patch_configs(&disable).await;
|
||||||
|
});
|
||||||
|
|
||||||
if *self.use_service_mode.lock() {
|
if *self.use_service_mode.lock() {
|
||||||
log::debug!(target: "app", "stop the core by service");
|
log::debug!(target: "app", "stop the core by service");
|
||||||
tauri::async_runtime::block_on(async move {
|
tauri::async_runtime::block_on(async move {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user