diff --git a/src/display/ui.rs b/src/display/ui.rs index 5954959cd..9a8f4d10b 100644 --- a/src/display/ui.rs +++ b/src/display/ui.rs @@ -177,9 +177,37 @@ where utilization: Utilization, ip_to_host: HashMap, ) { + let hostnames: Vec = self + .state + .excluded_ips + .clone() + .unwrap_or_default() + .iter() + .filter_map(|hf| match hf { + HostFilter::Hostname(s) => Some(s.clone()), + _ => None, + }) + .collect(); + for (k, v) in &ip_to_host { + if hostnames.contains(v) { + match &self.state.excluded_ips { + None => {} + Some(_) => match k { + IpAddr::V4(ip) => self.push_to_excluded_ips(HostFilter::Ipv4Addr(*ip)), + IpAddr::V6(ip) => self.push_to_excluded_ips(HostFilter::Ipv6Addr(*ip)), + }, + } + } + } self.state.update(connections_to_procs, utilization); self.ip_to_host.extend(ip_to_host); } + fn push_to_excluded_ips(&mut self, ip: HostFilter) { + let mut vec = self.state.excluded_ips.take().unwrap_or_default(); + vec.push(ip); + println!("\x1b[91m the new vector {:?}\x1b[0m", vec); + self.state.excluded_ips = Some(vec); + } pub fn set_excluded(&mut self, ex: Option>) { self.state.excluded_ips = ex; }