Convert static list of config change detection vars to per-protocol
This commit is contained in:
parent
273af1c821
commit
2da08cceb9
1 changed files with 9 additions and 7 deletions
16
ddclient.in
16
ddclient.in
|
@ -156,8 +156,8 @@ our %config;
|
||||||
# it was just before the previous update attempt. Values are synchronized from `%config` to
|
# it was just before the previous update attempt. Values are synchronized from `%config` to
|
||||||
# `%recap` during each update attempt.
|
# `%recap` during each update attempt.
|
||||||
#
|
#
|
||||||
# The set of config change detection variables is currently hard-coded; all other recap variables
|
# A protocol's set of config change detection variables can be found in the protocol's
|
||||||
# are assumed to be status variables.
|
# `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
|
# 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
|
# 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.)
|
# compatibility concerns with the public `--cache` option.)
|
||||||
our %recap;
|
our %recap;
|
||||||
|
|
||||||
our @recap_config_change_detection_vars = qw(static wildcard mx backupmx);
|
|
||||||
|
|
||||||
my $result;
|
my $result;
|
||||||
my $saved_recap;
|
my $saved_recap;
|
||||||
my %saved_opt;
|
my %saved_opt;
|
||||||
|
@ -853,6 +851,7 @@ our %protocols = (
|
||||||
%{$variables{'dyndns-common-defaults'}},
|
%{$variables{'dyndns-common-defaults'}},
|
||||||
'static' => setv(T_BOOL, 0, 1, 0, undef),
|
'static' => setv(T_BOOL, 0, 1, 0, undef),
|
||||||
},
|
},
|
||||||
|
'force_update_if_changed' => [qw(static wildcard mx backupmx)],
|
||||||
},
|
},
|
||||||
'dyndns2' => {
|
'dyndns2' => {
|
||||||
'update' => \&nic_dyndns2_update,
|
'update' => \&nic_dyndns2_update,
|
||||||
|
@ -862,6 +861,7 @@ our %protocols = (
|
||||||
%{$variables{'dyndns-common-defaults'}},
|
%{$variables{'dyndns-common-defaults'}},
|
||||||
'script' => setv(T_STRING, 0, 0, '/nic/update', undef),
|
'script' => setv(T_STRING, 0, 0, '/nic/update', undef),
|
||||||
},
|
},
|
||||||
|
'force_update_if_changed' => [qw(wildcard mx backupmx)],
|
||||||
},
|
},
|
||||||
'easydns' => {
|
'easydns' => {
|
||||||
'update' => \&nic_easydns_update,
|
'update' => \&nic_easydns_update,
|
||||||
|
@ -877,6 +877,7 @@ our %protocols = (
|
||||||
'script' => setv(T_STRING, 0, 0, '/dyn/generic.php', undef),
|
'script' => setv(T_STRING, 0, 0, '/dyn/generic.php', undef),
|
||||||
'wildcard' => setv(T_BOOL, 0, 1, 0, undef),
|
'wildcard' => setv(T_BOOL, 0, 1, 0, undef),
|
||||||
},
|
},
|
||||||
|
'force_update_if_changed' => [qw(wildcard mx backupmx)],
|
||||||
},
|
},
|
||||||
'freedns' => {
|
'freedns' => {
|
||||||
'update' => \&nic_freedns_update,
|
'update' => \&nic_freedns_update,
|
||||||
|
@ -1487,8 +1488,9 @@ sub update_nics {
|
||||||
# `update` sees consistent values between `%recap` and `%config`. This reduces
|
# `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 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.
|
# the `update` method is called then that behavior should be made explicit.
|
||||||
my $vars = $protocols{opt('protocol', $h)}{variables};
|
my $protocol = $protocols{$p};
|
||||||
for my $v (@recap_config_change_detection_vars) {
|
my $vars = $protocol->{variables};
|
||||||
|
for my $v (@{$protocol->{force_update_if_changed} // []}) {
|
||||||
next if !$vars->{$v} || !$vars->{$v}{recap};
|
next if !$vars->{$v} || !$vars->{$v}{recap};
|
||||||
if (defined(my $val = opt($v, $h))) {
|
if (defined(my $val = opt($v, $h))) {
|
||||||
$recap{$h}{$v} = $val;
|
$recap{$h}{$v} = $val;
|
||||||
|
@ -3536,7 +3538,7 @@ sub nic_updateable {
|
||||||
my $rv = $recap{$host}{$_};
|
my $rv = $recap{$host}{$_};
|
||||||
my $cv = opt($_, $host);
|
my $cv = opt($_, $host);
|
||||||
defined($rv) && defined($cv) && $rv ne $cv;
|
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));
|
info("update forced because options changed: " . join(', ', @changed));
|
||||||
$update = 1;
|
$update = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue