Compare commits

...
22 Commits
Author SHA1 Message Date
wonfen 7d2b18759e Release 1.7.7 2024-08-22 03:47:33 +08:00
wonfen aa8f6f4ad6 chore: Shorten text to prevent Windows tooltip truncation. 2024-08-22 03:41:16 +08:00
wonfen 592167ffb7 fix: profiles will not be selected after import 2024-08-22 00:57:04 +08:00
wonfen 12a6bfad00 Release 1.7.6 2024-08-18 00:49:23 +08:00
tony-sung 1ea3b956ad Update web-ui-viewer.tsx Fix yacd parameter hostname error (#1484) 2024-08-18 00:23:24 +08:00
MystiPanda 1b7dafe743 feat: auto select profile 2024-07-30 09:06:12 +08:00
MystiPanda 624eb2a2ba chore: prepend new added rules 2024-07-24 14:25:06 +08:00
MystiPanda 88d98517c8 fix: wrap the password in quotes
#1460
2024-07-24 14:22:23 +08:00
Avan 9528606906 style: AddressDisplay padding (#1457) 2024-07-23 22:17:51 +08:00
nhsmw 09b44a3af3 fix: update test url 2024-07-19 10:32:41 +08:00
MystiPanda dc861eca7d chore: remove unnecessary console log 2024-07-18 23:37:54 +08:00
MystiPanda e749fe70e2 fix: use group testUrl
#1384
2024-07-18 15:04:55 +08:00
MystiPanda d20c082deb fix: windows x86 updater url 2024-07-18 14:38:31 +08:00
MystiPanda c4abc3ade3 fix: error command status 2024-07-16 18:37:56 +08:00
MystiPanda ff28aab56e fix: MacOS service install error 2024-07-16 13:01:27 +08:00
MystiPanda 1a6f842492 fix(#1335): support cidr 2024-07-16 12:22:11 +08:00
MystiPanda af0cd4a342 fix: try to fix install service 2024-07-16 12:07:23 +08:00
MystiPanda d98b3224cf chore: disable okBtn 2024-07-15 23:38:49 +08:00
MystiPanda f2e5f0754c ci: fix winget uploader 2024-07-15 23:27:38 +08:00
MystiPanda ec1601f317 Release 1.7.5 2024-07-15 22:35:33 +08:00
MystiPanda 54116608dc ci: fix winget uploader 2024-07-15 22:33:57 +08:00
MystiPanda fea6735ea1 fix: copy necessary files 2024-07-15 22:25:04 +08:00
33 changed files with 339 additions and 145 deletions
+13 -2
View File
@@ -258,12 +258,23 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
submit-to-winget: submit-to-winget:
runs-on: windows-latest runs-on: ubuntu-latest
needs: [release-update] needs: [release-update]
steps: steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Version
run: |
sudo apt-get update
sudo apt-get install jq
echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
- name: Submit to Winget - name: Submit to Winget
uses: vedantmgoyal9/winget-releaser@main uses: vedantmgoyal9/winget-releaser@main
with: with:
identifier: ClashVergeRev.ClashVergeRev identifier: ClashVergeRev.ClashVergeRev
version: ${{env.VERSION}}
release-tag: v${{env.VERSION}}
installers-regex: '_(arm64|x64|x86)-setup\.exe$' installers-regex: '_(arm64|x64|x86)-setup\.exe$'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.WINGET_TOKEN }}
+34 -1
View File
@@ -1,4 +1,37 @@
## v1.7.4 ## v1.7.7
### Bugs Fixes
- 修复导入订阅没有自动重载(不显示节点)的问题
- 英语状态下修复 Windows 工具栏提示文本超过限制的问题
---
## v1.7.6
### Notice
- Clash Verge Rev 目前已进入稳定周期,日后更新将着重于 bug 修复与内核常规升级
### Features
- Meta(mihomo)内核升级 1.18.7
- 界面细节调整
- 优化服务模式安装逻辑
- 移除无用的 console log
- 能自动选择第一个订阅
### Bugs Fixes
- 修复服务模式安装问题
- 修复 Mac 下的代理绕过 CIDR 写法过滤
- 修复 32 位升级 URL
- 修复不同分组 URL 测试地址配置无效的问题
- 修复 Web UI 下的一处 hostname 参数
---
## v1.7.5
### Features ### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "clash-verge", "name": "clash-verge",
"version": "1.7.4", "version": "1.7.7",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {
"dev": "tauri dev", "dev": "tauri dev",
+2 -2
View File
@@ -72,12 +72,12 @@ async function resolveUpdater() {
} }
// win32 url // win32 url
if (name.endsWith("x64-setup.nsis.zip")) { if (name.endsWith("x86-setup.nsis.zip")) {
updateData.platforms["windows-x86"].url = browser_download_url; updateData.platforms["windows-x86"].url = browser_download_url;
updateData.platforms["windows-i686"].url = browser_download_url; updateData.platforms["windows-i686"].url = browser_download_url;
} }
// win32 signature // win32 signature
if (name.endsWith("x64-setup.nsis.zip.sig")) { if (name.endsWith("x86-setup.nsis.zip.sig")) {
const sig = await getSignature(browser_download_url); const sig = await getSignature(browser_download_url);
updateData.platforms["windows-x86"].signature = sig; updateData.platforms["windows-x86"].signature = sig;
updateData.platforms["windows-i686"].signature = sig; updateData.platforms["windows-i686"].signature = sig;
+1 -1
View File
@@ -790,7 +790,7 @@ dependencies = [
[[package]] [[package]]
name = "clash-verge" name = "clash-verge"
version = "1.7.4" version = "1.7.7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"auto-launch", "auto-launch",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "clash-verge" name = "clash-verge"
version = "1.7.4" version = "1.7.7"
description = "clash verge" description = "clash verge"
authors = ["zzzgydi", "wonfen", "MystiPanda"] authors = ["zzzgydi", "wonfen", "MystiPanda"]
license = "GPL-3.0-only" license = "GPL-3.0-only"
+4 -4
View File
@@ -389,13 +389,13 @@ pub mod service {
} }
#[tauri::command] #[tauri::command]
pub async fn install_service() -> CmdResult { pub async fn install_service(passwd: String) -> CmdResult {
wrap_err!(service::install_service().await) wrap_err!(service::install_service(passwd).await)
} }
#[tauri::command] #[tauri::command]
pub async fn uninstall_service() -> CmdResult { pub async fn uninstall_service(passwd: String) -> CmdResult {
wrap_err!(service::uninstall_service().await) wrap_err!(service::uninstall_service(passwd).await)
} }
} }
+17 -4
View File
@@ -111,6 +111,7 @@ impl IProfiles {
if item.uid.is_none() { if item.uid.is_none() {
bail!("the uid should not be null"); bail!("the uid should not be null");
} }
let uid = item.uid.clone();
// save the file data // save the file data
// move the field value after save // move the field value after save
@@ -128,6 +129,12 @@ impl IProfiles {
.with_context(|| format!("failed to write to file \"{}\"", file))?; .with_context(|| format!("failed to write to file \"{}\"", file))?;
} }
if self.current.is_none()
&& (item.itype == Some("remote".to_string()) || item.itype == Some("local".to_string()))
{
self.current = uid;
}
if self.items.is_none() { if self.items.is_none() {
self.items = Some(vec![]); self.items = Some(vec![]);
} }
@@ -135,6 +142,7 @@ impl IProfiles {
if let Some(items) = self.items.as_mut() { if let Some(items) = self.items.as_mut() {
items.push(item) items.push(item)
} }
self.save_file() self.save_file()
} }
@@ -355,10 +363,15 @@ impl IProfiles {
} }
// delete the original uid // delete the original uid
if current == uid { if current == uid {
self.current = match !items.is_empty() { self.current = None;
true => items[0].uid.clone(), for item in items.iter() {
false => None, if item.itype == Some("remote".to_string())
}; || item.itype == Some("local".to_string())
{
self.current = item.uid.clone();
break;
}
}
} }
self.items = Some(items); self.items = Some(items);
+94 -53
View File
@@ -28,11 +28,19 @@ pub struct JsonResponse {
pub data: Option<ResponseBody>, pub data: Option<ResponseBody>,
} }
#[cfg(not(target_os = "windows"))]
pub fn sudo(passwd: &String, cmd: String) -> StdCommand {
let shell = format!("echo \"{}\" | sudo -S {}", passwd, cmd);
let mut command = StdCommand::new("bash");
command.arg("-c").arg(shell);
command
}
/// Install the Clash Verge Service /// Install the Clash Verge Service
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程 /// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
/// ///
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub async fn install_service() -> Result<()> { pub async fn install_service(_passwd: String) -> Result<()> {
use deelevate::{PrivilegeLevel, Token}; use deelevate::{PrivilegeLevel, Token};
use runas::Command as RunasCommand; use runas::Command as RunasCommand;
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
@@ -65,30 +73,45 @@ pub async fn install_service() -> Result<()> {
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub async fn install_service() -> Result<()> { pub async fn install_service(passwd: String) -> Result<()> {
use users::get_effective_uid; use users::get_effective_uid;
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;
let installer_path = binary_path.with_file_name("install-service"); let installer_path = binary_path.with_file_name("install-service");
if !installer_path.exists() { if !installer_path.exists() {
bail!("installer not found"); bail!("installer not found");
} }
let elevator = crate::utils::unix_helper::linux_elevator(); let output = match get_effective_uid() {
let status = match get_effective_uid() { 0 => {
0 => StdCommand::new(installer_path).status()?, StdCommand::new("chmod")
_ => StdCommand::new(elevator) .arg("+x")
.arg("sh") .arg(installer_path.clone())
.arg("-c") .output()?;
.arg(installer_path) StdCommand::new("chmod")
.status()?, .arg("+x")
.arg(binary_path)
.output()?;
StdCommand::new(installer_path.clone()).output()?
}
_ => {
sudo(
&passwd,
format!("chmod +x {}", installer_path.to_string_lossy()),
)
.output()?;
sudo(
&passwd,
format!("chmod +x {}", binary_path.to_string_lossy()),
)
.output()?;
sudo(&passwd, format!("{}", installer_path.to_string_lossy())).output()?
}
}; };
if !output.status.success() {
if !status.success() {
bail!( bail!(
"failed to install service with status {}", "failed to install service with error: {}",
status.code().unwrap() String::from_utf8_lossy(&output.stderr)
); );
} }
@@ -96,7 +119,7 @@ pub async fn install_service() -> Result<()> {
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
pub async fn install_service() -> Result<()> { pub async fn install_service(passwd: String) -> Result<()> {
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;
let installer_path = binary_path.with_file_name("install-service"); let installer_path = binary_path.with_file_name("install-service");
@@ -104,22 +127,24 @@ pub async fn install_service() -> Result<()> {
bail!("installer not found"); bail!("installer not found");
} }
let _ = StdCommand::new("chmod") sudo(
.arg("+x") &passwd,
.arg(installer_path.to_string_lossy().replace(" ", "\\ ")) format!(
.output(); "chmod +x {}",
installer_path.to_string_lossy().replace(" ", "\\ ")
),
)
.output()?;
let output = sudo(
&passwd,
format!("{}", installer_path.to_string_lossy().replace(" ", "\\ ")),
)
.output()?;
let shell = installer_path.to_string_lossy().replace(" ", "\\\\ "); if !output.status.success() {
let command = format!(r#"do shell script "{shell}" with administrator privileges"#);
let status = StdCommand::new("osascript")
.args(vec!["-e", &command])
.status()?;
if !status.success() {
bail!( bail!(
"failed to install service with status {}", "failed to install service with error: {}",
status.code().unwrap() String::from_utf8_lossy(&output.stderr)
); );
} }
@@ -128,7 +153,7 @@ pub async fn install_service() -> Result<()> {
/// Uninstall the Clash Verge Service /// Uninstall the Clash Verge Service
/// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程 /// 该函数应该在协程或者线程中执行,避免UAC弹窗阻塞主线程
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub async fn uninstall_service() -> Result<()> { pub async fn uninstall_service(_passwd: String) -> Result<()> {
use deelevate::{PrivilegeLevel, Token}; use deelevate::{PrivilegeLevel, Token};
use runas::Command as RunasCommand; use runas::Command as RunasCommand;
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
@@ -161,7 +186,7 @@ pub async fn uninstall_service() -> Result<()> {
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub async fn uninstall_service() -> Result<()> { pub async fn uninstall_service(passwd: String) -> Result<()> {
use users::get_effective_uid; use users::get_effective_uid;
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;
@@ -171,20 +196,29 @@ pub async fn uninstall_service() -> Result<()> {
bail!("uninstaller not found"); bail!("uninstaller not found");
} }
let elevator = crate::utils::unix_helper::linux_elevator(); let output = match get_effective_uid() {
let status = match get_effective_uid() { 0 => {
0 => StdCommand::new(uninstaller_path).status()?, StdCommand::new("chmod")
_ => StdCommand::new(elevator) .arg("+x")
.arg("sh") .arg(uninstaller_path.clone())
.arg("-c") .output()?;
.arg(uninstaller_path) StdCommand::new(uninstaller_path.clone()).output()?
.status()?, }
_ => {
sudo(
&passwd,
format!("chmod +x {}", uninstaller_path.to_string_lossy()),
)
.output()?;
sudo(&passwd, format!("{}", uninstaller_path.to_string_lossy())).output()?
}
}; };
if !status.success() { if !output.status.success() {
bail!( bail!(
"failed to install service with status {}", "failed to install service with error: {}",
status.code().unwrap() String::from_utf8_lossy(&output.stderr)
); );
} }
@@ -192,7 +226,7 @@ pub async fn uninstall_service() -> Result<()> {
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
pub async fn uninstall_service() -> Result<()> { pub async fn uninstall_service(passwd: String) -> Result<()> {
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;
let uninstaller_path = binary_path.with_file_name("uninstall-service"); let uninstaller_path = binary_path.with_file_name("uninstall-service");
@@ -200,17 +234,24 @@ pub async fn uninstall_service() -> Result<()> {
bail!("uninstaller not found"); bail!("uninstaller not found");
} }
let shell = uninstaller_path.to_string_lossy().replace(" ", "\\\\ "); sudo(
let command = format!(r#"do shell script "{shell}" with administrator privileges"#); &passwd,
format!(
"chmod +x {}",
uninstaller_path.to_string_lossy().replace(" ", "\\ ")
),
)
.output()?;
let output = sudo(
&passwd,
format!("{}", uninstaller_path.to_string_lossy().replace(" ", "\\ ")),
)
.output()?;
let status = StdCommand::new("osascript") if !output.status.success() {
.args(vec!["-e", &command])
.status()?;
if !status.success() {
bail!( bail!(
"failed to install service with status {}", "failed to uninstall service with error: {}",
status.code().unwrap() String::from_utf8_lossy(&output.stderr)
); );
} }
+3 -3
View File
@@ -297,11 +297,11 @@ impl Tray {
}; };
let _ = tray.set_tooltip(&format!( let _ = tray.set_tooltip(&format!(
"Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}", "Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}",
t!("System Proxy", "系统代理"), t!("SysProxy", "系统代理"),
switch_map[system_proxy], switch_map[system_proxy],
t!("TUN Mode", "Tun 模式"), t!("TUN", "Tun模式"),
switch_map[tun_mode], switch_map[tun_mode],
t!("Curent Profile", "当前订阅"), t!("Profile", "当前订阅"),
current_profile_name current_profile_name
)); ));
+13 -5
View File
@@ -191,11 +191,15 @@ pub fn init_config() -> Result<()> {
/// after tauri setup /// after tauri setup
pub fn init_resources() -> Result<()> { pub fn init_resources() -> Result<()> {
let app_dir = dirs::app_home_dir()?; let app_dir = dirs::app_home_dir()?;
let test_dir = app_dir.join("test");
let res_dir = dirs::app_resources_dir()?; let res_dir = dirs::app_resources_dir()?;
if !app_dir.exists() { if !app_dir.exists() {
let _ = fs::create_dir_all(&app_dir); let _ = fs::create_dir_all(&app_dir);
} }
if !test_dir.exists() {
let _ = fs::create_dir_all(&test_dir);
}
if !res_dir.exists() { if !res_dir.exists() {
let _ = fs::create_dir_all(&res_dir); let _ = fs::create_dir_all(&res_dir);
} }
@@ -210,9 +214,10 @@ pub fn init_resources() -> Result<()> {
for file in file_list.iter() { for file in file_list.iter() {
let src_path = res_dir.join(file); let src_path = res_dir.join(file);
let dest_path = app_dir.join(file); let dest_path = app_dir.join(file);
let test_dest_path = test_dir.join(file);
let handle_copy = || { let handle_copy = |dest: &PathBuf| {
match fs::copy(&src_path, &dest_path) { match fs::copy(&src_path, dest) {
Ok(_) => log::debug!(target: "app", "resources copied '{file}'"), Ok(_) => log::debug!(target: "app", "resources copied '{file}'"),
Err(err) => { Err(err) => {
log::error!(target: "app", "failed to copy resources '{file}', {err}") log::error!(target: "app", "failed to copy resources '{file}', {err}")
@@ -220,8 +225,11 @@ pub fn init_resources() -> Result<()> {
}; };
}; };
if src_path.exists() && !test_dest_path.exists() {
handle_copy(&test_dest_path);
}
if src_path.exists() && !dest_path.exists() { if src_path.exists() && !dest_path.exists() {
handle_copy(); handle_copy(&dest_path);
continue; continue;
} }
@@ -231,14 +239,14 @@ pub fn init_resources() -> Result<()> {
match (src_modified, dest_modified) { match (src_modified, dest_modified) {
(Ok(src_modified), Ok(dest_modified)) => { (Ok(src_modified), Ok(dest_modified)) => {
if src_modified > dest_modified { if src_modified > dest_modified {
handle_copy(); handle_copy(&dest_path);
} else { } else {
log::debug!(target: "app", "skipping resource copy '{file}'"); log::debug!(target: "app", "skipping resource copy '{file}'");
} }
} }
_ => { _ => {
log::debug!(target: "app", "failed to get modified '{file}'"); log::debug!(target: "app", "failed to get modified '{file}'");
handle_copy(); handle_copy(&dest_path);
} }
}; };
} }
-1
View File
@@ -4,4 +4,3 @@ pub mod init;
pub mod resolve; pub mod resolve;
pub mod server; pub mod server;
pub mod tmpl; pub mod tmpl;
pub mod unix_helper;
+1
View File
@@ -8,6 +8,7 @@ use serde_yaml::Mapping;
use std::net::TcpListener; use std::net::TcpListener;
use tauri::api::notification; use tauri::api::notification;
use tauri::{App, AppHandle, Manager}; use tauri::{App, AppHandle, Manager};
#[cfg(not(target_os = "linux"))]
use window_shadows::set_shadow; use window_shadows::set_shadow;
pub static VERSION: OnceCell<String> = OnceCell::new(); pub static VERSION: OnceCell<String> = OnceCell::new();
-14
View File
@@ -1,14 +0,0 @@
#[cfg(target_os = "linux")]
pub fn linux_elevator() -> &'static str {
use std::process::Command;
match Command::new("which").arg("pkexec").output() {
Ok(output) => {
if output.stdout.is_empty() {
"sudo"
} else {
"pkexec"
}
}
Err(_) => "sudo",
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
"$schema": "../node_modules/@tauri-apps/cli/schema.json", "$schema": "../node_modules/@tauri-apps/cli/schema.json",
"package": { "package": {
"productName": "Clash Verge", "productName": "Clash Verge",
"version": "1.7.4" "version": "1.7.7"
}, },
"build": { "build": {
"distDir": "../dist", "distDir": "../dist",
@@ -723,7 +723,7 @@ export const GroupsEditorViewer = (props: Props) => {
throw new Error(t("Group Name Already Exists")); throw new Error(t("Group Name Already Exists"));
} }
} }
setPrependSeq([...prependSeq, formIns.getValues()]); setPrependSeq([formIns.getValues(), ...prependSeq]);
} catch (err: any) { } catch (err: any) {
Notice.error(err.message || err.toString()); Notice.error(err.message || err.toString());
} }
@@ -276,7 +276,7 @@ export const ProxiesEditorViewer = (props: Props) => {
startIcon={<VerticalAlignTopRounded />} startIcon={<VerticalAlignTopRounded />}
onClick={() => { onClick={() => {
let proxies = handleParse(); let proxies = handleParse();
setPrependSeq([...prependSeq, ...proxies]); setPrependSeq([...proxies, ...prependSeq]);
}} }}
> >
{t("Prepend Proxy")} {t("Prepend Proxy")}
@@ -543,7 +543,7 @@ export const RulesEditorViewer = (props: Props) => {
try { try {
let raw = validateRule(); let raw = validateRule();
if (prependSeq.includes(raw)) return; if (prependSeq.includes(raw)) return;
setPrependSeq([...prependSeq, raw]); setPrependSeq([raw, ...prependSeq]);
} catch (err: any) { } catch (err: any) {
Notice.error(err.message || err.toString()); Notice.error(err.message || err.toString());
} }
+6 -2
View File
@@ -21,6 +21,7 @@ import delayManager from "@/services/delay";
interface Props { interface Props {
sx?: SxProps; sx?: SxProps;
url?: string;
groupName: string; groupName: string;
headState: HeadState; headState: HeadState;
onLocation: () => void; onLocation: () => void;
@@ -29,7 +30,7 @@ interface Props {
} }
export const ProxyHead = (props: Props) => { export const ProxyHead = (props: Props) => {
const { sx = {}, groupName, headState, onHeadState } = props; const { sx = {}, url, groupName, headState, onHeadState } = props;
const { showType, sortType, filterText, textState, testUrl } = headState; const { showType, sortType, filterText, textState, testUrl } = headState;
@@ -45,7 +46,10 @@ export const ProxyHead = (props: Props) => {
const { verge } = useVerge(); const { verge } = useVerge();
useEffect(() => { useEffect(() => {
delayManager.setUrl(groupName, testUrl || verge?.default_latency_test!); delayManager.setUrl(
groupName,
testUrl || url || verge?.default_latency_test!
);
}, [groupName, testUrl, verge?.default_latency_test]); }, [groupName, testUrl, verge?.default_latency_test]);
return ( return (
+1
View File
@@ -129,6 +129,7 @@ export const ProxyRender = (props: RenderProps) => {
return ( return (
<ProxyHead <ProxyHead
sx={{ pl: 2, pr: 3, mt: indent ? 1 : 0.5, mb: 1 }} sx={{ pl: 2, pr: 3, mt: indent ? 1 : 0.5, mb: 1 }}
url={group.testUrl}
groupName={group.name} groupName={group.name}
headState={headState!} headState={headState!}
onLocation={() => onLocation(group)} onLocation={() => onLocation(group)}
@@ -24,7 +24,6 @@ export const NetworkInterfaceViewer = forwardRef<DialogRef>((props, ref) => {
useEffect(() => { useEffect(() => {
if (!open) return; if (!open) return;
getNetworkInterfacesInfo().then((res) => { getNetworkInterfacesInfo().then((res) => {
console.log(res);
setNetworkInterfaces(res); setNetworkInterfaces(res);
}); });
}, [open]); }, [open]);
@@ -49,9 +48,8 @@ export const NetworkInterfaceViewer = forwardRef<DialogRef>((props, ref) => {
</Box> </Box>
} }
contentSx={{ width: 450, maxHeight: 330 }} contentSx={{ width: 450, maxHeight: 330 }}
okBtn={t("Save")} disableOk
cancelBtn={t("Cancel")} cancelBtn={t("Close")}
onClose={() => setOpen(false)}
onCancel={() => setOpen(false)} onCancel={() => setOpen(false)}
> >
{networkInterfaces.map((item) => ( {networkInterfaces.map((item) => (
@@ -116,7 +114,7 @@ const AddressDisplay = (props: { label: string; content: string }) => {
<Box <Box
sx={({ palette }) => ({ sx={({ palette }) => ({
borderRadius: "8px", borderRadius: "8px",
padding: "2px", padding: "2px 2px 2px 8px",
background: background:
palette.mode === "dark" palette.mode === "dark"
? alpha(palette.background.paper, 0.3) ? alpha(palette.background.paper, 0.3)
@@ -0,0 +1,54 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
TextField,
} from "@mui/material";
interface Props {
onConfirm: (passwd: string) => Promise<void>;
}
export const PasswordInput = (props: Props) => {
const { onConfirm } = props;
const { t } = useTranslation();
const [passwd, setPasswd] = useState("");
useEffect(() => {
if (!open) return;
}, [open]);
return (
<Dialog open={true} maxWidth="xs" fullWidth>
<DialogTitle>{t("Please enter your root password")}</DialogTitle>
<DialogContent>
<TextField
sx={{ mt: 1 }}
autoFocus
label={t("Password")}
fullWidth
size="small"
type="password"
value={passwd}
onKeyDown={(e) => e.key === "Enter" && onConfirm(passwd)}
onChange={(e) => setPasswd(e.target.value)}
></TextField>
</DialogContent>
<DialogActions>
<Button
onClick={async () => await onConfirm(passwd)}
variant="contained"
>
{t("Confirm")}
</Button>
</DialogActions>
</Dialog>
);
};
@@ -5,6 +5,8 @@ import { useTranslation } from "react-i18next";
import { installService, uninstallService } from "@/services/cmds"; import { installService, uninstallService } from "@/services/cmds";
import { Notice } from "@/components/base"; import { Notice } from "@/components/base";
import { LoadingButton } from "@mui/lab"; import { LoadingButton } from "@mui/lab";
import { PasswordInput } from "./password-input";
import getSystem from "@/utils/get-system";
interface Props { interface Props {
status: "active" | "installed" | "unknown" | "uninstall"; status: "active" | "installed" | "unknown" | "uninstall";
@@ -15,7 +17,7 @@ interface Props {
export const ServiceSwitcher = (props: Props) => { export const ServiceSwitcher = (props: Props) => {
const { status, mutate, patchVerge, onChangeData } = props; const { status, mutate, patchVerge, onChangeData } = props;
const isWindows = getSystem() === "windows";
const isActive = status === "active"; const isActive = status === "active";
const isInstalled = status === "installed"; const isInstalled = status === "installed";
const isUninstall = status === "uninstall" || status === "unknown"; const isUninstall = status === "uninstall" || status === "unknown";
@@ -23,40 +25,33 @@ export const ServiceSwitcher = (props: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [serviceLoading, setServiceLoading] = useState(false); const [serviceLoading, setServiceLoading] = useState(false);
const [uninstallServiceLoaing, setUninstallServiceLoading] = useState(false); const [uninstallServiceLoaing, setUninstallServiceLoading] = useState(false);
const [openInstall, setOpenInstall] = useState(false);
const [openUninstall, setOpenUninstall] = useState(false);
const onInstallOrEnableService = useLockFn(async () => { async function install(passwd: string) {
setServiceLoading(true);
try { try {
if (isUninstall) { setOpenInstall(false);
// install service await installService(passwd);
await installService(); await mutate();
await mutate(); setTimeout(() => {
setTimeout(() => { mutate();
mutate(); }, 2000);
}, 2000); Notice.success(t("Service Installed Successfully"));
Notice.success(t("Service Installed Successfully")); setServiceLoading(false);
setServiceLoading(false);
} else {
// enable or disable service
await patchVerge({ enable_service_mode: !isActive });
onChangeData({ enable_service_mode: !isActive });
await mutate();
setTimeout(() => {
mutate();
}, 2000);
setServiceLoading(false);
}
} catch (err: any) { } catch (err: any) {
await mutate(); await mutate();
setTimeout(() => {
mutate();
}, 2000);
Notice.error(err.message || err.toString()); Notice.error(err.message || err.toString());
setServiceLoading(false); setServiceLoading(false);
} }
}); }
const onUninstallService = useLockFn(async () => { async function uninstall(passwd: string) {
setUninstallServiceLoading(true);
try { try {
await uninstallService(); setOpenUninstall(false);
await uninstallService(passwd);
await mutate(); await mutate();
setTimeout(() => { setTimeout(() => {
mutate(); mutate();
@@ -65,13 +60,55 @@ export const ServiceSwitcher = (props: Props) => {
setUninstallServiceLoading(false); setUninstallServiceLoading(false);
} catch (err: any) { } catch (err: any) {
await mutate(); await mutate();
setTimeout(() => {
mutate();
}, 2000);
Notice.error(err.message || err.toString()); Notice.error(err.message || err.toString());
setUninstallServiceLoading(false); setUninstallServiceLoading(false);
} }
}
const onInstallOrEnableService = useLockFn(async () => {
setServiceLoading(true);
if (isUninstall) {
// install service
if (isWindows) {
await install("");
} else {
setOpenInstall(true);
}
} else {
try {
// enable or disable service
await patchVerge({ enable_service_mode: !isActive });
onChangeData({ enable_service_mode: !isActive });
await mutate();
setTimeout(() => {
mutate();
}, 2000);
setServiceLoading(false);
} catch (err: any) {
await mutate();
Notice.error(err.message || err.toString());
setServiceLoading(false);
}
}
});
const onUninstallService = useLockFn(async () => {
setUninstallServiceLoading(true);
if (isWindows) {
await uninstall("");
} else {
setOpenUninstall(true);
}
}); });
return ( return (
<> <>
{openInstall && <PasswordInput onConfirm={install} />}
{openUninstall && <PasswordInput onConfirm={uninstall} />}
<LoadingButton <LoadingButton
size="small" size="small"
variant={isUninstall ? "outlined" : "contained"} variant={isUninstall ? "outlined" : "contained"}
@@ -34,17 +34,22 @@ const domain_tld_part = String.raw`(?:\w{2,64}\*?|\*)`;
const rDomainSimple = domain_subdomain_part + domain_tld_part; const rDomainSimple = domain_subdomain_part + domain_tld_part;
const ipv4_part = String.raw`\d{1,3}`; const ipv4_part = String.raw`\d{1,3}`;
// 127.0.0.1 (full ipv4)
const rIPv4 = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}`;
// const rIPv4Partial = String.raw`${ipv4_part}\.(?:(?:${ipv4_part}|\*)\.){0,2}\.\*`;
const ipv6_part = "(?:[a-fA-F0-9:])+"; const ipv6_part = "(?:[a-fA-F0-9:])+";
const rIPv6 = `(?:${ipv6_part}:+)+${ipv6_part}`;
const rLocal = `localhost|<local>|localdomain`; const rLocal = `localhost|<local>|localdomain`;
const rValidPart = `${rDomainSimple}|${rIPv4}|${rIPv6}|${rLocal}`;
const getValidReg = (isWindows: boolean) => { const getValidReg = (isWindows: boolean) => {
// 127.0.0.1 (full ipv4)
const rIPv4Unix = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}(?:\/\d{1,2})?`;
const rIPv4Windows = String.raw`(?:${ipv4_part}\.){3}${ipv4_part}`;
const rIPv6Unix = String.raw`(?:${ipv6_part}:+)+${ipv6_part}(?:\/\d{1,3})?`;
const rIPv6Windows = String.raw`(?:${ipv6_part}:+)+${ipv6_part}`;
const rValidPart = `${rDomainSimple}|${
isWindows ? rIPv4Windows : rIPv4Unix
}|${isWindows ? rIPv6Windows : rIPv6Unix}|${rLocal}`;
const separator = isWindows ? ";" : ","; const separator = isWindows ? ";" : ",";
const rValid = String.raw`^(${rValidPart})(?:${separator}\s?(${rValidPart}))*${separator}?$`; const rValid = String.raw`^(${rValidPart})(?:${separator}\s?(${rValidPart}))*${separator}?$`;
@@ -24,7 +24,7 @@ export const WebUIViewer = forwardRef<DialogRef>((props, ref) => {
const webUIList = verge?.web_ui_list || [ const webUIList = verge?.web_ui_list || [
"https://metacubex.github.io/metacubexd/#/setup?http=true&hostname=%host&port=%port&secret=%secret", "https://metacubex.github.io/metacubexd/#/setup?http=true&hostname=%host&port=%port&secret=%secret",
"https://yacd.metacubex.one/?host=%host&port=%port&secret=%secret", "https://yacd.metacubex.one/?hostname=%host&port=%port&secret=%secret",
]; ];
const handleAdd = useLockFn(async (value: string) => { const handleAdd = useLockFn(async (value: string) => {
+3 -5
View File
@@ -28,7 +28,7 @@ interface Props {
onDelete: (uid: string) => void; onDelete: (uid: string) => void;
} }
let eventListener: UnlistenFn | null = null; let eventListener: UnlistenFn = () => {};
export const TestItem = (props: Props) => { export const TestItem = (props: Props) => {
const { itemData, onEdit, onDelete: onDeleteItem } = props; const { itemData, onEdit, onDelete: onDeleteItem } = props;
@@ -90,9 +90,7 @@ export const TestItem = (props: Props) => {
]; ];
const listenTsetEvent = async () => { const listenTsetEvent = async () => {
if (eventListener !== null) { eventListener();
eventListener();
}
eventListener = await listen("verge://test-all", () => { eventListener = await listen("verge://test-all", () => {
onDelay(); onDelay();
}); });
@@ -100,7 +98,7 @@ export const TestItem = (props: Props) => {
useEffect(() => { useEffect(() => {
listenTsetEvent(); listenTsetEvent();
}, []); }, [url]);
return ( return (
<Box <Box
+1
View File
@@ -267,6 +267,7 @@
"Release Version": "Release Version", "Release Version": "Release Version",
"Alpha Version": "Alpha Version", "Alpha Version": "Alpha Version",
"Please Enable Service Mode": "Please Install and Enable Service Mode First", "Please Enable Service Mode": "Please Install and Enable Service Mode First",
"Please enter your root password": "Please enter your root password",
"Grant": "Grant", "Grant": "Grant",
"Open UWP tool": "Open UWP tool", "Open UWP tool": "Open UWP tool",
"Open UWP tool Info": "Since Windows 8, UWP apps (such as Microsoft Store) are restricted from directly accessing local host network services, and this tool can be used to bypass this restriction", "Open UWP tool Info": "Since Windows 8, UWP apps (such as Microsoft Store) are restricted from directly accessing local host network services, and this tool can be used to bypass this restriction",
+1
View File
@@ -262,6 +262,7 @@
"Release Version": "نسخه نهایی", "Release Version": "نسخه نهایی",
"Alpha Version": "نسخه آلفا", "Alpha Version": "نسخه آلفا",
"Please Install and Enable Service Mode First": "لطفاً ابتدا حالت سرویس را نصب و فعال کنید", "Please Install and Enable Service Mode First": "لطفاً ابتدا حالت سرویس را نصب و فعال کنید",
"Please enter your root password": "لطفاً رمز ریشه خود را وارد کنید",
"Grant": "اعطا", "Grant": "اعطا",
"Open UWP tool": "باز کردن ابزار UWP", "Open UWP tool": "باز کردن ابزار UWP",
"Open UWP tool Info": "از ویندوز 8 به بعد، برنامه‌های UWP (مانند Microsoft Store) از دسترسی مستقیم به خدمات شبکه محلی محدود شده‌اند و این ابزار می‌تواند برای دور زدن این محدودیت استفاده شود", "Open UWP tool Info": "از ویندوز 8 به بعد، برنامه‌های UWP (مانند Microsoft Store) از دسترسی مستقیم به خدمات شبکه محلی محدود شده‌اند و این ابزار می‌تواند برای دور زدن این محدودیت استفاده شود",
+1
View File
@@ -265,6 +265,7 @@
"Release Version": "Официальная версия", "Release Version": "Официальная версия",
"Alpha Version": "Альфа-версия", "Alpha Version": "Альфа-версия",
"Please Enable Service Mode": "Пожалуйста, сначала установите и включите режим обслуживания", "Please Enable Service Mode": "Пожалуйста, сначала установите и включите режим обслуживания",
"Please enter your root password": "Пожалуйста, введите ваш пароль root",
"Grant": "Предоставить", "Grant": "Предоставить",
"Open UWP tool": "Открыть UWP инструмент", "Open UWP tool": "Открыть UWP инструмент",
"Open UWP tool Info": "С Windows 8 приложения UWP (такие как Microsoft Store) ограничены в прямом доступе к сетевым службам локального хоста, и этот инструмент позволяет обойти это ограничение", "Open UWP tool Info": "С Windows 8 приложения UWP (такие как Microsoft Store) ограничены в прямом доступе к сетевым службам локального хоста, и этот инструмент позволяет обойти это ограничение",
+1
View File
@@ -267,6 +267,7 @@
"Release Version": "正式版", "Release Version": "正式版",
"Alpha Version": "预览版", "Alpha Version": "预览版",
"Please Enable Service Mode": "请先安装并启用服务模式", "Please Enable Service Mode": "请先安装并启用服务模式",
"Please enter your root password": "请输入您的 root 密码",
"Grant": "授权", "Grant": "授权",
"Open UWP tool": "UWP 工具", "Open UWP tool": "UWP 工具",
"Open UWP tool Info": "Windows 8开始限制 UWP 应用(如微软商店)直接访问本地主机的网络服务,使用此工具可绕过该限制", "Open UWP tool Info": "Windows 8开始限制 UWP 应用(如微软商店)直接访问本地主机的网络服务,使用此工具可绕过该限制",
+1 -1
View File
@@ -137,7 +137,7 @@ const ProfilePage = () => {
mutate("getProfiles", newProfiles); mutate("getProfiles", newProfiles);
const remoteItem = newProfiles.items?.find((e) => e.type === "remote"); const remoteItem = newProfiles.items?.find((e) => e.type === "remote");
if (!newProfiles.current && remoteItem) { if (newProfiles.current && remoteItem) {
const current = remoteItem.uid; const current = remoteItem.uid;
await patchProfiles({ current }); await patchProfiles({ current });
mutateLogs(); mutateLogs();
+4 -4
View File
@@ -201,12 +201,12 @@ export async function checkService() {
} }
} }
export async function installService() { export async function installService(passwd: string) {
return invoke<void>("install_service"); return invoke<void>("install_service", { passwd });
} }
export async function uninstallService() { export async function uninstallService(passwd: string) {
return invoke<void>("uninstall_service"); return invoke<void>("uninstall_service", { passwd });
} }
export async function invoke_uwp_tool() { export async function invoke_uwp_tool() {
+1
View File
@@ -59,6 +59,7 @@ interface IProxyItem {
time: string; time: string;
delay: number; delay: number;
}[]; }[];
testUrl?: string;
all?: string[]; all?: string[];
now?: string; now?: string;
hidden?: boolean; hidden?: boolean;