feat: Add score and opnsense implementation to register dhcp leases in dns server
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::{net::Ipv4Addr, sync::Arc, time::Duration};
|
||||
|
||||
use crate::{config::{SshConfigManager, SshCredentials, SshOPNSenseShell}, error::Error, modules::dhcp::DhcpConfig};
|
||||
use crate::{config::{SshConfigManager, SshCredentials, SshOPNSenseShell}, error::Error, modules::{dhcp::DhcpConfig, dns::DnsConfig}};
|
||||
use log::trace;
|
||||
use opnsense_config_xml::OPNsense;
|
||||
use russh::client;
|
||||
@@ -35,6 +35,25 @@ impl Config {
|
||||
DhcpConfig::new(&mut self.opnsense, self.shell.clone())
|
||||
}
|
||||
|
||||
pub fn dns(&mut self) -> DnsConfig {
|
||||
DnsConfig::new(&mut self.opnsense, self.shell.clone())
|
||||
}
|
||||
|
||||
pub async fn restart_dns(&self) -> Result<(), Error> {
|
||||
self.shell.exec("configctl unbound restart").await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Save the config to the repository. This method is meant NOT to reload services, only save
|
||||
/// the config to the live file/database and perhaps take a backup when relevant.
|
||||
pub async fn save(&self) -> Result<(), Error> {
|
||||
self.repository
|
||||
.save_config(&self.opnsense.to_xml())
|
||||
.await
|
||||
}
|
||||
|
||||
/// Save the configuration and reload all services. Be careful with this one as it will cause
|
||||
/// downtime in many cases, such as a PPPoE renegociation
|
||||
pub async fn apply(&self) -> Result<(), Error> {
|
||||
self.repository
|
||||
.apply_new_config(&self.opnsense.to_xml())
|
||||
|
||||
Reference in New Issue
Block a user