refactor: align GP profile and packaging flow

Main changes:

- Refactor connect/auth flows around a single OS profile and host identity model, including gateway fallback and cookie-on-stdin handling.

- Align request parameters, HIP host-id propagation, SAML webview user-agent behavior, and portal default-browser handling with observed official client behavior.

- Add opt-in cookie cache support and Microsoft Defender HIP reporting while keeping host-id validation explicit.

- Add BSD build, packaging, release artifact, and provenance support with FreeBSD/OpenBSD path and dependency cleanup.

- Update NixOS install documentation and dependency compatibility fixes.
This commit is contained in:
Kevin Yue committed 2026-06-19 21:23:29 +08:00
1 parent f98e0336dc
commit 888dc93643
92 files changed
+9847 -2868

No files matched your search

+1
View File
@@ -15,6 +15,7 @@ pub(crate) struct ConnectOptions {
pub os: *const c_char,
pub os_version: *const c_char,
pub client_version: *const c_char,
pub host_id: *const c_char,
pub local_hostname: *const c_char,
pub script: *const c_char,
+5
View File
@@ -80,6 +80,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
INFO("USER_AGENT: %s", options->user_agent);
INFO("OS: %s", options->os);
INFO("CLIENT_VERSION: %s", options->client_version);
INFO("HOST_ID: %s", options->host_id ? options->host_id : "(not set)");
INFO("VPNC_SCRIPT: %s", options->script);
INFO("SCRIPT_TUN: %d", g_script_tun);
INFO("CSD_USER: %d", options->csd_uid);
@@ -120,6 +121,10 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
options->client_version);
}
if (options->host_id) {
openconnect_set_gp_host_id(vpninfo, options->host_id);
}
effective_local_hostname = options->local_hostname;
if (!effective_local_hostname && !uname(&utsbuf)) {
effective_local_hostname = utsbuf.nodename;
+1
View File
@@ -25,6 +25,7 @@ typedef struct vpn_options {
const char *os;
const char *os_version;
const char *client_version;
const char *host_id;
const char *local_hostname;
const char *script;
+45
View File
@@ -64,6 +64,7 @@ pub struct Vpn {
os: CString,
os_version: Option<CString>,
client_version: Option<CString>,
host_id: Option<CString>,
local_hostname: Option<CString>,
script: CString,
@@ -124,6 +125,7 @@ impl Vpn {
os: self.os.as_ptr(),
os_version: Self::option_to_ptr(&self.os_version),
client_version: Self::option_to_ptr(&self.client_version),
host_id: Self::option_to_ptr(&self.host_id),
local_hostname: Self::option_to_ptr(&self.local_hostname),
script: self.script.as_ptr(),
@@ -185,6 +187,7 @@ pub struct VpnBuilder {
os: Option<String>,
os_version: Option<String>,
client_version: Option<String>,
host_id: Option<String>,
local_hostname: Option<String>,
certificate: Option<String>,
@@ -217,6 +220,7 @@ impl VpnBuilder {
os: None,
os_version: None,
client_version: None,
host_id: None,
local_hostname: None,
certificate: None,
@@ -271,6 +275,11 @@ impl VpnBuilder {
self
}
pub fn host_id<T: Into<Option<String>>>(mut self, host_id: T) -> Self {
self.host_id = host_id.into();
self
}
pub fn local_hostname<T: Into<Option<String>>>(mut self, local_hostname: T) -> Self {
self.local_hostname = local_hostname.into();
self
@@ -378,6 +387,7 @@ impl VpnBuilder {
os: Self::to_cstring(&os),
os_version: self.os_version.as_deref().map(Self::to_cstring),
client_version: self.client_version.as_deref().map(Self::to_cstring),
host_id: self.host_id.as_deref().map(Self::to_cstring),
local_hostname: self.local_hostname.as_deref().map(Self::to_cstring),
script: Self::to_cstring(&script),
@@ -453,4 +463,39 @@ mod tests {
assert_eq!(info.lifetime_secs, None);
assert_eq!(info.lifetime_warning, None);
}
#[test]
fn connect_options_include_host_id() {
let vpn = Vpn {
server: CString::new("gateway.example.com").unwrap(),
cookie: CString::new("cookie").unwrap(),
user_agent: CString::new("agent").unwrap(),
os: CString::new("linux").unwrap(),
os_version: None,
client_version: None,
host_id: Some(CString::new("profile-host-id").unwrap()),
local_hostname: None,
script: CString::new("/bin/true").unwrap(),
interface: None,
script_tun: false,
certificate: None,
sslkey: None,
key_password: None,
servercert: None,
csd_uid: 0,
csd_wrapper: None,
reconnect_timeout: 300,
mtu: 0,
disable_ipv6: false,
no_dtls: false,
dpd_interval: 0,
no_xmlpost: false,
callback: Default::default(),
};
let options = vpn.build_connect_options();
let host_id = unsafe { CStr::from_ptr(options.host_id) }.to_str().unwrap();
assert_eq!(host_id, "profile-host-id");
}
}
+4 -2
View File
@@ -3,6 +3,7 @@ use std::{io, path::Path};
use is_executable::IsExecutable;
const VPNC_SCRIPT_LOCATIONS: &[&str] = &[
"/usr/local/libexec/gpclient/vpnc-script",
"/usr/libexec/gpclient/vpnc-script",
"/usr/lib/gpclient/vpnc-script",
"/usr/local/share/vpnc-scripts/vpnc-script",
@@ -19,6 +20,7 @@ const VPNC_SCRIPT_LOCATIONS: &[&str] = &[
];
const CSD_WRAPPER_LOCATIONS: &[&str] = &[
"/usr/local/libexec/gpclient/hipreport.sh",
"/usr/libexec/gpclient/hipreport.sh",
#[cfg(target_arch = "x86_64")]
"/usr/lib/x86_64-linux-gnu/openconnect/hipreport.sh",
@@ -44,11 +46,11 @@ fn find_executable(locations: &[&'static str]) -> Option<&'static str> {
}
pub fn find_vpnc_script() -> Option<&'static str> {
find_executable(&VPNC_SCRIPT_LOCATIONS)
find_executable(VPNC_SCRIPT_LOCATIONS)
}
pub fn find_csd_wrapper() -> Option<&'static str> {
find_executable(&CSD_WRAPPER_LOCATIONS)
find_executable(CSD_WRAPPER_LOCATIONS)
}
/// If file exists, check if it is executable