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]
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