Added some logging lines.
This commit is contained in:
parent
cae24f70c1
commit
504fc87b83
|
@ -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<dyn std::error::Error>> {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> {
|
|||
.await
|
||||
.expect("Error getting the current IP.");
|
||||
|
||||
debug!("Current IP: {}, Previous IP: {}", current_ip, previous_ip);
|
||||
|
||||
if current_ip.eq(&previous_ip) {
|
||||
return None;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue