update_nics: Move legacy wantip assignment to update call

This consolidates the legacy support with other legacy support logic,
which will make it easier to refactor in a future commit.
This commit is contained in:
Richard Hansen 2024-08-29 13:18:20 -04:00
parent c5df774b7e
commit bf83ba032c

View file

@ -685,10 +685,10 @@ our %variables = (
# TODO: Create a timestamp type and change this to that type. # TODO: Create a timestamp type and change this to that type.
'atime' => setv(T_NUMBER,0, 1, 0, undef), 'atime' => setv(T_NUMBER,0, 1, 0, undef),
# Disposition of the most recent (or currently in progress) attempt to update the DDNS # Disposition of the most recent (or currently in progress) attempt to update the DDNS
# service with the IP address in `wantipv4` (or `wantip`, if an IPv4 address). Anything # service with the IP address in `wantipv4`. Anything other than `good`, including undef,
# other than `good`, including undef, is treated as a failure. # is treated as a failure.
'status-ipv4' => setv(T_ANY, 0, 1, undef, undef), 'status-ipv4' => setv(T_ANY, 0, 1, undef, undef),
# As `status-ipv4`, but with `wantipv6` (or `wantip`, if an IPv6 address). # As `status-ipv4`, but with `wantipv6`.
'status-ipv6' => setv(T_ANY, 0, 1, undef, undef), 'status-ipv6' => setv(T_ANY, 0, 1, undef, undef),
# Timestamp (seconds since epoch) of the most recent attempt that would have been made had # Timestamp (seconds since epoch) of the most recent attempt that would have been made had
# `min-interval` not inhibited the attempt. This is reset to 0 once an attempt is actually # `min-interval` not inhibited the attempt. This is reset to 0 once an attempt is actually
@ -1437,11 +1437,10 @@ sub update_nics {
$ip //= $ipv4 // $ipv6; $ip //= $ipv4 // $ipv6;
$ipv4 //= $ip if is_ipv4($ip); $ipv4 //= $ip if is_ipv4($ip);
$ipv6 //= $ip if is_ipv6($ip); $ipv6 //= $ip if is_ipv6($ip);
$config{$h}{'wantip'} = $ip;
$config{$h}{'wantipv4'} = $ipv4; $config{$h}{'wantipv4'} = $ipv4;
$config{$h}{'wantipv6'} = $ipv6; $config{$h}{'wantipv6'} = $ipv6;
if (!$ip && !$ipv4 && !$ipv6) { if (!$ipv4 && !$ipv6) {
warning('unable to determine IP address'); warning('unable to determine IP address');
next; next;
} }
@ -1455,6 +1454,11 @@ sub update_nics {
if (@hosts) { if (@hosts) {
$0 = sprintf("%s - updating %s", $program, join(',', @hosts)); $0 = sprintf("%s - updating %s", $program, join(',', @hosts));
local $_l = pushlogctx($p); local $_l = pushlogctx($p);
for my $h (@hosts) {
# TODO: Remove this once all legacy protocol implementations have been upgraded to
# read `wantipv4` and `wantipv6` directly.
$config{$h}{'wantip'} = $config{$h}{'wantipv4'} // $config{$h}{'wantipv6'};
}
&$update(@hosts); &$update(@hosts);
for my $h (@hosts) { for my $h (@hosts) {
delete($config{$h}{$_}) for qw(wantip wantipv4 wantipv6); delete($config{$h}{$_}) for qw(wantip wantipv4 wantipv6);