feat: OKD Dhcp config works and is actually savec on opnsense firewall, its alive!! First real run on wk cluster

This commit is contained in:
Jean-Gabriel Gill-Couture
2024-12-17 15:15:41 -05:00
parent d0d81af796
commit b15df3c93f
10 changed files with 132 additions and 41 deletions

View File

@@ -24,9 +24,10 @@ impl SshConfigManager {
impl SshConfigManager {
async fn backup_config_remote(&self) -> Result<String, Error> {
let backup_filename = format!("config_{}.xml", chrono::Local::now().format("%Y%m%d%H%M%S"));
let ts = chrono::Utc::now();
let backup_filename = format!("config-{}-harmony.xml", ts.format("%s%.3f"));
self.opnsense_shell.exec(&format!("cp /conf/config.xml /tmp/{}", backup_filename))
self.opnsense_shell.exec(&format!("cp /conf/config.xml /conf/backup/{}", backup_filename))
.await
}

View File

@@ -84,9 +84,13 @@ impl<'a> DhcpConfig<'a> {
return Err(DhcpError::InvalidMacAddress(mac));
}
if !Self::is_ip_in_range(&ipaddr, range) {
return Err(DhcpError::IpAddressOutOfRange(ipaddr.to_string()));
}
// TODO verify if address is in subnet range
// This check here does not do what we want to do, as we want to assign static leases
// outside of the dynamic DHCP pool
//
// if !Self::is_ip_in_range(&ipaddr, range) {
// return Err(DhcpError::IpAddressOutOfRange(ipaddr.to_string()));
// }
if existing_mappings.iter().any(|m| {
m.ipaddr
@@ -123,7 +127,7 @@ impl<'a> DhcpConfig<'a> {
parts
.iter()
.all(|part| part.len() == 2 && part.chars().all(|c| c.is_ascii_hexdigit()))
.all(|part| part.len() <= 2 && part.chars().all(|c| c.is_ascii_hexdigit()))
}
fn is_ip_in_range(ip: &Ipv4Addr, range: &Range) -> bool {