dyndns2: Refine log messages

This commit is contained in:
Richard Hansen 2024-07-18 05:19:58 -04:00
parent 1e73f4a51a
commit adfd68d5e0

View file

@ -4084,12 +4084,11 @@ sub nic_dyndns2_update {
my $ipv6 = $groupcfg{'wantipv6'}; my $ipv6 = $groupcfg{'wantipv6'};
delete $config{$_}{'wantipv4'} for @hosts; delete $config{$_}{'wantipv4'} for @hosts;
delete $config{$_}{'wantipv6'} for @hosts; delete $config{$_}{'wantipv6'} for @hosts;
info("setting IPv4 address to %s for %s", $ipv4, $hosts) if $ipv4; info("$hosts: setting IPv4 address to $ipv4") if $ipv4;
info("setting IPv6 address to %s for %s", $ipv6, $hosts) if $ipv6; info("$hosts: setting IPv6 address to $ipv6") if $ipv6;
verbose("UPDATE:", "updating %s", $hosts);
my $url = "$groupcfg{'server'}$groupcfg{'script'}?system="; my $url = "$groupcfg{'server'}$groupcfg{'script'}?system=";
if ($groupcfg{'custom'}) { if ($groupcfg{'custom'}) {
warning("updating %s: 'custom' and 'static' may not be used together. ('static' ignored)", $hosts) warning("$hosts: 'custom' and 'static' may not be used together ('static' ignored)")
if $groupcfg{'static'}; if $groupcfg{'static'};
$url .= 'custom'; $url .= 'custom';
} elsif ($groupcfg{'static'}) { } elsif ($groupcfg{'static'}) {
@ -4117,7 +4116,7 @@ sub nic_dyndns2_update {
password => $groupcfg{'password'}, password => $groupcfg{'password'},
) // ''; ) // '';
if ($reply eq '') { if ($reply eq '') {
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'}); failed("$hosts: Could not connect to $groupcfg{'server'}");
next; next;
} }
next if !header_ok($hosts, $reply); next if !header_ok($hosts, $reply);
@ -4126,7 +4125,7 @@ sub nic_dyndns2_update {
(my $body = $reply) =~ s/^.*?\n\n//s; (my $body = $reply) =~ s/^.*?\n\n//s;
my @reply = split(qr/\n/, $body); my @reply = split(qr/\n/, $body);
if (!@reply) { if (!@reply) {
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'}); failed("$hosts: Could not connect to $groupcfg{'server'}");
next; next;
} }
# From <https://help.dyn.com/remote-access-api/return-codes/>: # From <https://help.dyn.com/remote-access-api/return-codes/>:
@ -4152,7 +4151,7 @@ sub nic_dyndns2_update {
# (an update attempt every min-error-interval instead of every max-interval). # (an update attempt every min-error-interval instead of every max-interval).
(my $status = $line) =~ s/ .*$//; (my $status = $line) =~ s/ .*$//;
if ($status eq 'nochg') { if ($status eq 'nochg') {
warning("updating %s: %s: %s", $hosts, $status, $errors{$status}); warning("$hosts: $status: $errors{$status}");
$status = 'good'; $status = 'good';
} }
for my $h (@hosts) { for my $h (@hosts) {
@ -4161,7 +4160,7 @@ sub nic_dyndns2_update {
} }
if ($status ne 'good') { if ($status ne 'good') {
if (exists($errors{$status})) { if (exists($errors{$status})) {
failed("updating %s: %s: %s", $hosts, $status, $errors{$status}); failed("$hosts: $status: $errors{$status}");
} elsif ($status =~ qr/w(\d+)(.)/) { } elsif ($status =~ qr/w(\d+)(.)/) {
# TODO: <https://help.dyn.com/remote-access-api/return-codes/> does not mention # TODO: <https://help.dyn.com/remote-access-api/return-codes/> does not mention
# anything about wait statuses. Is this obsolete (this code has been here # anything about wait statuses. Is this obsolete (this code has been here
@ -4176,9 +4175,9 @@ sub nic_dyndns2_update {
for my $h (@hosts) { for my $h (@hosts) {
$config{$h}{'wtime'} = $now + $sec; $config{$h}{'wtime'} = $now + $sec;
} }
warning("updating %s: %s: wait %s %s before further updates", $hosts, $status, $wait, $units); warning("$hosts: wait $wait $units before further updates");
} else { } else {
failed("updating %s: unexpected status (%s)", $hosts, $line); failed("$hosts: unexpected status: $line");
} }
next; next;
} }
@ -4187,8 +4186,8 @@ sub nic_dyndns2_update {
$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", $hosts, $status, $ipv4) if $ipv4; success("$hosts: IPv4 address set to $ipv4") if $ipv4;
success("updating %s: %s: IPv6 address set to %s", $hosts, $status, $ipv6) if $ipv6; success("$hosts: IPv6 address set to $ipv6") if $ipv6;
} }
} }
} }