refactor: align dependencies and centralize GUI activation

This commit is contained in:
Kevin Yue committed 2026-11-01 23:35:59 +08:00
1 parent 54b4d810d9
commit 43eda033e5
7 files changed
+145 -155

No files matched your search

-1
View File
@@ -28,7 +28,6 @@ sysinfo.workspace = true
serde.workspace = true
serde_json.workspace = true
whoami.workspace = true
reqwest.workspace = true
directories.workspace = true
compile-time.workspace = true
uzers.workspace = true
+2 -14
View File
@@ -11,7 +11,7 @@ use clap::Args;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
use common::binary_paths;
use directories::ProjectDirs;
use gpapi::{process::desktop_launcher::DesktopLauncher, utils::endpoint::http_endpoint};
use gpapi::process::desktop_launcher::DesktopLauncher;
use log::info;
#[derive(Args)]
@@ -61,7 +61,7 @@ impl<'a> LaunchGuiHandler<'a> {
return forward_auth_callback(callback);
}
if try_active_gui().await.is_ok() {
if DesktopLauncher::activate_existing().await.is_ok() {
info!("The GUI is already running");
return Ok(());
}
@@ -115,18 +115,6 @@ fn parse_auth_callback(callback: &str) -> Result<String, String> {
.ok_or_else(|| "callback URL must use the globalprotectcallback scheme".to_owned())
}
async fn try_active_gui() -> anyhow::Result<()> {
let service_endpoint = http_endpoint().await?;
reqwest::Client::default()
.post(format!("{}/active-gui", service_endpoint))
.send()
.await?
.error_for_status()?;
Ok(())
}
fn get_log_file() -> anyhow::Result<PathBuf> {
let dirs = ProjectDirs::from("com.yuezk", "GlobalProtect-openconnect", "gpclient")
.ok_or_else(|| anyhow::anyhow!("Failed to get project dirs"))?;
+1 -1
View File
@@ -36,7 +36,7 @@ nix = { version = "0.31", features = ["fs", "socket", "user"] }
[dev-dependencies]
openssl.workspace = true
tokio-tungstenite = "0.29"
tokio-tungstenite.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
gpvpnc = { path = "../../crates/gpvpnc" }