Default web_server.ip_address and port

Fall back to "0.0.0.0" and 3000 when these fields are omitted from the
[web_server] section (api_key remains required). Update the sample TOML
and README to reflect the new defaults; the Nix module already used them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-02 18:33:35 -04:00
co-authored by Claude Opus 4.8
parent 0393378d24
commit bee492b703
3 changed files with 37 additions and 4 deletions
+2 -2
View File
@@ -160,8 +160,8 @@ Options marked **Required** have no built-in default and must be set in your con
|`database.path`|**Required**|Location of the system database. Must be `/db/oott.db` when using the Docker image.| |`database.path`|**Required**|Location of the system database. Must be `/db/oott.db` when using the Docker image.|
|`networking.interface`|auto-detected|Network interface to use for scans. Optional — if not set, the first non-loopback connected interface is used automatically.| |`networking.interface`|auto-detected|Network interface to use for scans. Optional — if not set, the first non-loopback connected interface is used automatically.|
|`log.level`|`warn`|Log level to use (off, error, warn, info, debug, trace)| |`log.level`|`warn`|Log level to use (off, error, warn, info, debug, trace)|
|`web_server.ip_address`|**Required**|Address the API and web UI bind to. Use `0.0.0.0` to bind all interfaces.| |`web_server.ip_address`|`0.0.0.0`|Address the API and web UI bind to. Use `0.0.0.0` to bind all interfaces.|
|`web_server.port`|**Required**|Port the API and web UI listen on.| |`web_server.port`|`3000`|Port the API and web UI listen on.|
|`web_server.api_key`|**Required**|API key the app must present to use the backend.| |`web_server.api_key`|**Required**|API key the app must present to use the backend.|
|`arp_scanner.enabled`|`true`|Whether to run the ARP scanner. The whole `[arp_scanner]` section is optional; omit it to use the defaults below. 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. Set to `false` to turn it off.|
|`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.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)|
+33
View File
@@ -14,6 +14,14 @@ fn default_log_level() -> String {
"warn".to_string() "warn".to_string()
} }
fn default_ip_address() -> String {
"0.0.0.0".to_string()
}
fn default_port() -> u16 {
3000
}
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]
pub struct Database { pub struct Database {
pub path: String, pub path: String,
@@ -143,7 +151,9 @@ pub struct Notifications {
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]
pub struct WebServer { pub struct WebServer {
#[serde(default = "default_ip_address")]
pub ip_address: String, pub ip_address: String,
#[serde(default = "default_port")]
pub port: u16, pub port: u16,
pub api_key: String, pub api_key: String,
} }
@@ -365,6 +375,29 @@ mod tests {
assert_eq!(settings.log.level, "warn"); assert_eq!(settings.log.level, "warn");
} }
#[test]
fn web_server_address_and_port_default_when_fields_omitted() {
// Keep the `[web_server]` section (api_key is required) but drop ip_address and port.
const NO_ADDR_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]
api_key = "test"
"#;
let settings = parse(NO_ADDR_CONFIG);
assert_eq!(settings.web_server.ip_address, "0.0.0.0");
assert_eq!(settings.web_server.port, 3000);
}
#[test] #[test]
fn device_events_dedup_window_defaults_when_section_omitted() { fn device_events_dedup_window_defaults_when_section_omitted() {
let settings = parse(BASE_CONFIG); let settings = parse(BASE_CONFIG);
+2 -2
View File
@@ -43,8 +43,8 @@ token="" # Your pushover token goes here, just copy&paste from their website aft
user_key="" # User key goes here, this is the account wide code for pushover user_key="" # User key goes here, this is the account wide code for pushover
[web_server] [web_server]
ip_address="0.0.0.0" # IP to bind the web server for the API and web UI to, use 0.0.0.0 to bind it to all interfaces ip_address="0.0.0.0" # IP to bind the web server for the API and web UI to, use 0.0.0.0 to bind it to all interfaces. Defaults to "0.0.0.0" if omitted
port=3000 # Port to listen on port=3000 # Port to listen on. Defaults to 3000 if omitted
api_key="CHANGE_ME" # API Key to use the system's API, change this! api_key="CHANGE_ME" # API Key to use the system's API, change this!
[retention] [retention]