mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Give the ARP scanner code defaults and make its config section optional
Add an ArpScanner Default impl (30m/1m/10m, enabled) and mark the arp_scanner field with serde default, so the [arp_scanner] section can now be omitted entirely and fall back to code defaults — matching the pattern used by the SNMP scanner. Previously these three durations were mandatory and the backend would not start without them. Reconcile the documentation to the canonical 30m/1m/10m: fix the README NixOS example (was 15m/20m/30m) and options table (was 15m), and note that the section is optional in both the README and sample TOML. The NixOS module and sample TOML already used these values. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b283699b3c
commit
38158a4ffc
@@ -111,9 +111,9 @@ Finally, in your `configuration.nix` (or in an import file) enable and configure
|
|||||||
database.path = "/var/lib/oott.db";
|
database.path = "/var/lib/oott.db";
|
||||||
# networking.interface = "eth0"; # Optional: auto-detected if not set
|
# networking.interface = "eth0"; # Optional: auto-detected if not set
|
||||||
log.level = "info";
|
log.level = "info";
|
||||||
arp_scanner.wait_between_scans = "15m";
|
arp_scanner.wait_between_scans = "30m";
|
||||||
arp_scanner.sender_timeout = "20m";
|
arp_scanner.sender_timeout = "1m";
|
||||||
arp_scanner.scan_duration = "30m";
|
arp_scanner.scan_duration = "10m";
|
||||||
notifications.method = "pushover";
|
notifications.method = "pushover";
|
||||||
notifications.notify_when_not_seen_for = "1w";
|
notifications.notify_when_not_seen_for = "1w";
|
||||||
notifications.pushover.token = "YOUR API TOKEN GOES HERE";
|
notifications.pushover.token = "YOUR API TOKEN GOES HERE";
|
||||||
@@ -136,8 +136,8 @@ If you are using Docker I recommend writing the config using TOML, [here](https:
|
|||||||
|`database.path`|`/var/lib/oott.db`|Location of the system database|
|
|`database.path`|`/var/lib/oott.db`|Location of the system database|
|
||||||
|`networking.interface`|`eno1`|Network interface to use for scans. Optional — if not set, the first non-loopback connected interface is used automatically.|
|
|`networking.interface`|`eno1`|Network interface to use for scans. Optional — if not set, the first non-loopback connected interface is used automatically.|
|
||||||
|`log.level`|`info`|Log level to use (trace, debug, info, warn, error)|
|
|`log.level`|`info`|Log level to use (trace, debug, info, warn, error)|
|
||||||
|`arp_scanner.enabled`|`true`|Whether to run the ARP scanner. Defaults to enabled; set to `false` to turn it off.|
|
|`arp_scanner.enabled`|`true`|Whether to run the ARP scanner. The whole `[arp_scanner]` section is optional; omit it to use the defaults below. Defaults to enabled; set to `false` to turn it off.|
|
||||||
|`arp_scanner.wait_between_scans`|`15m`|Time to wait between each network scan (you can express it in seconds, minutes, hours, etc. as a suffix - for example: 30s, 10m, 1h)|
|
|`arp_scanner.wait_between_scans`|`30m`|Time to wait between each network scan (you can express it in seconds, minutes, hours, etc. as a suffix - for example: 30s, 10m, 1h)|
|
||||||
|`arp_scanner.sender_timeout`|`1m`|If the ARP sender process takes longer than this it will be stopped (for a class C network - 254 IPs - it should take less than a minute)|
|
|`arp_scanner.sender_timeout`|`1m`|If the ARP sender process takes longer than this it will be stopped (for a class C network - 254 IPs - it should take less than a minute)|
|
||||||
|`arp_scanner.scan_duration`|`10m`|How long to wait for response packets on each scan (5m to 10m is a good timeframe for a class B or C network)|
|
|`arp_scanner.scan_duration`|`10m`|How long to wait for response packets on each scan (5m to 10m is a good timeframe for a class B or C network)|
|
||||||
|`mdns_scanner.enabled`|`true`|Whether to run the mDNS/Bonjour scanner. Defaults to enabled; set to `false` to turn it off.|
|
|`mdns_scanner.enabled`|`true`|Whether to run the mDNS/Bonjour scanner. Defaults to enabled; set to `false` to turn it off.|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
- [x] Add configuration options to enable/disable each scanner
|
- [x] Add configuration options to enable/disable each scanner
|
||||||
- [ ] Implement the pushover API call directly to support HTML content and review notification text to use it
|
- [ ] Implement the pushover API call directly to support HTML content and review notification text to use it
|
||||||
- [ ] Add "devices seen on last scan" to the ARP and SNMP scanners status
|
- [ ] Add "devices seen on last scan" to the ARP and SNMP scanners status
|
||||||
- [ ] Review the recommended timings for the ARP scanner (change defaults) — SNMP defaults set to 10m/5s
|
- [x] Review the recommended timings for the ARP scanner (change defaults) — SNMP defaults set to 10m/5s
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,17 @@ pub struct ArpScanner {
|
|||||||
pub scan_duration: DurationString,
|
pub scan_duration: DurationString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ArpScanner {
|
||||||
|
fn default() -> Self {
|
||||||
|
ArpScanner {
|
||||||
|
enabled: true,
|
||||||
|
wait_between_scans: DurationString::try_from("30m".to_string()).unwrap(),
|
||||||
|
sender_timeout: DurationString::try_from("1m".to_string()).unwrap(),
|
||||||
|
scan_duration: DurationString::try_from("10m".to_string()).unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct MdnsScanner {
|
pub struct MdnsScanner {
|
||||||
#[serde(default = "default_true")]
|
#[serde(default = "default_true")]
|
||||||
@@ -142,6 +153,7 @@ pub struct Settings {
|
|||||||
pub database: Database,
|
pub database: Database,
|
||||||
pub networking: Networking,
|
pub networking: Networking,
|
||||||
pub log: Log,
|
pub log: Log,
|
||||||
|
#[serde(default)]
|
||||||
pub arp_scanner: ArpScanner,
|
pub arp_scanner: ArpScanner,
|
||||||
pub notifications: Notifications,
|
pub notifications: Notifications,
|
||||||
pub web_server: WebServer,
|
pub web_server: WebServer,
|
||||||
@@ -258,6 +270,42 @@ mod tests {
|
|||||||
assert_eq!(settings.snmp_scanner.community, "public");
|
assert_eq!(settings.snmp_scanner.community, "public");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn arp_scanner_uses_code_defaults_when_section_omitted() {
|
||||||
|
// A config without an `[arp_scanner]` section falls back to the code defaults.
|
||||||
|
const NO_ARP_CONFIG: &str = r#"
|
||||||
|
[database]
|
||||||
|
path = "./oott.db"
|
||||||
|
[networking]
|
||||||
|
[log]
|
||||||
|
level = "info"
|
||||||
|
[notifications]
|
||||||
|
method = "none"
|
||||||
|
notify_when_not_seen_for = "1w"
|
||||||
|
[notifications.pushover]
|
||||||
|
token = ""
|
||||||
|
user_key = ""
|
||||||
|
[web_server]
|
||||||
|
ip_address = "0.0.0.0"
|
||||||
|
port = 3000
|
||||||
|
api_key = "test"
|
||||||
|
"#;
|
||||||
|
let settings = parse(NO_ARP_CONFIG);
|
||||||
|
assert!(settings.arp_scanner.enabled);
|
||||||
|
assert_eq!(
|
||||||
|
std::time::Duration::from(settings.arp_scanner.wait_between_scans),
|
||||||
|
std::time::Duration::from_secs(30 * 60)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
std::time::Duration::from(settings.arp_scanner.sender_timeout),
|
||||||
|
std::time::Duration::from_secs(60)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
std::time::Duration::from(settings.arp_scanner.scan_duration),
|
||||||
|
std::time::Duration::from_secs(10 * 60)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn scanners_can_be_disabled() {
|
fn scanners_can_be_disabled() {
|
||||||
let toml = format!(
|
let toml = format!(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ path = "/db/oott.db" # Database path. For the Docker image this must be "/db/oot
|
|||||||
[log]
|
[log]
|
||||||
level = "info" # off, error, warn, info, debug, trace
|
level = "info" # off, error, warn, info, debug, trace
|
||||||
|
|
||||||
[arp_scanner]
|
[arp_scanner] # Optional: omit this whole section to use the defaults shown below
|
||||||
enabled=true # Set to false to disable the ARP scanner
|
enabled=true # Set to false to disable the ARP scanner
|
||||||
wait_between_scans="30m" # Wait time between scans. This does not include the scan time
|
wait_between_scans="30m" # Wait time between scans. This does not include the scan time
|
||||||
sender_timeout="1m" # If the ARP sender process takes longer than this it will be stopped (for a class C network - 254 IPs - it should take less than a minute)
|
sender_timeout="1m" # If the ARP sender process takes longer than this it will be stopped (for a class C network - 254 IPs - it should take less than a minute)
|
||||||
|
|||||||
Reference in New Issue
Block a user