Merge pull request #203 from junkurihara/feat/serde-ignored
feat: check unsupported configuration entries with `serde-ignored`
This commit is contained in:
commit
9b13145079
6 changed files with 33 additions and 17 deletions
|
|
@ -13,7 +13,7 @@ publish.workspace = true
|
|||
[dependencies]
|
||||
url = { version = "2.5.2" }
|
||||
rustc-hash = "2.0.0"
|
||||
thiserror = "1.0.64"
|
||||
thiserror = "1.0.65"
|
||||
tracing = "0.1.40"
|
||||
async-trait = "0.1.83"
|
||||
base64 = "0.22.1"
|
||||
|
|
@ -29,6 +29,6 @@ rustls-platform-verifier = { version = "0.3.4" }
|
|||
rustls-acme = { path = "../submodules/rustls-acme/", default-features = false, features = [
|
||||
"aws-lc-rs",
|
||||
] }
|
||||
tokio = { version = "1.40.0", default-features = false }
|
||||
tokio = { version = "1.41.0", default-features = false }
|
||||
tokio-util = { version = "0.7.12", default-features = false }
|
||||
tokio-stream = { version = "0.1.16", default-features = false }
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [
|
|||
] }
|
||||
|
||||
mimalloc = { version = "*", default-features = false }
|
||||
anyhow = "1.0.89"
|
||||
anyhow = "1.0.91"
|
||||
rustc-hash = "2.0.0"
|
||||
serde = { version = "1.0.210", default-features = false, features = ["derive"] }
|
||||
tokio = { version = "1.40.0", default-features = false, features = [
|
||||
serde = { version = "1.0.213", default-features = false, features = ["derive"] }
|
||||
tokio = { version = "1.41.0", default-features = false, features = [
|
||||
"net",
|
||||
"rt-multi-thread",
|
||||
"time",
|
||||
|
|
@ -47,6 +47,7 @@ futures-util = { version = "0.3.31", default-features = false }
|
|||
clap = { version = "4.5.20", features = ["std", "cargo", "wrap_help"] }
|
||||
toml = { version = "0.8.19", default-features = false, features = ["parse"] }
|
||||
hot_reload = "0.1.6"
|
||||
serde_ignored = "0.1.10"
|
||||
|
||||
# logging
|
||||
tracing = { version = "0.1.40" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::{
|
||||
constants::*,
|
||||
error::{anyhow, ensure},
|
||||
log::warn,
|
||||
};
|
||||
use rpxy_lib::{reexports::Uri, AppConfig, ProxyConfig, ReverseProxyConfig, TlsConfig, UpstreamUri};
|
||||
use rustc_hash::FxHashMap as HashMap;
|
||||
|
|
@ -229,7 +230,21 @@ impl ConfigToml {
|
|||
pub fn new(config_file: &str) -> std::result::Result<Self, anyhow::Error> {
|
||||
let config_str = fs::read_to_string(config_file)?;
|
||||
|
||||
toml::from_str(&config_str).map_err(|e| anyhow!(e))
|
||||
// Check unused fields during deserialization
|
||||
let t = toml::de::Deserializer::new(&config_str);
|
||||
let mut unused = rustc_hash::FxHashSet::default();
|
||||
|
||||
let res = serde_ignored::deserialize(t, |path| {
|
||||
unused.insert(path.to_string());
|
||||
})
|
||||
.map_err(|e| anyhow!(e));
|
||||
|
||||
if !unused.is_empty() {
|
||||
let str = unused.iter().fold(String::new(), |acc, x| acc + x + "\n");
|
||||
warn!("Configuration file contains unsupported fields. Check typos:\n{}", str);
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ http3 = []
|
|||
rustc-hash = { version = "2.0.0" }
|
||||
tracing = { version = "0.1.40" }
|
||||
derive_builder = { version = "0.20.2" }
|
||||
thiserror = { version = "1.0.64" }
|
||||
thiserror = { version = "1.0.65" }
|
||||
hot_reload = { version = "0.1.6" }
|
||||
async-trait = { version = "0.1.83" }
|
||||
rustls = { version = "0.23.15", default-features = false, features = [
|
||||
|
|
@ -33,7 +33,7 @@ rustls-webpki = { version = "0.102.8", default-features = false, features = [
|
|||
x509-parser = { version = "0.16.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.40.0", default-features = false, features = [
|
||||
tokio = { version = "1.41.0", default-features = false, features = [
|
||||
"rt-multi-thread",
|
||||
"macros",
|
||||
] }
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ acme = ["dep:rpxy-acme"]
|
|||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
rustc-hash = "2.0.0"
|
||||
bytes = "1.7.2"
|
||||
bytes = "1.8.0"
|
||||
derive_builder = "0.20.2"
|
||||
futures = { version = "0.3.31", features = ["alloc", "async-await"] }
|
||||
tokio = { version = "1.40.0", default-features = false, features = [
|
||||
tokio = { version = "1.41.0", default-features = false, features = [
|
||||
"net",
|
||||
"rt-multi-thread",
|
||||
"time",
|
||||
|
|
@ -44,12 +44,12 @@ tokio = { version = "1.40.0", default-features = false, features = [
|
|||
"fs",
|
||||
] }
|
||||
tokio-util = { version = "0.7.12", default-features = false }
|
||||
pin-project-lite = "0.2.14"
|
||||
pin-project-lite = "0.2.15"
|
||||
async-trait = "0.1.83"
|
||||
|
||||
# Error handling
|
||||
anyhow = "1.0.89"
|
||||
thiserror = "1.0.64"
|
||||
anyhow = "1.0.91"
|
||||
thiserror = "1.0.65"
|
||||
|
||||
# http for both server and client
|
||||
http = "1.1.0"
|
||||
|
|
@ -90,11 +90,11 @@ h3-quinn = { version = "0.0.7", optional = true }
|
|||
s2n-quic-h3 = { path = "../submodules/s2n-quic-h3/", features = [
|
||||
"tracing",
|
||||
], optional = true }
|
||||
s2n-quic = { version = "1.47.0", default-features = false, features = [
|
||||
s2n-quic = { version = "1.48.0", default-features = false, features = [
|
||||
"provider-tls-rustls",
|
||||
], optional = true }
|
||||
s2n-quic-core = { version = "0.47.0", default-features = false, optional = true }
|
||||
s2n-quic-rustls = { version = "0.47.0", optional = true }
|
||||
s2n-quic-core = { version = "0.48.0", default-features = false, optional = true }
|
||||
s2n-quic-rustls = { version = "0.48.0", optional = true }
|
||||
##########
|
||||
# for UDP socket wit SO_REUSEADDR when h3 with quinn
|
||||
socket2 = { version = "0.5.7", features = ["all"], optional = true }
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ h3 = { version = "0.0.6", features = ["tracing"] }
|
|||
# s2n-quic = { path = "../s2n-quic" }
|
||||
# s2n-quic-core = { path = "../s2n-quic-core" }
|
||||
s2n-quic = { version = "1.47.0" }
|
||||
s2n-quic-core = { version = "0.47.0" }
|
||||
s2n-quic-core = { version = "0.48.0" }
|
||||
tracing = { version = "0.1.40", optional = true }
|
||||
|
||||
[features]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue