Skip to content

Commit

Permalink
Change: Refactor IP filtering logic in spawn_tasks
Browse files Browse the repository at this point in the history
function
  • Loading branch information
pchpub committed Dec 9, 2023
1 parent 77d0355 commit 1194fb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/mods/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::time::Duration;
use log::{error, trace};
use tokio::time::sleep;

use crate::mods::{interfaces::AddressType, types::AddressVersion};

use super::{
interfaces::{get_interface_ips, get_interfaces},
providers::DDNSProviderTrait,
Expand Down Expand Up @@ -47,7 +49,7 @@ pub async fn spawn_tasks() -> Result<(), String> {
.into_iter()
.filter(|ip| match ip {
super::interfaces::IPAddress::V4(_ip, address_type) => {
if site.address_version.to_string() == "V4".to_string()
if site.address_version == AddressVersion::V4
&& *address_type == site.address_type
{
true
Expand All @@ -56,7 +58,7 @@ pub async fn spawn_tasks() -> Result<(), String> {
}
}
super::interfaces::IPAddress::V6(_ip, address_type) => {
if site.address_version.to_string() == "V6".to_string()
if site.address_version == AddressVersion::V6
&& *address_type == site.address_type
{
true
Expand Down
2 changes: 1 addition & 1 deletion src/mods/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct SiteConfig {
pub retry_on_failure: bool,
}

#[derive(Deserialize, Serialize, Clone)]
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq)]
pub enum AddressVersion {
V4,
V6,
Expand Down

0 comments on commit 1194fb9

Please sign in to comment.