use crate::{active_children, value_after};
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct NextHopTunnel {
pub gateway_address: String,
pub ipsec_vpn: String,
}
pub(super) fn parse_next_hop_tunnels(family: &ConfigLine) -> Vec<NextHopTunnel> {
active_children(family)
.filter_map(|c| {
let words: Vec<&str> = c.arg("next-hop-tunnel")?.split_whitespace().collect();
Some(NextHopTunnel {
gateway_address: words.first()?.to_string(),
ipsec_vpn: value_after(&words, "ipsec-vpn")?,
})
})
.collect()
}