mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
feat: add UWP loopback tools
This commit is contained in:
parent
7ec251ea6d
commit
caa82ad1e6
|
@ -325,6 +325,11 @@ const resolveGeoIP = () =>
|
||||||
file: "geoip.dat",
|
file: "geoip.dat",
|
||||||
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat`,
|
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat`,
|
||||||
});
|
});
|
||||||
|
const resolveEnableLoopback = () =>
|
||||||
|
resolveResource({
|
||||||
|
file: "enableLoopback.exe",
|
||||||
|
downloadURL: `https://github.com/Kuingsmile/uwp-tool/releases/download/latest/enableLoopback.exe`,
|
||||||
|
});
|
||||||
|
|
||||||
const tasks = [
|
const tasks = [
|
||||||
// { name: "clash", func: resolveClash, retry: 5 },
|
// { name: "clash", func: resolveClash, retry: 5 },
|
||||||
|
@ -336,6 +341,12 @@ const tasks = [
|
||||||
{ name: "mmdb", func: resolveMmdb, retry: 5 },
|
{ name: "mmdb", func: resolveMmdb, retry: 5 },
|
||||||
{ name: "geosite", func: resolveGeosite, retry: 5 },
|
{ name: "geosite", func: resolveGeosite, retry: 5 },
|
||||||
{ name: "geoip", func: resolveGeoIP, retry: 5 },
|
{ name: "geoip", func: resolveGeoIP, retry: 5 },
|
||||||
|
{
|
||||||
|
name: "enableLoopback",
|
||||||
|
func: resolveEnableLoopback,
|
||||||
|
retry: 5,
|
||||||
|
winOnly: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
async function runTask() {
|
async function runTask() {
|
||||||
|
|
|
@ -229,6 +229,18 @@ pub fn open_web_url(url: String) -> CmdResult<()> {
|
||||||
wrap_err!(open::that(url))
|
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]
|
#[tauri::command]
|
||||||
pub async fn clash_api_get_proxy_delay(
|
pub async fn clash_api_get_proxy_delay(
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -278,3 +290,13 @@ pub mod service {
|
||||||
Ok(())
|
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 timer;
|
||||||
pub mod tray;
|
pub mod tray;
|
||||||
pub mod win_service;
|
pub mod win_service;
|
||||||
|
pub mod win_uwp;
|
||||||
|
|
||||||
pub use self::core::*;
|
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_yaml,
|
||||||
cmds::get_runtime_exists,
|
cmds::get_runtime_exists,
|
||||||
cmds::get_runtime_logs,
|
cmds::get_runtime_logs,
|
||||||
|
cmds::uwp::invoke_uwp_tool,
|
||||||
// verge
|
// verge
|
||||||
cmds::get_verge_config,
|
cmds::get_verge_config,
|
||||||
cmds::patch_verge_config,
|
cmds::patch_verge_config,
|
||||||
|
|
|
@ -18,6 +18,10 @@ import { ClashPortViewer } from "./mods/clash-port-viewer";
|
||||||
import { ControllerViewer } from "./mods/controller-viewer";
|
import { ControllerViewer } from "./mods/controller-viewer";
|
||||||
import { SettingList, SettingItem } from "./mods/setting-comp";
|
import { SettingList, SettingItem } from "./mods/setting-comp";
|
||||||
import { ClashCoreViewer } from "./mods/clash-core-viewer";
|
import { ClashCoreViewer } from "./mods/clash-core-viewer";
|
||||||
|
import { invoke_uwp_tool } from "@/services/cmds";
|
||||||
|
import getSystem from "@/utils/get-system";
|
||||||
|
|
||||||
|
const isWIN = getSystem() === "windows";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onError: (err: Error) => void;
|
onError: (err: Error) => void;
|
||||||
|
@ -162,6 +166,19 @@ const SettingClash = ({ onError }: Props) => {
|
||||||
>
|
>
|
||||||
<Typography sx={{ py: "7px", pr: 1 }}>{version}</Typography>
|
<Typography sx={{ py: "7px", pr: 1 }}>{version}</Typography>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
|
{isWIN && (
|
||||||
|
<SettingItem label={t("Open UWP tool")}>
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
sx={{ my: "2px" }}
|
||||||
|
onClick={invoke_uwp_tool}
|
||||||
|
>
|
||||||
|
<ArrowForward />
|
||||||
|
</IconButton>
|
||||||
|
</SettingItem>
|
||||||
|
)}
|
||||||
</SettingList>
|
</SettingList>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
"Silent Start": "Silent Start",
|
"Silent Start": "Silent Start",
|
||||||
"System Proxy": "System Proxy",
|
"System Proxy": "System Proxy",
|
||||||
"System Proxy Setting": "System Proxy Setting",
|
"System Proxy Setting": "System Proxy Setting",
|
||||||
|
"Open UWP tool": "Open UWP tool",
|
||||||
"Proxy Guard": "Proxy Guard",
|
"Proxy Guard": "Proxy Guard",
|
||||||
"Guard Duration": "Guard Duration",
|
"Guard Duration": "Guard Duration",
|
||||||
"Proxy Bypass": "Proxy Bypass",
|
"Proxy Bypass": "Proxy Bypass",
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
"Silent Start": "Тихий запуск",
|
"Silent Start": "Тихий запуск",
|
||||||
"System Proxy": "Системный прокси",
|
"System Proxy": "Системный прокси",
|
||||||
"System Proxy Setting": "Настройка системного прокси",
|
"System Proxy Setting": "Настройка системного прокси",
|
||||||
|
"Open UWP tool": "Открыть UWP инструмент",
|
||||||
"Proxy Guard": "Защита прокси",
|
"Proxy Guard": "Защита прокси",
|
||||||
"Guard Duration": "Период защиты",
|
"Guard Duration": "Период защиты",
|
||||||
"Proxy Bypass": "Игнорирование прокси",
|
"Proxy Bypass": "Игнорирование прокси",
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
"Silent Start": "静默启动",
|
"Silent Start": "静默启动",
|
||||||
"System Proxy": "系统代理",
|
"System Proxy": "系统代理",
|
||||||
"System Proxy Setting": "系统代理设置",
|
"System Proxy Setting": "系统代理设置",
|
||||||
|
"Open UWP tool": "UWP工具",
|
||||||
"Proxy Guard": "系统代理守卫",
|
"Proxy Guard": "系统代理守卫",
|
||||||
"Guard Duration": "代理守卫间隔",
|
"Guard Duration": "代理守卫间隔",
|
||||||
"Proxy Bypass": "代理绕过",
|
"Proxy Bypass": "代理绕过",
|
||||||
|
|
|
@ -178,3 +178,9 @@ export async function installService() {
|
||||||
export async function uninstallService() {
|
export async function uninstallService() {
|
||||||
return invoke<void>("uninstall_service");
|
return invoke<void>("uninstall_service");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function invoke_uwp_tool() {
|
||||||
|
return invoke<void>("invoke_uwp_tool").catch((err) =>
|
||||||
|
Notice.error(err?.message || err.toString(), 1500)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user