mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
refactor: improve the XML parsing
This commit is contained in:
@@ -5,18 +5,18 @@ use crate::utils::xml::NodeExt;
|
||||
|
||||
use super::{Gateway, PriorityRule};
|
||||
|
||||
pub(crate) fn parse_gateways(node: &Node, use_internal: bool) -> Option<Vec<Gateway>> {
|
||||
let node_gateways = node.find_child("gateways")?;
|
||||
let internal_gateway_list = if use_internal {
|
||||
info!("Using internal gateways");
|
||||
node_gateways.find_child("internal").and_then(|n| n.find_child("list"))
|
||||
pub(crate) fn parse_gateways(node: &Node, prefer_internal: bool) -> Option<Vec<Gateway>> {
|
||||
let node_gateways = node.find_descendant("gateways")?;
|
||||
let internal_gateway_list = if prefer_internal {
|
||||
info!("Try to parse the internal gateways...");
|
||||
node_gateways.find_descendant("internal").and_then(|n| n.find_child("list"))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let gateway_list = internal_gateway_list.or_else(|| {
|
||||
info!("Using external gateways");
|
||||
node_gateways.find_child("external").and_then(|n| n.find_child("list"))
|
||||
info!("Try to parse the external gateways...");
|
||||
node_gateways.find_descendant("external").and_then(|n| n.find_child("list"))
|
||||
})?;
|
||||
|
||||
let gateways = gateway_list
|
||||
|
Reference in New Issue
Block a user