dyndns2: Improve readability of status parsing

This commit is contained in:
Richard Hansen 2024-07-13 04:33:44 -04:00
parent 88f140d470
commit 90de2f9606

View file

@ -4133,9 +4133,12 @@ sub nic_dyndns2_update {
# TODO: The logic below applies the last line's status to all hosts. Change it to apply
# each status to its corresponding host.
for my $line (@reply) {
# bug #10: some dyndns providers does not return the IP so
# we can't use the returned IP
my ($status, $returnedips) = split / /, lc $line;
# The IP address normally comes after the status, but we ignore it. We could compare
# it with the expected address and mark the update as failed if it differs, but (1)
# some services do not return the IP; and (2) comparison is brittle (e.g.,
# 192.000.002.001 vs. 192.0.2.1) and false errors could cause high load on the service
# (an update attempt every min-error-interval instead of every max-interval).
(my $status = $line) =~ s/ .*$//;
if ($status eq 'nochg') {
warning("updating %s: %s: %s", $hosts, $status, $errors{$status});
$status = 'good';