diff --git a/src/go_daddy_ddns/mod.rs b/src/go_daddy_ddns/mod.rs index e877ec1..6e6933f 100644 --- a/src/go_daddy_ddns/mod.rs +++ b/src/go_daddy_ddns/mod.rs @@ -1,5 +1,6 @@ use std::fs::read_to_string; use std::path::Path; +use log::{debug, info}; use serde::{Deserialize, Serialize}; @@ -57,16 +58,18 @@ struct DNSRecordCreateTypeName { /// /// * `secret` - A &str holding the GoDaddy developer secret. pub async fn exec(domain: &str, key: &str, secret: &str) -> Result<(), Box> { + info!("Checking if the IP has changed."); let new_ip = get_ip_to_publish().await; // There's no need to do anything here. So we stop the execution. if Option::is_none(&new_ip) { + info!("The IP hasn't changed. Let's stop the execution here."); return Ok(()); } - let records = get_records(); - - for record in records { + info!("The IP has changed. Let's update the DNS records."); + for record in get_records() { + debug!("{:?}", record); update_record(&record, &new_ip.clone().unwrap(), domain, key, secret).await; } diff --git a/src/ip_handler/mod.rs b/src/ip_handler/mod.rs index 5f476d2..5a57565 100644 --- a/src/ip_handler/mod.rs +++ b/src/ip_handler/mod.rs @@ -2,6 +2,7 @@ use serde::Deserialize; use std::fs::{read_to_string, File}; use std::io::Write; use std::path::Path; +use log::debug; const IP_FILE_NAME: &'static str = "ddns_ip"; const WEBSITE_URL: &'static str = "https://httpbin.org/ip"; @@ -22,6 +23,8 @@ pub async fn get_ip_to_publish() -> Option { .await .expect("Error getting the current IP."); + debug!("Current IP: {}, Previous IP: {}", current_ip, previous_ip); + if current_ip.eq(&previous_ip) { return None; }