diff --git a/Cargo.toml b/Cargo.toml index 2277f1d..ccbef1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ categories = ["command-line-utilities", "network-programming"] readme = "README.md" [dependencies] -anyhow = "1.0.89" +anyhow = "1.0.90" async-trait = "0.1.83" clap = { version = "4.5.20", features = ["derive"] } hickory-resolver = "0.24.1" @@ -27,7 +27,7 @@ reqwest = { version = "0.12.8", features = [ "rustls-tls", ], default-features = false } serde = { version = "1.0.210", features = ["serde_derive"] } -serde_json = "1.0.128" +serde_json = "1.0.129" smallvec = { version = "1.13.2", features = ["serde"] } stun = "0.6.0" tokio = { version = "1.40.0", features = [ diff --git a/src/client.rs b/src/client.rs index 55bd48c..33528c9 100755 --- a/src/client.rs +++ b/src/client.rs @@ -222,14 +222,18 @@ impl Client { continue; } info!("IP address update detected, updating providers..."); + let mut failed = false; for provider in &self.config.providers { - provider.update(&update, &self.request).await?; + if let Err(error) = provider.update(&update, &self.request).await { + error!("Failed to update provider: {error}"); + failed = true; + } + } + if !failed { + info!("Providers updated successfully wih IP(s): {update}"); + let mut cache = self.cache.write().await; + *cache = update; } - info!("Providers updated successfully wih IP(s): {update}"); - // TODO: Only write on successful update - debug!("Saving IP address update to cache..."); - let mut cache = self.cache.write().await; - *cache = update; } } } diff --git a/src/providers/cloudflare.rs b/src/providers/cloudflare.rs index 5c2e101..539a50a 100644 --- a/src/providers/cloudflare.rs +++ b/src/providers/cloudflare.rs @@ -123,7 +123,8 @@ impl Provider for Cloudflare { if updated.success { debug!("Record updated: {:#?}", updated); } else { - error!("Failed to update record: {:#?}", updated); + error!("Failed to update domain ({}) record: {:#?}", domain.name, updated); + return Err(anyhow!("Failed to update domain ({}) record", domain.name)); } } else { debug!( @@ -148,7 +149,8 @@ impl Provider for Cloudflare { if created.success { debug!("Record created: {:#?}", created); } else { - error!("Failed to create record: {:#?}", created); + error!("Failed to create domain ({}) record: {:#?}", domain.name, created); + return Err(anyhow!("Failed to create domain ({}) record", domain.name)); } }; }