feat: add internal host detection support (#384)

This commit is contained in:
Ruben Rodriguez authored and GitHub committed 2024-07-02 21:30:34 +08:00
1 parent 6357a4087d
commit 26dbd8d312
6 files changed
+90 -3

No files matched your search

+10 -2
View File
@@ -2,9 +2,17 @@ use roxmltree::Document;
use super::{Gateway, PriorityRule};
pub(crate) fn parse_gateways(doc: &Document) -> Option<Vec<Gateway>> {
pub(crate) fn parse_gateways(doc: &Document, external: bool) -> Option<Vec<Gateway>> {
let node_gateways = doc.descendants().find(|n| n.has_tag_name("gateways"))?;
let list_gateway = node_gateways.descendants().find(|n| n.has_tag_name("list"))?;
// if external flag is set, look for external gateways, otherwise look for internal gateways
let kind_gateways = if external {
node_gateways.descendants().find(|n| n.has_tag_name("external"))?
} else {
node_gateways.descendants().find(|n| n.has_tag_name("internal"))?
};
let list_gateway = kind_gateways.descendants().find(|n| n.has_tag_name("list"))?;
let gateways = list_gateway
.children()