feat(wip): Support opnsense 25.7 which defaults to dnsmasq instead of isc dhcp
This commit is contained in:
111
opnsense-config-xml/src/data/dnsmasq.rs
Normal file
111
opnsense-config-xml/src/data/dnsmasq.rs
Normal file
@@ -0,0 +1,111 @@
|
||||
use yaserde::MaybeString;
|
||||
use yaserde_derive::{YaDeserialize, YaSerialize};
|
||||
|
||||
// This is the top-level struct that represents the entire <dnsmasq> element.
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct DnsMasq {
|
||||
#[yaserde(attribute = true)]
|
||||
pub version: String,
|
||||
#[yaserde(attribute = true)]
|
||||
pub persisted_at: Option<String>,
|
||||
|
||||
pub enable: u8,
|
||||
pub regdhcp: u8,
|
||||
pub regdhcpstatic: u8,
|
||||
pub dhcpfirst: u8,
|
||||
pub strict_order: u8,
|
||||
pub domain_needed: u8,
|
||||
pub no_private_reverse: u8,
|
||||
pub no_resolv: Option<u8>,
|
||||
pub log_queries: u8,
|
||||
pub no_hosts: u8,
|
||||
pub strictbind: u8,
|
||||
pub dnssec: u8,
|
||||
pub regdhcpdomain: MaybeString,
|
||||
pub interface: Option<String>,
|
||||
pub port: Option<u32>,
|
||||
pub dns_forward_max: MaybeString,
|
||||
pub cache_size: MaybeString,
|
||||
pub local_ttl: MaybeString,
|
||||
pub add_mac: Option<MaybeString>,
|
||||
pub add_subnet: Option<u8>,
|
||||
pub strip_subnet: Option<u8>,
|
||||
pub no_ident: Option<u8>,
|
||||
pub dhcp: Option<Dhcp>,
|
||||
pub dhcp_ranges: Vec<DhcpRange>,
|
||||
pub dhcp_options: Vec<DhcpOptions>,
|
||||
pub dhcp_boot: Vec<DhcpBoot>,
|
||||
}
|
||||
|
||||
// Represents the <dhcp> element and its nested fields.
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
#[yaserde(rename = "dhcp")]
|
||||
pub struct Dhcp {
|
||||
pub no_interface: MaybeString,
|
||||
pub fqdn: u8,
|
||||
pub domain: MaybeString,
|
||||
pub lease_max: MaybeString,
|
||||
pub authoritative: u8,
|
||||
pub default_fw_rules: u8,
|
||||
pub reply_delay: MaybeString,
|
||||
pub enable_ra: u8,
|
||||
pub nosync: u8,
|
||||
}
|
||||
|
||||
// Represents a single <dhcp_ranges> element.
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
#[yaserde(rename = "dhcp_ranges")]
|
||||
pub struct DhcpRange {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: String,
|
||||
pub interface: String,
|
||||
pub set_tag: MaybeString,
|
||||
pub start_addr: String,
|
||||
pub end_addr: String,
|
||||
pub subnet_mask: MaybeString,
|
||||
pub constructor: MaybeString,
|
||||
pub mode: MaybeString,
|
||||
pub prefix_len: MaybeString,
|
||||
pub lease_time: MaybeString,
|
||||
pub domain_type: String,
|
||||
pub domain: MaybeString,
|
||||
pub nosync: u8,
|
||||
pub ra_mode: MaybeString,
|
||||
pub ra_priority: MaybeString,
|
||||
pub ra_mtu: MaybeString,
|
||||
pub ra_interval: MaybeString,
|
||||
pub ra_router_lifetime: MaybeString,
|
||||
pub description: MaybeString,
|
||||
}
|
||||
|
||||
// Represents a single <dhcp_boot> element.
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
#[yaserde(rename = "dhcp_boot")]
|
||||
pub struct DhcpBoot {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: String,
|
||||
pub interface: MaybeString,
|
||||
pub tag: MaybeString,
|
||||
pub filename: String,
|
||||
pub servername: String,
|
||||
pub address: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
// Represents a single <dhcp_options> element.
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
#[yaserde(rename = "dhcp_options")]
|
||||
pub struct DhcpOptions {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: String,
|
||||
#[yaserde(rename = "type")]
|
||||
pub _type: String,
|
||||
pub option: MaybeString,
|
||||
pub option6: MaybeString,
|
||||
pub interface: MaybeString,
|
||||
pub tag: MaybeString,
|
||||
pub set_tag: MaybeString,
|
||||
pub value: String,
|
||||
pub force: u8,
|
||||
pub description: MaybeString,
|
||||
}
|
||||
@@ -8,10 +8,12 @@ pub struct Interface {
|
||||
#[yaserde(rename = "if")]
|
||||
pub physical_interface_name: String,
|
||||
pub descr: Option<MaybeString>,
|
||||
pub mtu: Option<MaybeString>,
|
||||
pub enable: MaybeString,
|
||||
pub lock: Option<MaybeString>,
|
||||
#[yaserde(rename = "spoofmac")]
|
||||
pub spoof_mac: Option<MaybeString>,
|
||||
pub mss: Option<MaybeString>,
|
||||
pub ipaddr: Option<MaybeString>,
|
||||
pub dhcphostname: Option<MaybeString>,
|
||||
#[yaserde(rename = "alias-address")]
|
||||
|
||||
@@ -3,6 +3,7 @@ mod dhcpd;
|
||||
mod haproxy;
|
||||
mod interfaces;
|
||||
mod opnsense;
|
||||
pub mod dnsmasq;
|
||||
pub use caddy::*;
|
||||
pub use dhcpd::*;
|
||||
pub use haproxy::*;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::dnsmasq::DnsMasq;
|
||||
use crate::HAProxy;
|
||||
use crate::{data::dhcpd::DhcpInterface, xml_utils::to_xml_str};
|
||||
use log::error;
|
||||
@@ -22,7 +23,7 @@ pub struct OPNsense {
|
||||
pub load_balancer: Option<LoadBalancer>,
|
||||
pub rrd: Option<RawXml>,
|
||||
pub ntpd: Ntpd,
|
||||
pub widgets: Widgets,
|
||||
pub widgets: Option<Widgets>,
|
||||
pub revision: Revision,
|
||||
#[yaserde(rename = "OPNsense")]
|
||||
pub opnsense: OPNsenseXmlSection,
|
||||
@@ -45,7 +46,7 @@ pub struct OPNsense {
|
||||
#[yaserde(rename = "Pischem")]
|
||||
pub pischem: Option<Pischem>,
|
||||
pub ifgroups: Ifgroups,
|
||||
pub dnsmasq: Option<RawXml>,
|
||||
pub dnsmasq: Option<DnsMasq>,
|
||||
}
|
||||
|
||||
impl From<String> for OPNsense {
|
||||
@@ -165,9 +166,9 @@ pub struct Sysctl {
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct SysctlItem {
|
||||
pub descr: MaybeString,
|
||||
pub tunable: String,
|
||||
pub value: MaybeString,
|
||||
pub descr: Option<MaybeString>,
|
||||
pub tunable: Option<String>,
|
||||
pub value: Option<MaybeString>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
@@ -182,8 +183,8 @@ pub struct System {
|
||||
pub domain: String,
|
||||
pub group: Vec<Group>,
|
||||
pub user: Vec<User>,
|
||||
pub nextuid: u32,
|
||||
pub nextgid: u32,
|
||||
pub nextuid: Option<u32>,
|
||||
pub nextgid: Option<u32>,
|
||||
pub timezone: String,
|
||||
pub timeservers: String,
|
||||
pub webgui: WebGui,
|
||||
@@ -242,6 +243,7 @@ pub struct Ssh {
|
||||
pub passwordauth: u8,
|
||||
pub keysig: MaybeString,
|
||||
pub permitrootlogin: u8,
|
||||
pub rekeylimit: Option<MaybeString>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
@@ -271,6 +273,7 @@ pub struct Group {
|
||||
pub member: Vec<u32>,
|
||||
#[yaserde(rename = "priv")]
|
||||
pub priv_field: String,
|
||||
pub source_networks: Option<MaybeString>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
|
||||
Reference in New Issue
Block a user