Commit graph

1527 commits

Author SHA1 Message Date
Richard Hansen
25fac765a0 nic_updateable: Move clearing of update to write_recap
for readability (the logic that uses the `update` boolean should be
responsible for clearing it).
2024-09-01 20:08:44 -04:00
Richard Hansen
5256a1d02c update_nics: Move legacy protocol support to an adapter function 2024-09-01 20:08:27 -04:00
Richard Hansen
a178d40633 update_nics: Combine post-update host loops 2024-09-01 20:08:10 -04:00
Richard Hansen
bf83ba032c update_nics: Move legacy wantip assignment to update call
This consolidates the legacy support with other legacy support logic,
which will make it easier to refactor in a future commit.
2024-09-01 20:07:53 -04:00
Richard Hansen
c5df774b7e update_nics: Change || next to or next (for readability) 2024-09-01 20:07:36 -04:00
Richard Hansen
20439bc130 update_nics: Refine comment 2024-09-01 20:07:19 -04:00
Richard Hansen
cb66870019 update_nics: Refine debug message for consistency/readability 2024-09-01 20:07:02 -04:00
Richard Hansen
78be40fe2c update_nics: Remove unnecessary assertions
These just add cold code paths and impair readability and
maintainability.
2024-09-01 20:06:45 -04:00
Richard Hansen
499318fbe0 update_nics: Always overwrite status-ipv* with value from status 2024-09-01 20:06:28 -04:00
Richard Hansen
94ce6367ec write_recap: Also clear out non-recap and stale values
Before, if a non-`undef` value was in `%recap` and the corresponding
value in `%config` became `undef`, the `%recap` value would remain
untouched.  Now it is deleted to match `%config`.

Also, any `%recap` values without a corresponding recap variable
declaration are deleted.
2024-09-01 20:06:11 -04:00
Richard Hansen
c64e432bf1 write_recap: Update all status recap vars when writing recap 2024-09-01 20:05:54 -04:00
Richard Hansen
f2c9ef6641 read_recap: Scrub recap values without var declarations 2024-09-01 20:05:40 -04:00
Richard Hansen
70e2b51377 read_recap: Don't copy non-recap values to %config 2024-09-01 20:04:45 -04:00
Richard Hansen
8359eff6ea read_recap: Check variable definedness, not existence 2024-09-01 20:03:13 -04:00
Richard Hansen
989f8be8c3 read_recap: Delete from %config any status values missing from recap 2024-09-01 20:02:58 -04:00
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