From f556b60ce4a72b8a2ba8d30f9310220cc52b8974 Mon Sep 17 00:00:00 2001 From: Razvan Dimescu Date: Fri, 10 Apr 2026 08:32:51 +0300 Subject: [PATCH] fix: suppress recursive hint in install when already configured (#71) `sudo numa install` unconditionally printed the "Want full DNS sovereignty?" hint even when numa.toml already has mode = "recursive". Now loads the config first and skips the message if recursive is already set. Co-authored-by: Claude Opus 4.6 --- src/system_dns.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/system_dns.rs b/src/system_dns.rs index 36c13d7..115ce2d 100644 --- a/src/system_dns.rs +++ b/src/system_dns.rs @@ -2,6 +2,17 @@ use std::net::SocketAddr; use log::info; +fn print_recursive_hint() { + let is_recursive = crate::config::load_config("numa.toml") + .map(|c| c.config.upstream.mode == crate::config::UpstreamMode::Recursive) + .unwrap_or(false); + if !is_recursive { + eprintln!(" Want full DNS sovereignty? Add to numa.toml:"); + eprintln!(" [upstream]"); + eprintln!(" mode = \"recursive\"\n"); + } +} + fn is_loopback_or_stub(addr: &str) -> bool { matches!(addr, "127.0.0.1" | "127.0.0.53" | "0.0.0.0" | "::1" | "") } @@ -688,9 +699,7 @@ fn install_windows() -> Result<(), String> { } else { eprintln!(" Numa will start automatically on next boot.\n"); } - eprintln!(" Want full DNS sovereignty? Add to numa.toml:"); - eprintln!(" [upstream]"); - eprintln!(" mode = \"recursive\"\n"); + print_recursive_hint(); Ok(()) } @@ -1181,9 +1190,7 @@ fn install_service_macos() -> Result<(), String> { eprintln!(" Numa will auto-start on boot and restart if killed."); eprintln!(" Logs: /usr/local/var/log/numa.log"); eprintln!(" Run 'sudo numa uninstall' to restore original DNS.\n"); - eprintln!(" Want full DNS sovereignty? Add to numa.toml:"); - eprintln!(" [upstream]"); - eprintln!(" mode = \"recursive\"\n"); + print_recursive_hint(); Ok(()) } @@ -1388,9 +1395,7 @@ fn install_service_linux() -> Result<(), String> { eprintln!(" Numa will auto-start on boot and restart if killed."); eprintln!(" Logs: journalctl -u numa -f"); eprintln!(" Run 'sudo numa uninstall' to restore original DNS.\n"); - eprintln!(" Want full DNS sovereignty? Add to numa.toml:"); - eprintln!(" [upstream]"); - eprintln!(" mode = \"recursive\"\n"); + print_recursive_hint(); Ok(()) }