From: Greg Burri Date: Thu, 8 Jul 2021 07:55:10 +0000 (+0200) Subject: Add domains in configuration file. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=f8b812ff8449cf420f41619db6c910f451b56629;p=gandi_dns_update.git Add domains in configuration file. --- diff --git a/src/main.rs b/src/main.rs index e6eadc8..65367e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,12 @@ * 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 = std::result::Result>; @@ -21,17 +23,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 +128,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";