wip: OKD Installation full process automation underway, ready to test bootstrapping very soon
Some checks failed
Run Check Script / check (pull_request) Failing after 30s
Some checks failed
Run Check Script / check (pull_request) Failing after 30s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// dnsmasq.rs
|
||||
use crate::modules::dhcp::DhcpError;
|
||||
use log::{debug, info, warn};
|
||||
use opnsense_config_xml::dnsmasq::{DnsMasq, DnsmasqHost};
|
||||
use opnsense_config_xml::dnsmasq::{DhcpRange, DnsMasq, DnsmasqHost}; // Assuming DhcpRange is defined in opnsense_config_xml::dnsmasq
|
||||
use opnsense_config_xml::{MaybeString, StaticMap};
|
||||
use std::collections::HashSet;
|
||||
use std::net::Ipv4Addr;
|
||||
@@ -224,6 +224,36 @@ impl<'a> DhcpConfigDnsMasq<'a> {
|
||||
Ok(static_maps)
|
||||
}
|
||||
|
||||
pub async fn set_dhcp_range(&mut self, start: &str, end: &str) -> Result<(), DhcpError> {
|
||||
let dnsmasq = self.get_dnsmasq();
|
||||
let ranges = &mut dnsmasq.dhcp_ranges;
|
||||
|
||||
// Assuming DnsMasq has dhcp_ranges: Vec<DhcpRange>
|
||||
// Find existing range for "lan" interface
|
||||
if let Some(range) = ranges
|
||||
.iter_mut()
|
||||
.find(|r| r.interface == Some("lan".to_string()))
|
||||
{
|
||||
// Update existing range
|
||||
range.start_addr = Some(start.to_string());
|
||||
range.end_addr = Some(end.to_string());
|
||||
} else {
|
||||
// Create new range
|
||||
let new_range = DhcpRange {
|
||||
uuid: Some(Uuid::new_v4().to_string()),
|
||||
interface: Some("lan".to_string()),
|
||||
start_addr: Some(start.to_string()),
|
||||
end_addr: Some(end.to_string()),
|
||||
domain_type: Some("range".to_string()),
|
||||
nosync: Some(0),
|
||||
..Default::default()
|
||||
};
|
||||
ranges.push(new_range);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_pxe_options(
|
||||
&self,
|
||||
tftp_ip: Option<String>,
|
||||
|
||||
1674
opnsense-config/src/tests/data/config-25.7-dnsmasq-static-host.xml
Normal file
1674
opnsense-config/src/tests/data/config-25.7-dnsmasq-static-host.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user