aboutsummaryrefslogtreecommitdiff
path: root/src/provider
diff options
context:
space:
mode:
Diffstat (limited to 'src/provider')
-rw-r--r--src/provider/gandi.rs30
-rw-r--r--src/provider/mod.rs17
2 files changed, 38 insertions, 9 deletions
diff --git a/src/provider/gandi.rs b/src/provider/gandi.rs
index eeff641..0658db2 100644
--- a/src/provider/gandi.rs
+++ b/src/provider/gandi.rs
@@ -56,10 +56,16 @@ impl DnsProvider for GandiProvider {
"gandi"
}
- async fn update_a(&self, domain: &str, subdomain: &str, targets: &[Ipv4Addr]) -> Result<()> {
+ async fn update_a(
+ &self,
+ domain: &str,
+ subdomain: Option<&str>,
+ targets: &[Ipv4Addr],
+ ) -> Result<()> {
let url = format!(
"https://api.gandi.net/v5/livedns/domains/{}/records/{}/A",
- domain, subdomain
+ domain,
+ subdomain.unwrap_or("@")
);
let rrset = GandiRrset {
@@ -70,10 +76,16 @@ impl DnsProvider for GandiProvider {
self.put_rrset(&url, &rrset).await
}
- async fn update_aaaa(&self, domain: &str, subdomain: &str, targets: &[Ipv6Addr]) -> Result<()> {
+ async fn update_aaaa(
+ &self,
+ domain: &str,
+ subdomain: Option<&str>,
+ targets: &[Ipv6Addr],
+ ) -> Result<()> {
let url = format!(
"https://api.gandi.net/v5/livedns/domains/{}/records/{}/AAAA",
- domain, subdomain
+ domain,
+ subdomain.unwrap_or("@")
);
let rrset = GandiRrset {
@@ -84,10 +96,16 @@ impl DnsProvider for GandiProvider {
self.put_rrset(&url, &rrset).await
}
- async fn update_cname(&self, domain: &str, subdomain: &str, target: &str) -> Result<()> {
+ async fn update_cname(
+ &self,
+ domain: &str,
+ subdomain: Option<&str>,
+ target: &str,
+ ) -> Result<()> {
let url = format!(
"https://api.gandi.net/v5/livedns/domains/{}/records/{}/CNAME",
- domain, subdomain
+ domain,
+ subdomain.unwrap_or("@")
);
let rrset = GandiRrset {
diff --git a/src/provider/mod.rs b/src/provider/mod.rs
index 6527631..1ef6b0f 100644
--- a/src/provider/mod.rs
+++ b/src/provider/mod.rs
@@ -8,9 +8,20 @@ use async_trait::async_trait;
#[async_trait]
pub trait DnsProvider: Send + Sync {
fn provider(&self) -> &'static str;
- async fn update_a(&self, domain: &str, subdomain: &str, targets: &[Ipv4Addr]) -> Result<()>;
- async fn update_aaaa(&self, domain: &str, subdomain: &str, targets: &[Ipv6Addr]) -> Result<()>;
- async fn update_cname(&self, domain: &str, subdomain: &str, target: &str) -> Result<()>;
+ async fn update_a(
+ &self,
+ domain: &str,
+ subdomain: Option<&str>,
+ targets: &[Ipv4Addr],
+ ) -> Result<()>;
+ async fn update_aaaa(
+ &self,
+ domain: &str,
+ subdomain: Option<&str>,
+ targets: &[Ipv6Addr],
+ ) -> Result<()>;
+ async fn update_cname(&self, domain: &str, subdomain: Option<&str>, target: &str)
+ -> Result<()>;
}
impl std::fmt::Debug for dyn DnsProvider {