mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
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
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:
parent
19b6f78c8a
commit
a9ef32c32f
|
@ -88,37 +88,16 @@ pub fn toggle_system_proxy() {
|
||||||
pub fn toggle_tun_mode() {
|
pub fn toggle_tun_mode() {
|
||||||
let enable = Config::verge().data().enable_tun_mode;
|
let enable = Config::verge().data().enable_tun_mode;
|
||||||
let enable = enable.unwrap_or(false);
|
let enable = enable.unwrap_or(false);
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
if !enable {
|
match patch_verge(IVerge {
|
||||||
if let Ok(res) = service::check_service().await {
|
enable_tun_mode: Some(!enable),
|
||||||
if res.code == 0 {
|
..IVerge::default()
|
||||||
match patch_verge(IVerge {
|
})
|
||||||
enable_tun_mode: Some(!enable),
|
.await
|
||||||
..IVerge::default()
|
{
|
||||||
})
|
Ok(_) => handle::Handle::refresh_verge(),
|
||||||
.await
|
Err(err) => log::error!(target: "app", "{err}"),
|
||||||
{
|
|
||||||
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}"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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"))
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,16 +19,6 @@ fn main() -> std::io::Result<()> {
|
||||||
println!("app exists");
|
println!("app exists");
|
||||||
return Ok(());
|
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")]
|
#[cfg(target_os = "linux")]
|
||||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||||
|
|
|
@ -24,7 +24,6 @@ export const StackModeSwitch = (props: Props) => {
|
||||||
>
|
>
|
||||||
gVisor
|
gVisor
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant={value?.toLowerCase() === "mixed" ? "contained" : "outlined"}
|
variant={value?.toLowerCase() === "mixed" ? "contained" : "outlined"}
|
||||||
onClick={() => onChange?.("mixed")}
|
onClick={() => onChange?.("mixed")}
|
||||||
|
|
|
@ -22,15 +22,11 @@ const SettingSystem = ({ onError }: Props) => {
|
||||||
const { verge, mutateVerge, patchVerge } = useVerge();
|
const { verge, mutateVerge, patchVerge } = useVerge();
|
||||||
|
|
||||||
// service mode
|
// service mode
|
||||||
const { data: serviceStatus, mutate: mutateCheck } = useSWR(
|
const { data: serviceStatus } = useSWR("checkService", checkService, {
|
||||||
"checkService",
|
revalidateIfStale: false,
|
||||||
checkService,
|
shouldRetryOnError: false,
|
||||||
{
|
focusThrottleInterval: 36e5, // 1 hour
|
||||||
revalidateIfStale: false,
|
});
|
||||||
shouldRetryOnError: false,
|
|
||||||
focusThrottleInterval: 36e5, // 1 hour
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const serviceRef = useRef<DialogRef>(null);
|
const serviceRef = useRef<DialogRef>(null);
|
||||||
const sysproxyRef = useRef<DialogRef>(null);
|
const sysproxyRef = useRef<DialogRef>(null);
|
||||||
|
@ -88,7 +84,7 @@ const SettingSystem = ({ onError }: Props) => {
|
||||||
onChange={(e) => onChangeData({ enable_tun_mode: e })}
|
onChange={(e) => onChangeData({ enable_tun_mode: e })}
|
||||||
onGuard={(e) => patchVerge({ enable_tun_mode: e })}
|
onGuard={(e) => patchVerge({ enable_tun_mode: e })}
|
||||||
>
|
>
|
||||||
<Switch disabled={serviceStatus !== "active"} edge="end" />
|
<Switch edge="end" />
|
||||||
</GuardState>
|
</GuardState>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
|
@ -113,10 +109,7 @@ const SettingSystem = ({ onError }: Props) => {
|
||||||
onCatch={onError}
|
onCatch={onError}
|
||||||
onFormat={onSwitchFormat}
|
onFormat={onSwitchFormat}
|
||||||
onChange={(e) => onChangeData({ enable_service_mode: e })}
|
onChange={(e) => onChangeData({ enable_service_mode: e })}
|
||||||
onGuard={(e) => {
|
onGuard={(e) => patchVerge({ enable_service_mode: e })}
|
||||||
setTimeout(() => mutateCheck(), 1000);
|
|
||||||
return patchVerge({ enable_service_mode: e });
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
edge="end"
|
edge="end"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user