Potential Bugfix whereby the code threw an otherwise unexplained error
This commit is contained in:
parent
6588bf20a5
commit
0a9eba9732
3 changed files with 4 additions and 16 deletions
|
@ -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<Self, VarError> {
|
||||
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 {
|
||||
|
|
|
@ -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<u16>,
|
||||
pub(crate) uptime_url: Option<String>,
|
||||
|
|
12
src/main.rs
12
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,
|
||||
|
|
Loading…
Reference in a new issue