diff --git a/ddclient.in b/ddclient.in index e299a2e..4c4e6cf 100755 --- a/ddclient.in +++ b/ddclient.in @@ -156,8 +156,8 @@ our %config; # it was just before the previous update attempt. Values are synchronized from `%config` to # `%recap` during each update attempt. # -# The set of config change detection variables is currently hard-coded; all other recap variables -# are assumed to be status variables. +# A protocol's set of config change detection variables can be found in the protocol's +# `force_update_if_changed` property; all other recap variables are assumed to be status variables. # # A note about terminology: This was previously named `%cache`, but "cache" implies that the # purpose is to reduce the cost or latency of data retrieval or computation, and that deletion only @@ -168,8 +168,6 @@ our %config; # compatibility concerns with the public `--cache` option.) our %recap; -our @recap_config_change_detection_vars = qw(static wildcard mx backupmx); - my $result; my $saved_recap; my %saved_opt; @@ -853,6 +851,7 @@ our %protocols = ( %{$variables{'dyndns-common-defaults'}}, 'static' => setv(T_BOOL, 0, 1, 0, undef), }, + 'force_update_if_changed' => [qw(static wildcard mx backupmx)], }, 'dyndns2' => { 'update' => \&nic_dyndns2_update, @@ -862,6 +861,7 @@ our %protocols = ( %{$variables{'dyndns-common-defaults'}}, 'script' => setv(T_STRING, 0, 0, '/nic/update', undef), }, + 'force_update_if_changed' => [qw(wildcard mx backupmx)], }, 'easydns' => { 'update' => \&nic_easydns_update, @@ -877,6 +877,7 @@ our %protocols = ( 'script' => setv(T_STRING, 0, 0, '/dyn/generic.php', undef), 'wildcard' => setv(T_BOOL, 0, 1, 0, undef), }, + 'force_update_if_changed' => [qw(wildcard mx backupmx)], }, 'freedns' => { 'update' => \&nic_freedns_update, @@ -1487,8 +1488,9 @@ sub update_nics { # `update` sees consistent values between `%recap` and `%config`. This reduces # the impact of Hyrum's Law; if a protocol needs a variable to be updated after # the `update` method is called then that behavior should be made explicit. - my $vars = $protocols{opt('protocol', $h)}{variables}; - for my $v (@recap_config_change_detection_vars) { + my $protocol = $protocols{$p}; + my $vars = $protocol->{variables}; + for my $v (@{$protocol->{force_update_if_changed} // []}) { next if !$vars->{$v} || !$vars->{$v}{recap}; if (defined(my $val = opt($v, $h))) { $recap{$h}{$v} = $val; @@ -3536,7 +3538,7 @@ sub nic_updateable { my $rv = $recap{$host}{$_}; my $cv = opt($_, $host); defined($rv) && defined($cv) && $rv ne $cv; - } @recap_config_change_detection_vars)) { + } @{$protocol->{force_update_if_changed} // []})) { info("update forced because options changed: " . join(', ', @changed)); $update = 1;