From 7c4fe28babc5c94157a80e097f8575c4c2d5e77f Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 29 May 2024 17:57:20 -0400 Subject: [PATCH] dnsexit2: Simplify IP version loop --- ddclient.in | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ddclient.in b/ddclient.in index 87aa995..019dc42 100755 --- a/ddclient.in +++ b/ddclient.in @@ -4174,17 +4174,11 @@ sub nic_dnsexit2_update { # The DNSExit API does not support updating multiple hosts at a time. for my $h (@_) { - my $ipv4 = delete $config{$h}{'wantipv4'}; - my $ipv6 = delete $config{$h}{'wantipv6'}; - # The IPv4 and IPv6 addresses must be updated together in a single API call. my %total_payload; - - for my $ip ($ipv4, $ipv6) { - next if (!$ip); - my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4'; - my $type = ($ip eq ($ipv6 // '')) ? 'AAAA' : 'A'; - + for my $ipv ('4', '6') { + my $ip = delete($config{$h}{"wantipv$ipv"}) or next; + my $type = ($ipv eq '6') ? 'AAAA' : 'A'; info("Going to update IPv%s address to %s for %s.", $ipv, $ip, $h); $config{$h}{'status-ipv$ipv'} = 'failed'; $total_payload{$ipv} = { @@ -4263,8 +4257,8 @@ sub nic_dnsexit2_update { info("Status: %s -- Message: %s", $status, $message); info("Server Message: %s -- Server Details: %s", $response->{'message'}, defined($response->{'details'}) ? $response->{'details'}[0] : "no details received"); - $config{$h}{'status-ipv4'} = $status if $ipv4; - $config{$h}{'status-ipv6'} = $status if $ipv6; + $config{$h}{'status-ipv4'} = $status if $total_payload{'4'}; + $config{$h}{'status-ipv6'} = $status if $total_payload{'6'}; if ($status ne 'good') { if ($status eq 'warning') { warning("%s", $message);