dnsexit2: Simplify IP version loop
This commit is contained in:
parent
40d1bc8e51
commit
7c4fe28bab
1 changed files with 5 additions and 11 deletions
16
ddclient.in
16
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);
|
||||
|
|
Loading…
Reference in a new issue