refactor to work as a lib
This commit is contained in:
@@ -4,6 +4,6 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
dns-update = "0.1"
|
||||
dns-update = { git = "ssh://git@github.com/groche97/dns-update.git" }
|
||||
base64 = "*"
|
||||
dns-config = {path = "../dns-config"}
|
||||
|
||||
@@ -38,21 +38,25 @@ impl DnsManager {
|
||||
|
||||
pub async fn add_domain(
|
||||
&self,
|
||||
domain_name: &String,
|
||||
domain_name: &str,
|
||||
domain_ip: Ipv4Addr,
|
||||
) -> Result<(), dns_update::Error> {
|
||||
let domain = format!("{}.{}", domain_name, self.zone);
|
||||
let domain = self.get_full_domain(domain_name);
|
||||
for dns_updater in &self.dns_updaters {
|
||||
utils::add_domain(dns_updater, &domain, &self.zone, domain_ip).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn del_domain(&self, domain_name: &String) -> Result<(), dns_update::Error> {
|
||||
let domain = format!("{}.{}", domain_name, self.zone);
|
||||
pub async fn del_domain(&self, domain_name: &str) -> Result<(), dns_update::Error> {
|
||||
let domain = self.get_full_domain(domain_name);
|
||||
for dns_updater in &self.dns_updaters {
|
||||
utils::del_domain(dns_updater, &domain, &self.zone).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_full_domain(&self, domain_name: &str) -> String {
|
||||
format!("{}.{}", domain_name, self.zone)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user