Revert "feat: disable running with admin permission and check service mode"
Some checks are pending
Alpha Build / alpha (macos-latest, aarch64-apple-darwin) (push) Waiting to run
Alpha Build / alpha (macos-latest, x86_64-apple-darwin) (push) Waiting to run
Alpha Build / alpha (windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha (windows-latest, i686-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha (windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, aarch64-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, armv7-unknown-linux-gnueabihf) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, i686-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (arm64, windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (x64, windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (x86, windows-latest, i686-pc-windows-msvc) (push) Waiting to run
Alpha Build / Update tag (push) Blocked by required conditions

This reverts commit a0f9fb90ee.
This commit is contained in:
MystiPanda 2024-06-16 12:04:20 +08:00
parent 19b6f78c8a
commit a9ef32c32f
No known key found for this signature in database
4 changed files with 16 additions and 71 deletions

View File

@ -88,37 +88,16 @@ pub fn toggle_system_proxy() {
pub fn toggle_tun_mode() {
let enable = Config::verge().data().enable_tun_mode;
let enable = enable.unwrap_or(false);
tauri::async_runtime::spawn(async move {
if !enable {
if let Ok(res) = service::check_service().await {
if res.code == 0 {
match patch_verge(IVerge {
enable_tun_mode: Some(!enable),
..IVerge::default()
})
.await
{
Ok(_) => handle::Handle::refresh_verge(),
Err(err) => log::error!(target: "app", "{err}"),
}
return;
}
}
tauri::api::dialog::message(
None::<&tauri::Window>,
"Please install and enable service mode",
"Service mode is required for Tun mode",
);
} else {
match patch_verge(IVerge {
enable_tun_mode: Some(!enable),
..IVerge::default()
})
.await
{
Ok(_) => handle::Handle::refresh_verge(),
Err(err) => log::error!(target: "app", "{err}"),
}
match patch_verge(IVerge {
enable_tun_mode: Some(!enable),
..IVerge::default()
})
.await
{
Ok(_) => handle::Handle::refresh_verge(),
Err(err) => log::error!(target: "app", "{err}"),
}
});
}
@ -424,19 +403,3 @@ pub async fn test_delay(url: String) -> Result<u32> {
}
}
}
pub fn check_permission() -> Result<()> {
#[cfg(target_os = "windows")]
{
let hklm = winreg::RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
if let Ok(reg) = hklm.open_subkey_with_flags(
"SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run",
winreg::enums::KEY_SET_VALUE,
) {
reg.delete_value("Clash Verge").unwrap_or_default();
return Ok(());
}
}
Err(anyhow::anyhow!("permission denied"))
}

View File

@ -19,16 +19,6 @@ fn main() -> std::io::Result<()> {
println!("app exists");
return Ok(());
}
// 权限检测
if feat::check_permission().is_ok() {
println!("please do not run with admin permission");
tauri::api::dialog::blocking::message(
None::<&tauri::Window>,
"Please do not run with admin permission",
"If you want to use Tun mode, please enable service mode instead",
);
return Ok(());
}
#[cfg(target_os = "linux")]
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");

View File

@ -24,7 +24,6 @@ export const StackModeSwitch = (props: Props) => {
>
gVisor
</Button>
<Button
variant={value?.toLowerCase() === "mixed" ? "contained" : "outlined"}
onClick={() => onChange?.("mixed")}

View File

@ -22,15 +22,11 @@ const SettingSystem = ({ onError }: Props) => {
const { verge, mutateVerge, patchVerge } = useVerge();
// service mode
const { data: serviceStatus, mutate: mutateCheck } = useSWR(
"checkService",
checkService,
{
revalidateIfStale: false,
shouldRetryOnError: false,
focusThrottleInterval: 36e5, // 1 hour
}
);
const { data: serviceStatus } = useSWR("checkService", checkService, {
revalidateIfStale: false,
shouldRetryOnError: false,
focusThrottleInterval: 36e5, // 1 hour
});
const serviceRef = useRef<DialogRef>(null);
const sysproxyRef = useRef<DialogRef>(null);
@ -88,7 +84,7 @@ const SettingSystem = ({ onError }: Props) => {
onChange={(e) => onChangeData({ enable_tun_mode: e })}
onGuard={(e) => patchVerge({ enable_tun_mode: e })}
>
<Switch disabled={serviceStatus !== "active"} edge="end" />
<Switch edge="end" />
</GuardState>
</SettingItem>
@ -113,10 +109,7 @@ const SettingSystem = ({ onError }: Props) => {
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ enable_service_mode: e })}
onGuard={(e) => {
setTimeout(() => mutateCheck(), 1000);
return patchVerge({ enable_service_mode: e });
}}
onGuard={(e) => patchVerge({ enable_service_mode: e })}
>
<Switch
edge="end"