Add: Log message for config loading.

This commit is contained in:
ghost 2025-12-28 21:51:22 +01:00
parent 8fc5450dc0
commit 0382ba4f15

View File

@ -36,37 +36,38 @@ fn resolve_host_or_ip(label: &str, value: &str) -> Option<IpAddr> {
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
// Bootstrap configuration: prefer appsettings.json, otherwise rely on baked-in demo defaults. // Bootstrap configuration: prefer appsettings.json, otherwise rely on baked-in demo defaults.
let cfg = match Config::load_default() { let (cfg, cfg_source) = match Config::load_default() {
Ok(c) => { Ok(c) => (c, "appsettings.json".to_string()),
c
}
Err(e) => { Err(e) => {
eprintln!( eprintln!(
"no appsettings.json found or failed to load: {} — using defaults", "no appsettings.json found or failed to load: {} — using defaults",
e e
); );
// defaults // defaults
Config { (
server: niom_turn::config::ServerOptions { Config {
bind: "0.0.0.0:3478".to_string(), server: niom_turn::config::ServerOptions {
udp_bind: None, bind: "0.0.0.0:3478".to_string(),
tcp_bind: None, udp_bind: None,
tls_bind: "0.0.0.0:5349".to_string(), tcp_bind: None,
enable_udp: true, tls_bind: "0.0.0.0:5349".to_string(),
enable_tcp: true, enable_udp: true,
enable_tls: true, enable_tcp: true,
tls_cert: None, enable_tls: true,
tls_key: None, tls_cert: None,
tls_key: None,
},
credentials: vec![niom_turn::config::CredentialEntry {
username: "testuser".into(),
password: "secretpassword".into(),
}],
auth: AuthOptions::default(),
relay: niom_turn::config::RelayOptions::default(),
logging: niom_turn::config::LoggingOptions::default(),
limits: niom_turn::config::LimitsOptions::default(),
}, },
credentials: vec![niom_turn::config::CredentialEntry { "defaults".to_string(),
username: "testuser".into(), )
password: "secretpassword".into(),
}],
auth: AuthOptions::default(),
relay: niom_turn::config::RelayOptions::default(),
logging: niom_turn::config::LoggingOptions::default(),
limits: niom_turn::config::LimitsOptions::default(),
}
} }
}; };
@ -81,6 +82,13 @@ async fn main() -> anyhow::Result<()> {
let rate_limiters = Arc::new(RateLimiters::from_limits(&cfg.limits)); let rate_limiters = Arc::new(RateLimiters::from_limits(&cfg.limits));
info!("niom-turn starting"); info!("niom-turn starting");
info!("config source={} realm={} creds={} rest_secret={} tls_cert={}",
cfg_source,
cfg.auth.realm,
cfg.credentials.len(),
cfg.auth.rest_secret.is_some(),
cfg.server.tls_cert.is_some()
);
info!("logging.default_directive={}", log_directive); info!("logging.default_directive={}", log_directive);
let udp_bind = cfg let udp_bind = cfg