Skip to main content

tuwunel_core/config/
compatibility.rs

1//! Configures compatibility behavior across room versions.
2//!
3//! State-resolution backports extend existing mitigations to older
4//! supported versions. The switch remains available for development and
5//! recovery.
6
7use serde::Deserialize;
8use tuwunel_macros::config_example_generator;
9
10use super::true_fn;
11
12/// Room-version compatibility
13///
14/// Carries protections from newer room versions back to rooms on older
15/// versions. Its single switch is on by default and safe for existing
16/// rooms; leave it on unless you are debugging state resolution.
17#[expect(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
18#[derive(Clone, Copy, Debug, Deserialize)]
19#[config_example_generator(
20	filename = "tuwunel-example.toml",
21	section = "global.compatibility",
22	group = "true"
23)]
24pub struct Compatibility {
25	/// Backports state-reset security mitigations to all supported room
26	/// versions.
27	///
28	/// This applies project Hydra's State Resolution 2.1 mitigations for room
29	/// version 12 to prior State Resolution 2.0 versions, increasing
30	/// resilience without redefining correctness and making it safe to enable
31	/// for existing rooms. State-reset attacks produce rooms without one
32	/// consensus, so disabling is unnecessary to match servers that disable or
33	/// lack the mitigations, even when replicating their post-reset state is
34	/// desired. The setting exists for developer and debug use and as a
35	/// failsafe instead of being hardcoded.
36	///
37	/// reloadable: yes
38	/// legacy: hydra_backports
39	#[serde(default = "true_fn")]
40	pub hydra_backports: bool,
41}
42
43impl Default for Compatibility {
44	fn default() -> Self { Self { hydra_backports: true_fn() } }
45}