disallow unknown fields in config

This commit is contained in:
Toshit Chawda 2024-11-25 14:28:59 -08:00
parent 31df4aefc6
commit 7669ffeb7c
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D

View file

@ -84,7 +84,7 @@ pub enum StatsEndpoint {
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(default)] #[serde(default, deny_unknown_fields)]
pub struct ServerConfig { pub struct ServerConfig {
/// Address and socket type to listen on. /// Address and socket type to listen on.
pub bind: BindAddr, pub bind: BindAddr,
@ -147,7 +147,7 @@ fn is_default_motd(str: &String) -> bool {
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(default)] #[serde(default, deny_unknown_fields)]
pub struct WispConfig { pub struct WispConfig {
/// Allow legacy wsproxy connections. /// Allow legacy wsproxy connections.
pub allow_wsproxy: bool, pub allow_wsproxy: bool,
@ -185,7 +185,7 @@ pub struct WispConfig {
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(default)] #[serde(default, deny_unknown_fields)]
pub struct StreamConfig { pub struct StreamConfig {
/// Whether or not to enable TCP nodelay. /// Whether or not to enable TCP nodelay.
pub tcp_nodelay: bool, pub tcp_nodelay: bool,
@ -237,7 +237,7 @@ pub struct StreamConfig {
} }
#[derive(Debug, Serialize, Deserialize, Default)] #[derive(Debug, Serialize, Deserialize, Default)]
#[serde(default)] #[serde(default, deny_unknown_fields)]
pub struct Config { pub struct Config {
/// Server-specific config. /// Server-specific config.
pub server: ServerConfig, pub server: ServerConfig,