diff --git a/src/go_daddy_ddns/dns_record.rs b/src/go_daddy_ddns/dns_record.rs new file mode 100644 index 0000000..7752aa0 --- /dev/null +++ b/src/go_daddy_ddns/dns_record.rs @@ -0,0 +1,47 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Deserialize)] +pub struct DNSRecordsHolder { + pub records: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct DNSRecord { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub name: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub record_type: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub port: Option, // SRV Only. + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub priority: Option, // MX and SRV only. + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub protocol: Option, // SRV only. + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub service: Option, // SRV only. + + pub ttl: u32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub interpolate: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub weight: Option, // SRV only. +} diff --git a/src/ip_handler/ip.rs b/src/ip_handler/ip.rs new file mode 100644 index 0000000..461b713 --- /dev/null +++ b/src/ip_handler/ip.rs @@ -0,0 +1,6 @@ +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct IP { + pub origin: String, +} diff --git a/src/ip_handler/mod.rs b/src/ip_handler/mod.rs index 5a57565..bc4c5f9 100644 --- a/src/ip_handler/mod.rs +++ b/src/ip_handler/mod.rs @@ -1,17 +1,16 @@ -use serde::Deserialize; -use std::fs::{read_to_string, File}; +use std::fs::{File, read_to_string}; use std::io::Write; use std::path::Path; + use log::debug; +use crate::ip_handler::ip::IP; + +mod ip; + const IP_FILE_NAME: &'static str = "ddns_ip"; const WEBSITE_URL: &'static str = "https://httpbin.org/ip"; -#[derive(Deserialize)] -struct IP { - origin: String, -} - /// Returns an Option holding the current IP address if the value has changed, otherwise returns None. pub async fn get_ip_to_publish() -> Option { let previous_ip = match check_previous_ip() { diff --git a/src/main.rs b/src/main.rs index 2bd189e..17cfd8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,10 @@ -mod go_daddy_ddns; -mod ip_handler; +use std::env; use log::LevelFilter; use simple_logger::SimpleLogger; -use std::env; + +mod go_daddy_ddns; +mod ip_handler; #[tokio::main] async fn main() -> Result<(), Box> {