Skip to content

Commit

Permalink
fixed clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
DenuxPlays committed Nov 30, 2023
1 parent 591658b commit 81357db
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/config/config.rs → src/configuration/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;

use serde::Deserialize;

use crate::config::domain::Domain;
use crate::configuration::domain::Domain;

pub const CONFIG_FILE: &str = "config.toml";

Expand Down
2 changes: 1 addition & 1 deletion src/config/domain.rs → src/configuration/domain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::config::record_type::DnsRecordType;
use crate::configuration::record_type::DnsRecordType;
use serde::Deserialize;

#[derive(Deserialize, Clone)]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use serde::Deserialize;
use std::fmt::Display;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[allow(clippy::upper_case_acronyms)]
pub enum DnsRecordType {
A,
AAAA,
Expand Down
2 changes: 1 addition & 1 deletion src/dns/updater.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::config::domain::{Domain, Record};
use crate::configuration::domain::{Domain, Record};
use crate::dns::util::build_dns_content;
use cloudflare::endpoints::dns::{UpdateDnsRecord, UpdateDnsRecordParams};
use cloudflare::framework::async_api::Client;
Expand Down
2 changes: 1 addition & 1 deletion src/dns/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::config::record_type::DnsRecordType;
use crate::configuration::record_type::DnsRecordType;
use crate::ip::ip_getter::{get_public_ipv4_address, get_public_ipv6_address};
use cloudflare::endpoints::dns::DnsContent;

Expand Down
2 changes: 1 addition & 1 deletion src/ip/ip_changed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::net::{Ipv4Addr, Ipv6Addr};

use crate::config::record_type::DnsRecordType;
use crate::configuration::record_type::DnsRecordType;
use crate::ip::ip_getter::{get_public_ipv4_address, get_public_ipv6_address};

pub struct LastIpAddresses {
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use std::time::Duration;
use log::{error, info};
use tokio::time::interval;

use crate::config::config::Config;
use crate::config::domain::{Domain, Record};
use crate::configuration::config::Config;
use crate::configuration::domain::{Domain, Record};
use crate::dns::updater::update_dns_record;
use crate::ip::ip_changed::{has_ip_changed, LastIpAddresses};
use crate::util::{build_cloudflare_client, init_logger};

mod config;
mod configuration;
mod dns;
mod ip;
mod util;
Expand All @@ -37,15 +37,15 @@ async fn update_every_record_in_domain(client: &Client, domain: &Domain, last_ip
for record in &domain.records {
if has_ip_changed(record.dns_type, last_ip_addresses).await {
info!("\t[*] Updating record '{}' with type '{}'", &record.dns_name, &record.dns_type);
update_record(&client, domain, &record).await;
update_record(client, domain, record).await;
continue
}
info!("\t[*] Skipping record '{}' with type '{}' because IP has not changed", &record.dns_name, &record.dns_type);
}
}

async fn update_record(client: &Client, domain: &Domain, record: &Record) {
match update_dns_record(&client, domain, &record).await {
match update_dns_record(client, domain, record).await {
Ok(_) => info!("\t\t[*] Successfully updated record '{}' with type '{}'", &record.dns_name, &record.dns_type),
Err(e) => error!("\t\t[*] Failed to update record '{}' with type '{}': {:?}", &record.dns_name, &record.dns_type, e),
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::config::config::Config;
use crate::configuration::config::Config;
use cloudflare::framework::async_api::Client;
use cloudflare::framework::auth::Credentials;
use cloudflare::framework::{Environment, HttpApiClientConfig};
Expand Down

0 comments on commit 81357db

Please sign in to comment.