From 0a9eba9732c6038de3e1b36ef1b446fe6bce058b Mon Sep 17 00:00:00 2001 From: Neshura Date: Fri, 29 Dec 2023 01:56:48 +0100 Subject: [PATCH] Potential Bugfix whereby the code threw an otherwise unexplained error --- src/cloudflare.rs | 7 +++---- src/config.rs | 1 - src/main.rs | 12 +----------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/cloudflare.rs b/src/cloudflare.rs index 700788f..0a56378 100644 --- a/src/cloudflare.rs +++ b/src/cloudflare.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::env::VarError; use std::error::Error; use std::net::{Ipv4Addr, Ipv6Addr}; use log::{error, warn}; @@ -33,14 +32,14 @@ pub(crate) struct CloudflareZone { } impl CloudflareZone { - pub(crate) fn new(zone: &ZoneConfig, config: &AppConfig) -> Result { + pub(crate) fn new(zone: &ZoneConfig, config: &AppConfig) -> Self { let key = config.cloudflare_api_token.clone(); - Ok(Self { + Self { name: zone.name.clone(), email: zone.email.clone(), key, id: zone.id.clone(), - }) + } } fn generate_auth_headers(&self) -> HeaderMap { diff --git a/src/config.rs b/src/config.rs index 2652cfa..3d5a8ea 100644 --- a/src/config.rs +++ b/src/config.rs @@ -142,7 +142,6 @@ impl Default for ZoneConfig { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub(crate) struct AppConfig { - #[serde(alias="cf_api_token")] pub(crate) cloudflare_api_token: String, pub(crate) check_interval_seconds: Option, pub(crate) uptime_url: Option, diff --git a/src/main.rs b/src/main.rs index f549057..10ad192 100644 --- a/src/main.rs +++ b/src/main.rs @@ -559,17 +559,7 @@ fn main() { ips.update(); for zone in &zone_cfgs { - let cf_zone = match CloudflareZone::new(zone, &config) { - Ok(data) => data, - Err(e) => { - let err_msg = format!("Cloudflare Token likely not set. Error: {}", e); - match connected_to_journal() { - true => error!("[ERROR] {err_msg}"), - false => eprintln!("[ERROR] {err_msg}"), - } - continue - } - }; + let cf_zone = CloudflareZone::new(zone, &config); let cf_entries = match cf_zone.get_entries() { Ok(entries) => entries,