X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmain.rs;h=fa7584ecbb8f9234ed082a4ee59ed53788bbc1c5;hb=81a586e4cbc435651174131d75f05cf33094678c;hp=e6eadc837839132256a59d9a69d29947e3b7cf44;hpb=a741015a5979b2a18e997b1efe39f604c98812ca;p=gandi_dns_update.git diff --git a/src/main.rs b/src/main.rs index e6eadc8..fa7584e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,16 @@ /* * API Reference: https://api.gandi.net/docs/livedns/ - * Some inspiration: https://github.com/rmarchant/gandi-ddns/blob/master/gandi_ddns.py + * Some similar implementations: + * - https://github.com/rmarchant/gandi-ddns/blob/master/gandi_ddns.py + * - https://github.com/brianhp2/gandi-automatic-dns */ -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 = std::result::Result>; @@ -21,17 +25,18 @@ impl std::fmt::Display for 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, } 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 { @@ -125,10 +130,11 @@ fn request_livedns_gandi(api_key: &str, url_fragment: &str) -> Result { fn get_current_record_ip(api_key: &str) -> Result { - 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";