From f001c69dc7cbac5d1fef4ad307feb85cbb4cbe11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sun, 21 Nov 2021 20:09:39 +0100 Subject: [PATCH] udp: statistics: print only for active protocols --- aquatic_udp/src/lib/workers/statistics.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/aquatic_udp/src/lib/workers/statistics.rs b/aquatic_udp/src/lib/workers/statistics.rs index 7ca16f4..6219e32 100644 --- a/aquatic_udp/src/lib/workers/statistics.rs +++ b/aquatic_udp/src/lib/workers/statistics.rs @@ -5,17 +5,23 @@ use crate::common::*; use crate::config::Config; pub fn run_statistics_worker(config: Config, state: State) { + let ipv4_active = config.network.address.is_ipv4() || !config.network.only_ipv6; + let ipv6_active = config.network.address.is_ipv6(); + loop { ::std::thread::sleep(Duration::from_secs(config.statistics.interval)); println!("General:"); println!(" access list entries: {}", state.access_list.load().len()); - println!("IPv4:"); - gather_and_print_for_protocol(&config, &state.statistics_ipv4); - - println!("IPv6:"); - gather_and_print_for_protocol(&config, &state.statistics_ipv6); + if ipv4_active { + println!("IPv4:"); + gather_and_print_for_protocol(&config, &state.statistics_ipv4); + } + if ipv6_active { + println!("IPv6:"); + gather_and_print_for_protocol(&config, &state.statistics_ipv6); + } println!(); }