diff --git a/src/go_daddy_ddns/mod.rs b/src/go_daddy_ddns/mod.rs new file mode 100644 index 0000000..134d283 --- /dev/null +++ b/src/go_daddy_ddns/mod.rs @@ -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> { + 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(()) +} diff --git a/src/main.rs b/src/main.rs index ec6e178..da47538 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,13 @@ +mod go_daddy_ddns; mod ip_handler; -use ip_handler::ip_has_changed; +use go_daddy_ddns::*; #[tokio::main] async fn main() -> Result<(), Box> { + // 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 { - println!("Ip has changed!"); - } - - Ok(()) + go_daddy_ddns::exec("a", "b", "c").await }