use std::sync::Arc; use opnsense_config_xml::{Host, OPNsense}; use crate::config::OPNsenseShell; pub struct DnsConfig<'a> { opnsense: &'a mut OPNsense, opnsense_shell: Arc, } impl<'a> DnsConfig<'a> { pub fn new(opnsense: &'a mut OPNsense, opnsense_shell: Arc) -> Self { Self { opnsense, opnsense_shell, } } pub fn register_hosts(&mut self, mut hosts: Vec) { let unbound = match &mut self.opnsense.opnsense.unboundplus { Some(unbound) => unbound, None => todo!("Handle case where unboundplus is not used"), }; unbound.hosts.hosts.append(&mut hosts); } pub fn get_hosts(&self) -> Vec { let unbound = match &self.opnsense.opnsense.unboundplus { Some(unbound) => unbound, None => todo!("Handle case where unboundplus is not used"), }; unbound.hosts.hosts.clone() } pub fn register_dhcp_leases(&mut self, register: bool) { let unbound = match &mut self.opnsense.opnsense.unboundplus { Some(unbound) => unbound, None => todo!("Handle case where unboundplus is not used"), }; unbound.general.regdhcp = Some(register as i8); unbound.general.regdhcpstatic = Some(register as i8); } }