mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
feat: support internal non-tunnel gateway sessions
This commit is contained in:
58 files changed
+7897
-949
No files matched your search
@@ -81,8 +81,27 @@ fn sibling_binary(binary_name: &str) -> Option<PathBuf> {
|
||||
let current_exe = env::current_exe().ok()?;
|
||||
let bin_dir = current_exe.parent()?;
|
||||
let binary = bin_dir.join(binary_name);
|
||||
if is_file(&binary) {
|
||||
return Some(binary);
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Some(binary) = bundled_helper_path(¤t_exe, binary_name)
|
||||
&& is_file(&binary)
|
||||
{
|
||||
return Some(binary);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
is_file(&binary).then_some(binary)
|
||||
#[cfg(target_os = "macos")]
|
||||
fn bundled_helper_path(executable: &Path, binary_name: &str) -> Option<PathBuf> {
|
||||
let bin_dir = executable.parent()?;
|
||||
let contents = bin_dir.parent()?;
|
||||
let bundle = contents.parent()?;
|
||||
if bin_dir.file_name()? != "MacOS" || contents.file_name()? != "Contents" || bundle.extension()? != "app" {
|
||||
return None;
|
||||
}
|
||||
Some(contents.join("Helpers").join(binary_name))
|
||||
}
|
||||
|
||||
fn is_file(path: &Path) -> bool {
|
||||
@@ -93,6 +112,20 @@ fn is_file(path: &Path) -> bool {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn desktop_resolves_helpers_in_the_actual_app_bundle_layout() {
|
||||
assert_eq!(
|
||||
bundled_helper_path(
|
||||
Path::new("/Applications/GP Connect.app/Contents/MacOS/gpgui"),
|
||||
"gpclient"
|
||||
),
|
||||
Some(PathBuf::from("/Applications/GP Connect.app/Contents/Helpers/gpclient"))
|
||||
);
|
||||
assert!(bundled_helper_path(Path::new("/usr/local/bin/gpgui"), "gpclient").is_none());
|
||||
assert!(bundled_helper_path(Path::new("/tmp/Contents/MacOS/gpgui"), "gpclient").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_path_is_used_when_no_sibling_exists() {
|
||||
let path = resolve("GP_TEST_BINARY", "missing-gp-test-binary", "/usr/bin/gp-test");
|
||||
|
||||
Reference in new issue
Block a user