Skip to main content

tuwunel_core/config/
configuration.rs

1//! Configures loading and reloading policy.
2//!
3//! Unknown-option handling selects warnings or startup errors. The signal
4//! switch controls configuration reload requests.
5
6use serde::Deserialize;
7use tuwunel_macros::config_example_generator;
8
9use super::true_fn;
10
11/// Configuration loading and reload
12///
13/// Controls how strictly the configuration is checked and whether `SIGUSR1`
14/// reloads it. By default an unknown key logs a warning and is ignored, and
15/// `SIGUSR1` (what `systemctl reload` sends with the packaged service units)
16/// re-reads every configuration source, applying the keys marked
17/// `reloadable: yes`.
18///
19/// Tips:
20/// - A reload runs the same checks as startup. If the new configuration
21///   fails them, the server keeps the running one and logs why.
22///   `server_name` and `http.ip_source` cannot change on reload.
23/// - `reload_signal` gates only the signal; the admin command
24///   `!admin server reload-config` reloads regardless.
25/// - Guide: <https://tuwunel.chat/deploying/configuration-reload.html>.
26#[expect(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
27#[derive(Clone, Copy, Debug, Deserialize)]
28#[config_example_generator(
29	filename = "tuwunel-example.toml",
30	section = "global.configuration",
31	group = "true"
32)]
33pub struct Configuration {
34	/// Rejects startup when an unknown configuration option is specified,
35	/// whereas the default false warns to allow future deprecation or removal
36	/// of options without breaking existing deployments.
37	///
38	/// reloadable: yes
39	/// legacy: error_on_unknown_config_opts
40	#[serde(default)]
41	pub error_on_unknown_opts: bool,
42
43	/// Reloads configuration on SIGUSR1 on supporting platforms when enabled.
44	///
45	/// reloadable: yes
46	/// default: true
47	/// legacy: config_reload_signal
48	#[serde(default = "true_fn")]
49	pub reload_signal: bool,
50}
51
52impl Default for Configuration {
53	fn default() -> Self {
54		Self {
55			error_on_unknown_opts: Default::default(),
56			reload_signal: true_fn(),
57		}
58	}
59}