Skip to main content

roowho2_lib/server/
config.rs

1use std::net::SocketAddrV4;
2
3use serde::{Deserialize, Serialize};
4
5pub const DEFAULT_CONFIG_PATH: &str = "/etc/roowho2/config.toml";
6
7pub const DEFAULT_CLIENT_SOCKET_PATH: &str = "/run/roowho2/server_client.sock";
8
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10pub struct Config {
11    /// Logging level for the daemon.
12    pub log_level: Option<LogLevel>,
13
14    /// Configuration for the rwhod server.
15    pub rwhod: RwhodConfig,
16
17    /// Path to the Unix domain socket for client-server communication.
18    ///
19    /// If left as `None`, the server expects to be served a file descriptor to the socket named 'client'.
20    pub client_socket_path: Option<String>,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "lowercase")]
25pub enum LogLevel {
26    Info,
27    Debug,
28    Trace,
29}
30
31#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
32pub struct RwhodConfig {
33    /// Enable or disable the rwhod server functionality.
34    pub enable: bool,
35
36    /// Network interfaces to listen on (e.g., ["eth0", "wlan0"]).
37    ///
38    /// If left as `None`, the server will automatically determine relevant interfaces.
39    ///
40    /// Note that if `broadcast_addresses` is specified, this field is ignored.
41    pub interfaces: Option<Vec<String>>,
42
43    /// Broadcast addresses to send rwhod packets to.
44    ///
45    /// If left as `None`, the server will automatically determine broadcast addresses for the selected interfaces.
46    pub broadcast_addresses: Option<Vec<SocketAddrV4>>,
47}