* Some inspiration: https://github.com/rmarchant/gandi-ddns/blob/master/gandi_ddns.py
*/
-use std::{fmt::format, fs::File, net::{ IpAddr, Ipv4Addr }, thread, time};
+#![cfg_attr(debug_assertions, allow(unused_variables, unused_imports, dead_code))]
+
+use std::{ fmt::format, fs::File, net::{ IpAddr, Ipv4Addr }, thread, time };
use ron::{ de::from_reader, ser::to_writer };
use serde::{ Deserialize, Serialize };
-use serde_json::{ Value };
+use serde_json::Value;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
}
}
-impl std::error::Error for Error {}
+impl std::error::Error for Error { }
#[derive(Debug, Deserialize, Serialize)]
struct Config {
delay_between_check: time::Duration,
api_key: String,
+ domains: Vec<String>,
}
impl Config {
fn default() -> Self {
- Config { delay_between_check: time::Duration::from_secs(60), api_key: String::from("") }
+ Config { delay_between_check: time::Duration::from_secs(60), api_key: String::from(""), domains: Vec::new() }
}
fn read(file_path: &str) -> Result<Config> {
fn get_current_record_ip(api_key: &str) -> Result<Ipv4Addr> {
- request_livedns_gandi(api_key, "domains/euphorik.ch/records/home/A"); // TODO...
+ request_livedns_gandi(api_key, "domains/euphorik.ch/records/home/A")?; // TODO...
// .map()
//.map(|json_value| json_value["rrset_values"][0].as_str().unwrap())
+ Result::Err(Box::new(Error { message: String::new() }))
//let url = "https://api.gandi.net/v5/livedns/domains/euphorik.ch/records";