From 13c9c544a7e7ce1f8e34e7d38762d54e78d77bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Fri, 31 Jan 2025 21:45:47 +0100 Subject: [PATCH] fix(webnsupdate): updating IPv6 in ipv4-only mode Dumb logic error T-T. --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0a21937..bea4268 100644 --- a/src/main.rs +++ b/src/main.rs @@ -517,20 +517,20 @@ async fn update_records( if let Some(ip) = ipv4 { let ip = IpAddr::V4(ip); - if !state.ip_type.valid_for_type(ip) { + if state.ip_type.valid_for_type(ip) { + _ = trigger_update(ip, &state).await?; + } else { tracing::warn!("requested update of IPv4 but we are {}", state.ip_type); } - - _ = trigger_update(ip, &state).await?; } if let Some(ip) = ipv6 { let ip = IpAddr::V6(ip); - if !state.ip_type.valid_for_type(ip) { + if state.ip_type.valid_for_type(ip) { + _ = trigger_update(ip, &state).await?; + } else { tracing::warn!("requested update of IPv6 but we are {}", state.ip_type); } - - _ = trigger_update(ip, &state).await?; } Ok("Successfully updated IP of records!\n") @@ -566,13 +566,13 @@ async fn trigger_update( error!("nsupdate failed with code {status}"); Err(( StatusCode::INTERNAL_SERVER_ERROR, - "nsupdate failed, check server logs", + "nsupdate failed, check server logs\n", ) .into()) } Err(error) => Err(( StatusCode::INTERNAL_SERVER_ERROR, - format!("failed to update records: {error}"), + format!("failed to update records: {error}\n"), ) .into()), }