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

+43 -18
View File
@@ -3,7 +3,10 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use specta::Type;
use crate::{gateway::Gateway, gp_params::ClientOs};
use crate::{
gateway::Gateway,
os_profile::{ClientOs, OsProfile},
};
use super::vpn_state::ConnectInfo;
@@ -36,6 +39,7 @@ pub struct ConnectArgs {
os: Option<ClientOs>,
os_version: Option<String>,
client_version: Option<String>,
host_id: Option<String>,
certificate: Option<String>,
sslkey: Option<String>,
@@ -65,6 +69,7 @@ impl ConnectArgs {
os: None,
os_version: None,
client_version: None,
host_id: None,
certificate: None,
sslkey: None,
key_password: None,
@@ -110,6 +115,10 @@ impl ConnectArgs {
self.client_version.clone()
}
pub fn host_id(&self) -> Option<String> {
self.host_id.clone()
}
pub fn certificate(&self) -> Option<String> {
self.certificate.clone()
}
@@ -201,23 +210,12 @@ impl ConnectRequest {
self
}
pub fn with_user_agent<T: Into<Option<String>>>(mut self, user_agent: T) -> Self {
self.args.user_agent = user_agent.into();
self
}
pub fn with_os<T: Into<Option<ClientOs>>>(mut self, os: T) -> Self {
self.args.os = os.into();
self
}
pub fn with_os_version<T: Into<Option<String>>>(mut self, os_version: T) -> Self {
self.args.os_version = os_version.into();
self
}
pub fn with_client_version(mut self, client_version: &str) -> Self {
self.args.client_version = Some(client_version.to_string());
pub fn with_os_profile(mut self, profile: &OsProfile) -> Self {
self.args.os = Some(profile.client_os());
self.args.os_version = Some(profile.os_version().to_string());
self.args.client_version = Some(profile.client_version().to_string());
self.args.host_id = Some(profile.host_identity().host_id().to_string());
self.args.user_agent = Some(profile.user_agent().to_string());
self
}
@@ -314,6 +312,12 @@ mod tests {
use serde_json::json;
use super::*;
use crate::os_profile::OsProfileBuilder;
fn test_connect_info() -> ConnectInfo {
let gateway = Gateway::new("Gateway".to_string(), "vpn.example.com".to_string());
ConnectInfo::new("portal.example.com".to_string(), gateway.clone(), vec![gateway])
}
#[test]
fn connect_request_serializes_allow_extend_session() {
@@ -324,4 +328,25 @@ mod tests {
assert_eq!(value["args"]["allowExtendSession"], json!(true));
}
#[test]
fn with_os_profile_sets_user_agent_from_profile() {
let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build();
let req = ConnectRequest::new(test_connect_info(), "cookie".to_string()).with_os_profile(&profile);
assert_eq!(req.args().user_agent(), Some(profile.user_agent().to_string()));
}
#[test]
fn with_os_profile_sets_host_id_from_profile_runtime_identity() {
let profile = OsProfileBuilder::new(ClientOs::Linux).build();
let req = ConnectRequest::new(test_connect_info(), "cookie".to_string()).with_os_profile(&profile);
assert_eq!(
req.args().host_id(),
Some(profile.host_identity().host_id().to_string())
);
}
}
+15 -1
View File
@@ -1,6 +1,17 @@
use serde::{Deserialize, Serialize};
use crate::service::vpn_state::VpnState;
use crate::{os_profile::HostIdentity, service::vpn_state::VpnState};
/// The single DTO carrying all host facts gpservice ships to gpgui.
///
/// Populated by gpservice at WS connection time and sent inside `VpnEnv`.
/// gpgui stores it in a process-wide `OnceLock` and routes `AppSettings`,
/// `Constants`, and `OsProfile` construction through it.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct HostInfo {
/// Host identity collected by gpservice for the runtime OS.
pub host_identity: HostIdentity,
}
/// Represents the VPN environment configuration.
/// When a client connects, the gpservice sends the current VPN environment
@@ -19,4 +30,7 @@ pub struct VpnEnv {
/// The gpauth executable path
/// Used by the client to launch gpauth for authentication
pub auth_executable: String,
/// Host identity collected by gpservice.
pub host_info: HostInfo,
}