diff options
author | Alex Auvolat <alex@adnab.me> | 2023-01-11 22:44:21 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-01-11 22:44:21 +0100 |
commit | 86c255dfeabc60b0ef46ff78bc487c61c9548c79 (patch) | |
tree | 245e6b8f5675a34358478e3a663db88d948c3f70 /src/main.rs | |
parent | 5f946d485c62feca79e907a2d071a291dcc8c7bf (diff) | |
download | D53-86c255dfeabc60b0ef46ff78bc487c61c9548c79.tar.gz D53-86c255dfeabc60b0ef46ff78bc487c61c9548c79.zip |
Less spam on stdout
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 77c8b16..24193f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -129,6 +129,8 @@ async fn dump_config_on_change( mut rx_dns_config: watch::Receiver<Arc<dns_config::DnsConfig>>, mut must_exit: watch::Receiver<bool>, ) { + let mut prev_dns_config = Arc::new(dns_config::DnsConfig::default()); + while !*must_exit.borrow() { select!( c = rx_dns_config.changed() => { @@ -138,11 +140,16 @@ async fn dump_config_on_change( } _ = must_exit.changed() => continue, ); - println!("---- DNS CONFIGURATION ----"); - for (k, v) in rx_dns_config.borrow().entries.iter() { - println!(" {} {}", k, v); + + let new_dns_config = rx_dns_config.borrow_and_update().clone(); + if new_dns_config != prev_dns_config { + println!("---- DNS CONFIGURATION ----"); + for (k, v) in rx_dns_config.borrow().entries.iter() { + println!(" {} {}", k, v); + } + println!(); } - println!(); + prev_dns_config = new_dns_config; } } |