config: split at __ for struct sections of config, add couple missing settings for show-config

this makes `CONDUWUIT_WELL_KNOWN__CLIENT` a valid env variable config
option as it would normally exist under `[well_known.client]` in toml

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-02 20:55:37 -04:00 committed by June
parent 7e2a15497c
commit d7399a12fb

View file

@ -369,6 +369,7 @@ pub(crate) struct WellKnownConfig {
const DEPRECATED_KEYS: &[&str] = &[ const DEPRECATED_KEYS: &[&str] = &[
"cache_capacity", "cache_capacity",
"max_concurrent_requests",
"well_known_client", "well_known_client",
"well_known_server", "well_known_server",
"well_known_support_page", "well_known_support_page",
@ -383,22 +384,22 @@ impl Config {
let raw_config = if let Some(config_file_env) = Env::var("CONDUIT_CONFIG") { let raw_config = if let Some(config_file_env) = Env::var("CONDUIT_CONFIG") {
Figment::new() Figment::new()
.merge(Toml::file(config_file_env).nested()) .merge(Toml::file(config_file_env).nested())
.merge(Env::prefixed("CONDUIT_").global()) .merge(Env::prefixed("CONDUIT_").global().split("__"))
.merge(Env::prefixed("CONDUWUIT_").global()) .merge(Env::prefixed("CONDUWUIT_").global().split("__"))
} else if let Some(config_file_arg) = Env::var("CONDUWUIT_CONFIG") { } else if let Some(config_file_arg) = Env::var("CONDUWUIT_CONFIG") {
Figment::new() Figment::new()
.merge(Toml::file(config_file_arg).nested()) .merge(Toml::file(config_file_arg).nested())
.merge(Env::prefixed("CONDUIT_").global()) .merge(Env::prefixed("CONDUIT_").global().split("__"))
.merge(Env::prefixed("CONDUWUIT_").global()) .merge(Env::prefixed("CONDUWUIT_").global().split("__"))
} else if let Some(config_file_arg) = path { } else if let Some(config_file_arg) = path {
Figment::new() Figment::new()
.merge(Toml::file(config_file_arg).nested()) .merge(Toml::file(config_file_arg).nested())
.merge(Env::prefixed("CONDUIT_").global()) .merge(Env::prefixed("CONDUIT_").global().split("__"))
.merge(Env::prefixed("CONDUWUIT_").global()) .merge(Env::prefixed("CONDUWUIT_").global().split("__"))
} else { } else {
Figment::new() Figment::new()
.merge(Env::prefixed("CONDUIT_").global()) .merge(Env::prefixed("CONDUIT_").global().split("__"))
.merge(Env::prefixed("CONDUWUIT_").global()) .merge(Env::prefixed("CONDUWUIT_").global().split("__"))
}; };
let config = match raw_config.extract::<Config>() { let config = match raw_config.extract::<Config>() {
@ -532,6 +533,7 @@ impl fmt::Display for Config {
("DNS attempts", &self.dns_attempts.to_string()), ("DNS attempts", &self.dns_attempts.to_string()),
("DNS timeout", &self.dns_timeout.to_string()), ("DNS timeout", &self.dns_timeout.to_string()),
("DNS fallback to TCP", &self.dns_tcp_fallback.to_string()), ("DNS fallback to TCP", &self.dns_tcp_fallback.to_string()),
("DNS query over TCP only", &self.query_over_tcp_only.to_string()),
("Query all nameservers", &self.query_all_nameservers.to_string()), ("Query all nameservers", &self.query_all_nameservers.to_string()),
("Maximum request size (bytes)", &self.max_request_size.to_string()), ("Maximum request size (bytes)", &self.max_request_size.to_string()),
("Sender retry backoff limit", &self.sender_retry_backoff_limit.to_string()), ("Sender retry backoff limit", &self.sender_retry_backoff_limit.to_string()),
@ -812,6 +814,14 @@ impl fmt::Display for Config {
String::new() String::new()
}, },
), ),
(
"Well-known client URL",
&if let Some(server) = &self.well_known.client {
server.to_string()
} else {
String::new()
},
),
( (
"Well-known support email", "Well-known support email",
&if let Some(support_email) = &self.well_known.support_email { &if let Some(support_email) = &self.well_known.support_email {