From f8b812ff8449cf420f41619db6c910f451b56629 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Thu, 8 Jul 2021 09:55:10 +0200 Subject: [PATCH] Add domains in configuration file. --- src/main.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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"; -- 2.45.2