Fixed caching for new providers with legacy 'use' parameter

When the configuration used the legacy 'use' parameter, we already
populated the new internal 'wantipv*' field alongside the legacy
'wantip' field. This allows both old and new providers to work.

The legacy providers set 'status'/'ip'.
The new providers then set 'status-ipv*'/'ipv*'.

The caching logic would look for 'status' and 'ip' when encountering a
'use' parameter in the config. We previously already changed ddclient to
set 'status' when 'status-ipv*' was set. Now we also set 'ip' from
'ipv*'. This ensures caching correctly works.
This commit is contained in:
Lenard Hess 2023-11-13 13:15:12 +01:00
parent 9145dc1bfd
commit 5d022b0520

View file

@ -1345,14 +1345,16 @@ sub update_nics {
&$update(@hosts); &$update(@hosts);
# Backwards compatibility: # Backwards compatibility:
# If we only have 'use', we set 'wantipv4' or 'wantipv6' depending on the IP type of # The legacy 'use' parameter sets 'wantip' and the legacy providers process this and
# 'wantip'. Newer provider implementations such as cloudflare only check 'wantipv*' # set 'ip', 'status' accordingly.
# and set 'status-ipv*' accordingly, ignoring 'wantip' and 'status'. # The new 'usev*' parameters set 'wantipv*' and the new providers set 'ipv*' and 'status-ipv*'.
# For these we then load back the 'status' from 'status-ipv*' to ensure correct # To allow gradual transition, we make sure both the old 'status' and 'ip' are being set
# caching and updating behaviour. # accordingly to what new providers returned in the new 'status-ipv*' and 'ipv*' fields respectively.
foreach my $h (@hosts) { foreach my $h (@hosts) {
$config{$h}{'status'} //= $config{$h}{'status-ipv4'}; $config{$h}{'status'} //= $config{$h}{'status-ipv4'};
$config{$h}{'status'} //= $config{$h}{'status-ipv6'}; $config{$h}{'status'} //= $config{$h}{'status-ipv6'};
$config{$h}{'ip'} //= $config{$h}{'ipv4'};
$config{$h}{'ip'} //= $config{$h}{'ipv6'};
} }
runpostscript(join ' ', keys %ipsv4, keys %ipsv6); runpostscript(join ' ', keys %ipsv4, keys %ipsv6);