Commit graph

1512 commits

Author SHA1 Message Date
Richard Hansen
c9cdb96086 read_recap: Fix copying of recap values into %config 2024-09-01 20:02:34 -04:00
Richard Hansen
fbd7167b94 read_recap: Fix iteration over hosts 2024-09-01 18:08:10 -04:00
Richard Hansen
35cbc8d200 read_recap: Reference %recap directly (for readability)
There's no need to pass a reference to `%recap` as an argument when
that is the only way `read_recap` is ever used.
2024-09-01 18:08:10 -04:00
Richard Hansen
31740006d0 read_recap: Use a named loop variable (for readability) 2024-09-01 18:08:10 -04:00
Richard Hansen
65d2473213 read_recap: Don't load ip from recap
This should have been part of commit
de5d894c91 but I forgot.
2024-09-01 18:08:10 -04:00
Richard Hansen
ce1bcaa68b nic_updateable: Set warned-min-* in %config, not %recap
Currently the semantics of recap variables are that values are updated
in `%config` and propagate to `%recap`.  Before this commit,
`warned-min-interval` and `warned-min-error-interval` were set in
`%recap` instead of `%config`, meaning if they followed the semantics
they would be overwritten or deleted when synced with `%config`.  Now
the values are set in `%config` to match the behavior of other recap
variables.
2024-09-01 18:08:10 -04:00
Richard Hansen
e8b3d9168b Remove unnecessary variables from the recap
The logic does not use the persisted values so they do not need to be
persisted.
2024-09-01 18:08:10 -04:00
Richard Hansen
c943d7c0d9 tests: Add some unit tests for read_recap 2024-09-01 18:05:53 -04:00
Richard Hansen
0a9ee106e4 tests: Debug log when in protocol update callback 2024-09-01 02:44:05 -04:00
Richard Hansen
7181152c78 cloudflare: Delete unused variable declarations 2024-09-01 01:01:33 -04:00
Richard Hansen
4b5f28b2f0 Add/update TODO comments for problematic bits of code 2024-09-01 00:59:55 -04:00
Richard Hansen
cf54da50e4 read_recap: Invert condition (for readability) 2024-09-01 00:54:41 -04:00
Richard Hansen
c2db690efb Whitespace fixes 2024-09-01 00:54:41 -04:00
Richard Hansen
3dafdbf604
Merge pull request #732 from rhansen/legacy-status
Fix handling of legacy `status` value
2024-08-22 04:20:37 -04:00
Richard Hansen
de5d894c91 Fix handling of legacy status value
When a legacy protocol implementation returns, move its `status` and
`ip` results to the new `status-ipv4` and `ipv4` (or `status-ipv6` and
`ipv6`) properties.

Also remove the now-unused `status` variable definition, and remove
`ip` from the recap.
2024-08-22 02:08:39 -04:00
Richard Hansen
4f89492dc0 nic_updateable: Use wantip definedness, not use enabledness
Rather than check whether `use`, `usev4`, or `usev6` is a non-disabled
value, check that `wantip`, `wantipv4`, or `wantipv6` is a defined
value.  This is preparation for removing the `status` variable in a
future commit.
2024-08-22 02:08:39 -04:00
Richard Hansen
a21e215ada Reduce unnecessary values in %config and %recap
* Delete values from `$config{$h}` and `$recap{$h}` when resetting
    values (as opposed to setting a falsy value).
  * Delete values from `$config{$h}` and `$recap{$h}` when they are no
    longer needed.

This is mostly done to improve the tests in `t/update_nics.pl`.
2024-08-22 02:08:39 -04:00
Richard Hansen
acd8dfe47f Don't force use to disabled if usev4 or usev6 is enabled
Now that the default changes depending on `usev4` and `usev6`, this is
no longer necessary.  Removing it simplifies the code a bit and makes
the behavior of unit tests match the overall behavior a bit better.
2024-08-22 02:08:39 -04:00
Richard Hansen
f024bcce34 Dynamically compute default for use based on usev4, usev6
This is mostly to simplify tests, but it also improves readability.

The infrastructure changes in this commit also make it possible to
introduce a new `url` variable that defaults to `opt('server', $h)`
concatenated with `opt('script', $h)` so that we can start migrating
away from those user-unfriendly variables.
2024-08-22 02:08:39 -04:00
Richard Hansen
46bd2f1771 tests: Also test default() return value 2024-08-22 02:08:39 -04:00
Richard Hansen
f23070a114 Change defaults for warned-min{,-error}-interval from 0 to undef
The code already treats `undef` and 0 the same, and `undef` omits them
from the recap which simplifies testing.
2024-08-22 02:08:39 -04:00
Richard Hansen
603a59ffe3 Delete redundant variable declarations from global-defaults 2024-08-22 02:08:39 -04:00
Richard Hansen
533e4735cd init_config: Support any variable as a command-line arg
This doesn't add any new command-line arguments, but it does mean that
a new command-line argument can be added for any variable, not just
those in `$variables{'global-defaults'}`, and its value will be copied
to `%globals`.

My main motivation for this commit is to make it possible to remove
the redundant variable declarations between
`$variables{'global-defaults'}` and
`$variables{'protocol-common-defaults'}`.
2024-08-22 02:08:39 -04:00
Richard Hansen
b9ec2d42a3 Remove the (broken and unused?) --retry option 2024-08-22 02:08:39 -04:00
Richard Hansen
555359dc98 tests: Add unit tests for legacy protocol handling in nic_updateable 2024-08-22 02:08:39 -04:00
Richard Hansen
80bbf1dc43
Merge pull request #734 from rhansen/cache
Don't write undefined recap values to the cache file
2024-08-19 17:35:45 -04:00
Richard Hansen
1631b465d5 Don't write undefined recap values to the cache file
There might be a semantic difference between `undef` and the empty
string, so it is incorrect to write an empty string when the value is
`undef`.
2024-08-19 17:29:59 -04:00
Richard Hansen
ed1d480617 Update PR TODOs in ChangeLog.md
I forgot to update these before merging PR #733.
2024-08-18 01:29:37 -04:00
Richard Hansen
12ff5bfbdc
Merge pull request #733 from rhansen/config
Option processing improvements
2024-08-18 01:27:40 -04:00
Richard Hansen
442eac96c7 Update changelog for recent config fixes 2024-08-18 01:22:53 -04:00
Richard Hansen
3be5b91601 Improve documentation for --host and --options command-line args 2024-08-18 01:22:53 -04:00
Richard Hansen
a06c532394 Call load_sha1_support, load_json_support once 2024-08-18 01:22:53 -04:00
Richard Hansen
42f720df86 Move --options validation to where it is processed 2024-08-18 01:22:53 -04:00
Richard Hansen
967bf2f6e8 Error out if given an unknown per-host option 2024-08-18 01:22:53 -04:00
Richard Hansen
564b315bfa Convert command-line argument warnings into fatal errors 2024-08-18 01:22:53 -04:00
Richard Hansen
18bd312216 Don't initialize $config{$h} entries to undef
There's no need -- if the key doesn't exist the value returned is
already `undef`.  This prevents debug output from being littered with
`undef` lines.
2024-08-18 01:22:53 -04:00
Richard Hansen
e8f0358bbb Rely on opt() fallback if a value is invalid 2024-08-18 01:22:53 -04:00
Richard Hansen
2b65aff56b Use opt() instead of accessing %config directly
This makes it possible to leave `$config{$h}{$var}` undefined to have
it fall back to `%opt`, `%globals`, or the variable's default value.
2024-08-18 01:22:52 -04:00
Richard Hansen
912bc6291a group_hosts_by: Treat undef as unset for consistency with opt
The `opt` function falls back to global/default if the value is
undefined, even if it is explicitly set to `undef`.  `group_hosts_by`
should behave the same.
2024-08-18 01:21:40 -04:00
Richard Hansen
5a66efe79e Delete unnecessary defined() check 2024-08-18 00:45:04 -04:00
Richard Hansen
478f517d53 Delete no-effect option normalization
The alternative is to "fix" the code to match the original intention,
but users haven't been complaining so it's better to avoid the risk of
introducing a new bug in the fix.
2024-08-18 00:45:04 -04:00
Richard Hansen
7fde55c188 Don't initialize %opt entries to undef
There's no need -- if the key doesn't exist the value returned is
already `undef`.  This prevents debug output from being littered with
`undef` lines.
2024-08-18 00:45:04 -04:00
Richard Hansen
fe1768316a Use protocol-specific default when known
Different protocols can have different default values for a particular
variable.  Grab the protocol-specific variable definition if given a
hostname when looking up the variable's default.
2024-08-18 00:45:04 -04:00
Richard Hansen
775b7fcbfe Validate and normalize all command-line arguments 2024-08-18 00:45:04 -04:00
Richard Hansen
bbf98dd031 Use parse_assignments to process --options
This simplifies the code and enables quoting of special characters.
2024-08-18 00:41:28 -04:00
Richard Hansen
270a82dd58 parse_assignments: Support newlines
Allow newlines to be in values, but stop searching for assignments
once an unescaped/unquoted newline is discovered.  This is preparation
to using `parse_assignments` to process the `--options` command-line
argument, which might have embedded newlines.
2024-08-18 00:41:28 -04:00
Richard Hansen
4c7634855b Move *_env processing to parse_assignment
This makes the behavior transparent to the rest of ddclient, which
will make it possible for a future commit to simplify option
processing.
2024-08-18 00:41:28 -04:00
Richard Hansen
19848852a4 check_value: Mention supported values if given an invalid value 2024-08-18 00:41:28 -04:00
Richard Hansen
ed2afde72d check_value: die if the value is invalid
This makes it possible to convey details about why the value was
deemed invalid.  It also allows `undef` to be treated as a valid
value.
2024-08-18 00:41:28 -04:00
Richard Hansen
2f8a4ba00a Use opt() instead of accessing %opt or %globals directly
This is for consistency, and to ensure that all possible ways of
configuring are respected.
2024-08-18 00:41:28 -04:00