Created module to handle everything related to GoDaddy.

This commit is contained in:
shad0wflame 2021-12-21 20:49:37 +01:00
parent f6118859ac
commit ac13a8e435
2 changed files with 36 additions and 6 deletions

30
src/go_daddy_ddns/mod.rs Normal file
View File

@ -0,0 +1,30 @@
use crate::ip_handler::get_ip_to_publish;
/// Updates the DNS records if the IP has changed and returns the result of the execution.
///
/// # Arguments
///
/// * `domain` - A &str holding the domain to update.
///
/// * `key` - A &str holding the GoDaddy developer key.
///
/// * `secret` - A &str holding the GoDaddy developer secret.
pub async fn exec(domain: &str, key: &str, secret: &str) -> Result<(), Box<dyn std::error::Error>> {
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) {
return Ok(());
}
// TODO: Create a struct representing the structure of
// a JSON file including the DNS Records we want to update.
// TODO: Create that JSON file.
// TODO: Read that JSON file and deserialize it with serde.
// TODO: Update the DNS Records.
Ok(())
}

View File

@ -1,13 +1,13 @@
mod go_daddy_ddns;
mod ip_handler; mod ip_handler;
use ip_handler::ip_has_changed; use go_daddy_ddns::*;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
// TODO: [GoDaddy] - Get the domain from ENV variable to replace "a".
// TODO: [GoDaddy] - Get the key from ENV variable to replace "b".
// TODO: [GoDaddy] - Get the secret from ENV variable to replace "c".
if ip_has_changed().await { go_daddy_ddns::exec("a", "b", "c").await
println!("Ip has changed!");
}
Ok(())
} }