mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
feat: add UWP loopback tools
This commit is contained in:
@@ -229,6 +229,18 @@ pub fn open_web_url(url: String) -> CmdResult<()> {
|
||||
wrap_err!(open::that(url))
|
||||
}
|
||||
|
||||
|
||||
#[cfg(windows)]
|
||||
pub mod uwp {
|
||||
use super::*;
|
||||
use crate::core::win_uwp;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn invoke_uwp_tool() -> CmdResult {
|
||||
wrap_err!(win_uwp::invoke_uwptools().await)
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn clash_api_get_proxy_delay(
|
||||
name: String,
|
||||
@@ -278,3 +290,13 @@ pub mod service {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub mod uwp {
|
||||
use super::*;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn invoke_uwp_tool() -> CmdResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,6 @@ pub mod sysopt;
|
||||
pub mod timer;
|
||||
pub mod tray;
|
||||
pub mod win_service;
|
||||
pub mod win_uwp;
|
||||
|
||||
pub use self::core::*;
|
||||
|
||||
27
src-tauri/src/core/win_uwp.rs
Normal file
27
src-tauri/src/core/win_uwp.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
#![cfg(target_os = "windows")]
|
||||
|
||||
use crate::utils::dirs;
|
||||
use anyhow::{bail, Result};
|
||||
use deelevate::{PrivilegeLevel, Token};
|
||||
use runas::Command as RunasCommand;
|
||||
use std::process::Command as StdCommand;
|
||||
|
||||
pub async fn invoke_uwptools() -> Result<()> {
|
||||
let binary_path = dirs::service_path()?;
|
||||
let tool_path = binary_path.with_file_name("enableLoopback.exe");
|
||||
|
||||
if !tool_path.exists() {
|
||||
bail!("enableLoopback exe not found");
|
||||
}
|
||||
|
||||
let token = Token::with_current_process()?;
|
||||
let level = token.privilege_level()?;
|
||||
|
||||
match level {
|
||||
PrivilegeLevel::NotPrivileged => RunasCommand::new(tool_path).status()?,
|
||||
_ => StdCommand::new(tool_path)
|
||||
.status()?,
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -46,6 +46,7 @@ fn main() -> std::io::Result<()> {
|
||||
cmds::get_runtime_yaml,
|
||||
cmds::get_runtime_exists,
|
||||
cmds::get_runtime_logs,
|
||||
cmds::uwp::invoke_uwp_tool,
|
||||
// verge
|
||||
cmds::get_verge_config,
|
||||
cmds::patch_verge_config,
|
||||
|
||||
Reference in New Issue
Block a user