Make optional config fields fall back to defaults

Several settings were required at parse time even though they had a
sensible default, causing the backend to panic on startup when omitted:

- notifications.notify_when_not_seen_for now defaults to "1w"
- the whole [networking] section is now optional (no mandatory fields)
- scanner duration/timeout fields (ARP, mDNS, SSDP, SNMP) now fall back
  to their defaults when the section is present but the field is omitted.
  serde only applies a field default when marked #[serde(default)], so
  the per-field attributes were added and the Default impls now share the
  same default functions as the single source of truth.

Updates the sample TOML and README accordingly and adds tests covering
each defaulting case.
This commit is contained in:
rzuasti
2026-06-04 09:02:36 -04:00
parent 9367c359d7
commit 38946d3abe
3 changed files with 143 additions and 10 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
[database]
path = "/db/oott.db" # Database path. For the Docker image this must be "/db/oott.db" (the mounted volume); make sure it's writeable for the user running this process
# The whole [networking] section is optional; omit it to auto-detect the interface.
[networking]
# interface = "eno1" # Optional: network interface to use for scans. If not set, the first non-loopback connected interface is used.
@@ -36,7 +37,7 @@ enabled=true # Set to false to disable the DHCP scanner
[notifications]
method="pushover" # For now just pushover, you can set this to "none" to avoid sending notifications (it will just log)
notify_when_not_seen_for="1w" # Send a notification if a device comes back online after not being seen for this timeframe
notify_when_not_seen_for="1w" # Send a notification if a device comes back online after not being seen for this timeframe. Defaults to "1w" if omitted
[notifications.pushover]
token="" # Your pushover token goes here, just copy&paste from their website after creating the app