mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
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:
92 files changed
+9847
-2868
No files matched your search
@@ -3,21 +3,28 @@ use xmltree::Element;
|
||||
|
||||
use crate::utils::xml::ElementExt;
|
||||
|
||||
use super::{Gateway, PriorityRule};
|
||||
use super::{Gateway, GatewayKind, PriorityRule};
|
||||
|
||||
pub(crate) fn parse_gateways(element: &Element, prefer_internal: bool) -> Option<Vec<Gateway>> {
|
||||
let node_gateways = element.descendant("gateways")?;
|
||||
let internal_gateway_list = if prefer_internal {
|
||||
info!("Try to parse the internal gateways...");
|
||||
node_gateways.descendant("internal").and_then(|n| n.child("list"))
|
||||
node_gateways
|
||||
.descendant("internal")
|
||||
.and_then(|n| n.child("list"))
|
||||
.map(|list| (list, GatewayKind::Internal))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let gateway_list = internal_gateway_list.or_else(|| {
|
||||
info!("Try to parse the external gateways...");
|
||||
node_gateways.descendant("external").and_then(|n| n.child("list"))
|
||||
node_gateways
|
||||
.descendant("external")
|
||||
.and_then(|n| n.child("list"))
|
||||
.map(|list| (list, GatewayKind::External))
|
||||
})?;
|
||||
let (gateway_list, kind) = gateway_list;
|
||||
|
||||
let gateways = gateway_list
|
||||
.children("entry")
|
||||
@@ -28,12 +35,13 @@ pub(crate) fn parse_gateways(element: &Element, prefer_internal: bool) -> Option
|
||||
let priority = parse_priority(gateway_item);
|
||||
let priority_rules = gateway_item
|
||||
.child("priority-rule")
|
||||
.map(|n| parse_priority_rules(n))
|
||||
.map(parse_priority_rules)
|
||||
.unwrap_or_default();
|
||||
|
||||
Gateway {
|
||||
name,
|
||||
address,
|
||||
kind,
|
||||
priority,
|
||||
priority_rules,
|
||||
}
|
||||
@@ -62,3 +70,54 @@ fn parse_priority(element: &Element) -> u32 {
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(u32::MAX)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parse_external_gateways_marks_gateway_kind() {
|
||||
let xml = r#"
|
||||
<policy>
|
||||
<gateways>
|
||||
<external>
|
||||
<list>
|
||||
<entry name="us1.vpn.example.com">
|
||||
<description>US_East</description>
|
||||
</entry>
|
||||
</list>
|
||||
</external>
|
||||
</gateways>
|
||||
</policy>
|
||||
"#;
|
||||
let root = Element::parse(xml.as_bytes()).unwrap();
|
||||
|
||||
let gateways = parse_gateways(&root, false).unwrap();
|
||||
|
||||
assert_eq!(gateways[0].name(), "US_East");
|
||||
assert_eq!(gateways[0].server(), "us1.vpn.example.com");
|
||||
assert_eq!(gateways[0].kind(), GatewayKind::External);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_internal_gateways_marks_gateway_kind_when_preferred() {
|
||||
let xml = r#"
|
||||
<policy>
|
||||
<gateways>
|
||||
<internal>
|
||||
<list>
|
||||
<entry name="internal.vpn.example.com">
|
||||
<description>Internal</description>
|
||||
</entry>
|
||||
</list>
|
||||
</internal>
|
||||
</gateways>
|
||||
</policy>
|
||||
"#;
|
||||
let root = Element::parse(xml.as_bytes()).unwrap();
|
||||
|
||||
let gateways = parse_gateways(&root, true).unwrap();
|
||||
|
||||
assert_eq!(gateways[0].kind(), GatewayKind::Internal);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user