wip: Actual implementation of opnsense dhcp
This commit is contained in:
parent
b0fc55e1fb
commit
465106438a
@ -1,10 +1,10 @@
|
|||||||
mod management;
|
mod management;
|
||||||
pub use management::*;
|
pub use management::*;
|
||||||
|
|
||||||
use crate::topology::{
|
use crate::{executors::ExecutorError, topology::{
|
||||||
Backend, DHCPStaticEntry, DhcpServer, DnsServer, Firewall, FirewallError, FirewallRule,
|
Backend, DHCPStaticEntry, DhcpServer, DnsServer, Firewall, FirewallError, FirewallRule,
|
||||||
Frontend, IpAddress, LoadBalancer, LoadBalancerError, LogicalHost,
|
Frontend, IpAddress, LoadBalancer, LoadBalancerError, LogicalHost,
|
||||||
};
|
}};
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
|
|
||||||
#[derive(new, Clone)]
|
#[derive(new, Clone)]
|
||||||
@ -16,6 +16,10 @@ impl OPNSenseFirewall {
|
|||||||
pub fn get_ip(&self) -> IpAddress {
|
pub fn get_ip(&self) -> IpAddress {
|
||||||
self.host.ip
|
self.host.ip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn save_xml_to_config(&self, xml_entry: &str) -> Result<(), ExecutorError> {
|
||||||
|
todo!("Save XML Entry in opnsense /conf/config.xml {xml_entry}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Firewall for OPNSenseFirewall {
|
impl Firewall for OPNSenseFirewall {
|
||||||
@ -77,6 +81,20 @@ impl DhcpServer for OPNSenseFirewall {
|
|||||||
&self,
|
&self,
|
||||||
entry: &DHCPStaticEntry,
|
entry: &DHCPStaticEntry,
|
||||||
) -> Result<(), crate::topology::DhcpError> {
|
) -> Result<(), crate::topology::DhcpError> {
|
||||||
|
let mac = &entry.mac;
|
||||||
|
let name = &entry.name;
|
||||||
|
let ip = &entry.ip;
|
||||||
|
|
||||||
|
let xml_entry = format!("<staticmap>
|
||||||
|
> <mac>{mac}</mac>
|
||||||
|
> <ipaddr>{ip}</ipaddr>
|
||||||
|
> <hostname>{name}</hostname>
|
||||||
|
> <descr>{name}</descr>
|
||||||
|
> <winsserver/>
|
||||||
|
> <dnsserver/>
|
||||||
|
> <ntpserver/>
|
||||||
|
> </staticmap>");
|
||||||
|
self.save_xml_to_config(&xml_entry)?;
|
||||||
todo!("Register {:?}", entry)
|
todo!("Register {:?}", entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user