Potential Bugfix whereby the code threw an otherwise unexplained error

This commit is contained in:
Neshura 2023-12-29 01:56:48 +01:00
parent 6588bf20a5
commit 0a9eba9732
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
3 changed files with 4 additions and 16 deletions

View file

@ -1,5 +1,4 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::env::VarError;
use std::error::Error; use std::error::Error;
use std::net::{Ipv4Addr, Ipv6Addr}; use std::net::{Ipv4Addr, Ipv6Addr};
use log::{error, warn}; use log::{error, warn};
@ -33,14 +32,14 @@ pub(crate) struct CloudflareZone {
} }
impl CloudflareZone { impl CloudflareZone {
pub(crate) fn new(zone: &ZoneConfig, config: &AppConfig) -> Result<Self, VarError> { pub(crate) fn new(zone: &ZoneConfig, config: &AppConfig) -> Self {
let key = config.cloudflare_api_token.clone(); let key = config.cloudflare_api_token.clone();
Ok(Self { Self {
name: zone.name.clone(), name: zone.name.clone(),
email: zone.email.clone(), email: zone.email.clone(),
key, key,
id: zone.id.clone(), id: zone.id.clone(),
}) }
} }
fn generate_auth_headers(&self) -> HeaderMap { fn generate_auth_headers(&self) -> HeaderMap {

View file

@ -142,7 +142,6 @@ impl Default for ZoneConfig {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub(crate) struct AppConfig { pub(crate) struct AppConfig {
#[serde(alias="cf_api_token")]
pub(crate) cloudflare_api_token: String, pub(crate) cloudflare_api_token: String,
pub(crate) check_interval_seconds: Option<u16>, pub(crate) check_interval_seconds: Option<u16>,
pub(crate) uptime_url: Option<String>, pub(crate) uptime_url: Option<String>,

View file

@ -559,17 +559,7 @@ fn main() {
ips.update(); ips.update();
for zone in &zone_cfgs { for zone in &zone_cfgs {
let cf_zone = match CloudflareZone::new(zone, &config) { let cf_zone = 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_entries = match cf_zone.get_entries() { let cf_entries = match cf_zone.get_entries() {
Ok(entries) => entries, Ok(entries) => entries,