Created module to handle everything related to GoDaddy.
This commit is contained in:
parent
f6118859ac
commit
ac13a8e435
|
@ -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(())
|
||||||
|
}
|
12
src/main.rs
12
src/main.rs
|
@ -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(())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue