diff --git a/ChangeLog.md b/ChangeLog.md index 513f988..b8e2766 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -66,6 +66,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). [#664](https://github.com/ddclient/ddclient/pull/664) * Fixed "Scalar value better written as" Perl warning. [#667](https://github.com/ddclient/ddclient/pull/667) + * Fixed unnecessary repeated updates for some services. + [#670](https://github.com/ddclient/ddclient/pull/670) ## 2023-11-23 v3.11.2 diff --git a/ddclient.in b/ddclient.in index 2bee75a..9c79d5e 100755 --- a/ddclient.in +++ b/ddclient.in @@ -639,9 +639,9 @@ my %variables = ( 'wtime' => setv(T_DELAY, 0, 1, 0, interval('30s')), 'mtime' => setv(T_NUMBER,0, 1, 0, undef), 'atime' => setv(T_NUMBER,0, 1, 0, undef), - 'status' => setv(T_ANY, 0, 1, '', undef), #TODO remove from cache? - 'status-ipv4' => setv(T_ANY, 0, 1, '', undef), - 'status-ipv6' => setv(T_ANY, 0, 1, '', undef), + 'status' => setv(T_ANY, 0, 1, undef, undef), #TODO remove from cache? + 'status-ipv4' => setv(T_ANY, 0, 1, undef, undef), + 'status-ipv6' => setv(T_ANY, 0, 1, undef, undef), 'min-interval' => setv(T_DELAY, 0, 0, interval('30s'), 0), 'max-interval' => setv(T_DELAY, 0, 0, interval('25d'), 0), 'min-error-interval' => setv(T_DELAY, 0, 0, interval('5m'), 0), @@ -1452,10 +1452,8 @@ sub update_nics { # To allow gradual transition, we make sure both the old 'status' and 'ip' are being set # accordingly to what new providers returned in the new 'status-ipv*' and 'ipv*' fields respectively. foreach my $h (@hosts) { - $config{$h}{'status'} //= $config{$h}{'status-ipv4'}; - $config{$h}{'status'} //= $config{$h}{'status-ipv6'}; - $config{$h}{'ip'} //= $config{$h}{'ipv4'}; - $config{$h}{'ip'} //= $config{$h}{'ipv6'}; + $config{$h}{'status'} //= $config{$h}{'status-ipv4'} // $config{$h}{'status-ipv6'}; + $config{$h}{'ip'} //= $config{$h}{'ipv4'} // $config{$h}{'ipv6'}; } runpostscript(join ' ', keys %ipsv4, keys %ipsv6); @@ -1919,7 +1917,7 @@ sub init_config { @hosts = split_by_comma($opt{'host'}); } if (opt('retry')) { - @hosts = map { $_ if $cache{$_}{'status'} ne 'good' } keys %cache; + @hosts = map { $_ if ($cache{$_}{'status'} // '') ne 'good' } keys %cache; } ## remove any other hosts @@ -3568,7 +3566,7 @@ sub nic_updateable { } elsif ( ($use ne 'disabled') && ((!exists($cache{$host}{'ip'})) || ("$cache{$host}{'ip'}" ne "$ip"))) { ## Check whether to update IP address for the "--use" method" - if (($cache{$host}{'status'} eq 'good') && + if ((($cache{$host}{'status'} // '') eq 'good') && !interval_expired($host, 'mtime', 'min-interval')) { warning("skipping update of %s from %s to %s.\nlast updated %s.\nWait at least %s between update attempts.", @@ -3582,7 +3580,7 @@ sub nic_updateable { $cache{$host}{'warned-min-interval'} = $now; - } elsif (($cache{$host}{'status'} ne 'good') && + } elsif ((($cache{$host}{'status'} // '') ne 'good') && !interval_expired($host, 'atime', 'min-error-interval')) { if ( opt('verbose') @@ -3613,7 +3611,7 @@ sub nic_updateable { } elsif ( ($usev4 ne 'disabled') && ((!exists($cache{$host}{'ipv4'})) || ("$cache{$host}{'ipv4'}" ne "$ipv4"))) { ## Check whether to update IPv4 address for the "--usev4" method" - if (($cache{$host}{'status-ipv4'} eq 'good') && + if ((($cache{$host}{'status-ipv4'} // '') eq 'good') && !interval_expired($host, 'mtime', 'min-interval')) { warning("skipping update of %s from %s to %s.\nlast updated %s.\nWait at least %s between update attempts.", @@ -3627,7 +3625,7 @@ sub nic_updateable { $cache{$host}{'warned-min-interval'} = $now; - } elsif (($cache{$host}{'status-ipv4'} ne 'good') && + } elsif ((($cache{$host}{'status-ipv4'} // '') ne 'good') && !interval_expired($host, 'atime', 'min-error-interval')) { if ( opt('verbose') @@ -3658,7 +3656,7 @@ sub nic_updateable { } elsif ( ($usev6 ne 'disabled') && ((!exists($cache{$host}{'ipv6'})) || ("$cache{$host}{'ipv6'}" ne "$ipv6"))) { ## Check whether to update IPv6 address for the "--usev6" method" - if (($cache{$host}{'status-ipv6'} eq 'good') && + if ((($cache{$host}{'status-ipv6'} // '') eq 'good') && !interval_expired($host, 'mtime', 'min-interval')) { warning("skipping update of %s from %s to %s.\nlast updated %s.\nWait at least %s between update attempts.", @@ -3672,7 +3670,7 @@ sub nic_updateable { $cache{$host}{'warned-min-interval'} = $now; - } elsif (($cache{$host}{'status-ipv6'} ne 'good') && + } elsif ((($cache{$host}{'status-ipv6'} // '') ne 'good') && !interval_expired($host, 'atime', 'min-error-interval')) { if ( opt('verbose') @@ -3727,14 +3725,14 @@ sub nic_updateable { } } - $config{$host}{'status'} = $cache{$host}{'status'} // ''; - $config{$host}{'status-ipv4'} = $cache{$host}{'status-ipv4'} // ''; - $config{$host}{'status-ipv6'} = $cache{$host}{'status-ipv6'} // ''; + $config{$host}{'status'} = $cache{$host}{'status'}; + $config{$host}{'status-ipv4'} = $cache{$host}{'status-ipv4'}; + $config{$host}{'status-ipv6'} = $cache{$host}{'status-ipv6'}; $config{$host}{'update'} = $update; if ($update) { - $config{$host}{'status'} = 'noconnect'; - $config{$host}{'status-ipv4'} = 'noconnect'; - $config{$host}{'status-ipv6'} = 'noconnect'; + $config{$host}{'status'} = undef; + $config{$host}{'status-ipv4'} = undef; + $config{$host}{'status-ipv6'} = undef; $config{$host}{'atime'} = $now; $config{$host}{'wtime'} = 0; $config{$host}{'warned-min-interval'} = 0;