dyndns2: fix multiline parsing and multiple host handling (#542)

This commit is contained in:
Franco Fichtner 2023-06-01 10:46:04 +02:00 committed by GitHub
parent 841ffcbdaa
commit 1c91a5aa84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4194,30 +4194,38 @@ sub nic_dyndns2_update {
# bug #10: some dyndns providers does not return the IP so # bug #10: some dyndns providers does not return the IP so
# we can't use the returned IP # we can't use the returned IP
my ($status, $returnedips) = split / /, lc $line; my ($status, $returnedips) = split / /, lc $line;
my $h = shift @hosts;
foreach my $h (@hosts) {
$config{$h}{'status'} = $status; $config{$h}{'status'} = $status;
$config{$h}{'status-ipv4'} = $status if $ipv4; $config{$h}{'status-ipv4'} = $status if $ipv4;
$config{$h}{'status-ipv6'} = $status if $ipv6; $config{$h}{'status-ipv6'} = $status if $ipv6;
}
if ($status eq 'good') { if ($status eq 'good') {
foreach my $h (@hosts) {
$config{$h}{'ipv4'} = $ipv4 if $ipv4; $config{$h}{'ipv4'} = $ipv4 if $ipv4;
$config{$h}{'ipv6'} = $ipv6 if $ipv6; $config{$h}{'ipv6'} = $ipv6 if $ipv6;
$config{$h}{'mtime'} = $now; $config{$h}{'mtime'} = $now;
success("updating %s: %s: IPv4 address set to %s", $h, $status, $ipv4) if $ipv4; }
success("updating %s: %s: IPv6 address set to %s", $h, $status, $ipv6) if $ipv6;
success("updating %s: %s: IPv4 address set to %s", $hosts, $status, $ipv4) if $ipv4;
success("updating %s: %s: IPv6 address set to %s", $hosts, $status, $ipv6) if $ipv6;
} elsif (exists $errors{$status}) { } elsif (exists $errors{$status}) {
if ($status eq 'nochg') { if ($status eq 'nochg') {
warning("updating %s: %s: %s", $h, $status, $errors{$status}); warning("updating %s: %s: %s", $hosts, $status, $errors{$status});
foreach my $h (@hosts) {
$config{$h}{'ipv4'} = $ipv4 if $ipv4; $config{$h}{'ipv4'} = $ipv4 if $ipv4;
$config{$h}{'ipv6'} = $ipv6 if $ipv6; $config{$h}{'ipv6'} = $ipv6 if $ipv6;
$config{$h}{'mtime'} = $now; $config{$h}{'mtime'} = $now;
$config{$h}{'status'} = 'good'; $config{$h}{'status'} = 'good';
$config{$h}{'status-ipv4'} = 'good' if $ipv4; $config{$h}{'status-ipv4'} = 'good' if $ipv4;
$config{$h}{'status-ipv6'} = 'good' if $ipv6; $config{$h}{'status-ipv6'} = 'good' if $ipv6;
}
} else { } else {
failed("updating %s: %s: %s", $h, $status, $errors{$status}); failed("updating %s: %s: %s", $hosts, $status, $errors{$status});
} }
} elsif ($status =~ /w(\d+)(.)/) { } elsif ($status =~ /w(\d+)(.)/) {
@ -4229,11 +4237,14 @@ sub nic_dyndns2_update {
($scale, $units) = (60*60, 'hours') if $units eq 'h'; ($scale, $units) = (60*60, 'hours') if $units eq 'h';
$sec = $wait * $scale; $sec = $wait * $scale;
foreach my $h (@hosts) {
$config{$h}{'wtime'} = $now + $sec; $config{$h}{'wtime'} = $now + $sec;
warning("updating %s: %s: wait %s %s before further updates", $h, $status, $wait, $units); }
warning("updating %s: %s: wait %s %s before further updates", $hosts, $status, $wait, $units);
} else { } else {
failed("updating %s: unexpected status (%s)", $h, $line); failed("updating %s: unexpected status (%s)", $hosts, $line);
} }
} }
} }