From 0382ba4f157c763e3d1a5318ceab43ca337c682c Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 28 Dec 2025 21:51:22 +0100 Subject: [PATCH] Add: Log message for config loading. --- src/main.rs | 56 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/main.rs b/src/main.rs index df463ee..1dfa670 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,37 +36,38 @@ fn resolve_host_or_ip(label: &str, value: &str) -> Option { #[tokio::main] async fn main() -> anyhow::Result<()> { // Bootstrap configuration: prefer appsettings.json, otherwise rely on baked-in demo defaults. - let cfg = match Config::load_default() { - Ok(c) => { - c - } + let (cfg, cfg_source) = match Config::load_default() { + Ok(c) => (c, "appsettings.json".to_string()), Err(e) => { eprintln!( "no appsettings.json found or failed to load: {} — using defaults", e ); // defaults - Config { - server: niom_turn::config::ServerOptions { - bind: "0.0.0.0:3478".to_string(), - udp_bind: None, - tcp_bind: None, - tls_bind: "0.0.0.0:5349".to_string(), - enable_udp: true, - enable_tcp: true, - enable_tls: true, - tls_cert: None, - tls_key: None, + ( + Config { + server: niom_turn::config::ServerOptions { + bind: "0.0.0.0:3478".to_string(), + udp_bind: None, + tcp_bind: None, + tls_bind: "0.0.0.0:5349".to_string(), + enable_udp: true, + enable_tcp: true, + enable_tls: true, + 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 { - 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(), - } + "defaults".to_string(), + ) } }; @@ -81,6 +82,13 @@ async fn main() -> anyhow::Result<()> { let rate_limiters = Arc::new(RateLimiters::from_limits(&cfg.limits)); 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); let udp_bind = cfg