X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmain.rs;h=67c251a9b668376c6eaf081fa6151b63160bedbd;hb=f66ea654402cb0a44d075466a1a55a89b5512e4a;hp=3c3b4f5e09ee62d0e283e00a6a831ae48d288208;hpb=79787cfdf89c320de9b12080b04f56ac38c39073;p=gandi_dns_update.git diff --git a/src/main.rs b/src/main.rs index 3c3b4f5..67c251a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ #![cfg_attr(debug_assertions, allow(unused_variables, unused_imports, dead_code))] -use std::{ fmt::format, fs::File, net::{ IpAddr, Ipv4Addr }, thread, time }; +use std::{ fs::File, net::{ IpAddr, Ipv4Addr }, thread, time }; use ron::{ de::from_reader, ser::to_writer }; use serde::{ Deserialize, Serialize }; use serde_json::{ Value, json }; @@ -32,7 +32,7 @@ impl std::fmt::Display for Error { impl std::error::Error for Error { } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] struct Config { delay_between_check: time::Duration, api_key: String, @@ -68,7 +68,7 @@ fn main() -> Result<()> { let config = Config::read(FILE_CONF)?; - println!("Configuration: {:?}", config); + println!("Configuration: {:?}", Config { api_key: String::from("*****"), ..config.clone() }); loop { let time_beginning_loop = time::Instant::now(); @@ -88,11 +88,9 @@ fn main() -> Result<()> { fn check_and_update_dns(api_key: &str, fqdn: &str, domains: &Vec, ttl: i32) -> Result<()> { let real_ip = get_real_ip()?; - dbg!(&real_ip); for domain in domains { let current_ip = get_current_record_ip(api_key, domain, fqdn)?; - dbg!(domain, current_ip); if real_ip != current_ip { println!("IP addresses don't match for domain {}: real = {}, dns = {}. Renewing DNS...", domain, real_ip, current_ip); @@ -177,7 +175,7 @@ fn update_record_ip(api_key: &str, name: &str, fqdn: &str, ip: Ipv4Addr, ttl: i3 let json_value = request_livedns_gandi(api_key, &format!("domains/{}/records/{}/A", fqdn, name), Method::Put(json_body.to_string()))?; - dbg!(json_value); + println!("Update response: {}", json_value); Ok(()) }