diff --git a/validator-firewall/src/ip_service.rs b/validator-firewall/src/ip_service.rs index 21042ed..cd5b28a 100644 --- a/validator-firewall/src/ip_service.rs +++ b/validator-firewall/src/ip_service.rs @@ -5,7 +5,7 @@ use rangemap::RangeInclusiveSet; use solana_rpc_client::nonblocking::rpc_client::RpcClient; use std::collections::HashSet; use std::net::SocketAddr; -use std::ops::{RangeInclusive}; +use std::ops::RangeInclusive; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; diff --git a/validator-firewall/src/main.rs b/validator-firewall/src/main.rs index f2612eb..43768cd 100644 --- a/validator-firewall/src/main.rs +++ b/validator-firewall/src/main.rs @@ -185,7 +185,7 @@ fn push_ports_to_map(bpf: &mut Bpf, ports: Vec) -> Result<(), anyhow::Error #[cfg(test)] mod tests { - + use cidr::Ipv4Cidr; use std::str::FromStr; diff --git a/validator-firewall/src/stats_service.rs b/validator-firewall/src/stats_service.rs index 8c66873..ad4565d 100644 --- a/validator-firewall/src/stats_service.rs +++ b/validator-firewall/src/stats_service.rs @@ -1,5 +1,5 @@ use aya::maps::{Map, MapData, MapIter, PerCpuHashMap, PerCpuValues}; -use log::{info, debug}; +use log::info; use std::net::Ipv4Addr; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -37,7 +37,6 @@ impl StatsService { per_cpu.iter().sum(), ) }) - .take(100) .collect(); pairs.sort_by(|a, b| b.1.cmp(&a.1)); pairs @@ -58,9 +57,13 @@ impl StatsService { while !co_exit.load(Ordering::Relaxed) { // Get stats from the maps let mut all_sum = 0u64; + let mut log_limit = 100; for (addr, total) in Self::prepare_stats(all_traffic.iter()) { all_sum += total; - info!("total_packets: {:?} = {:?}", addr, total); + if log_limit > 0 { + info!("total_packets: {:?} = {:?}", addr, total); + log_limit -= 1; + } } info!( "All traffic summary: {} pkts last_interval {} pkts {} pkts/s", @@ -72,9 +75,13 @@ impl StatsService { all_las_eval_time = std::time::Instant::now(); let mut blocked_sum = 0u64; + let mut log_limit = 100; for (addr, total) in Self::prepare_stats(blocked_traffic.iter()) { blocked_sum += total; - info!("dropped_packets: {:?} = {:?}", addr, total); + if log_limit > 0 { + info!("dropped_packets: {:?} = {:?}", addr, total); + log_limit -= 1; + } } info!( "Blocked traffic summary: {} pkts last_interval {} pkts {} pkts/s",