From 1fcf89bb52a72983408e8687e80ac37b94b23033 Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Sat, 29 Jul 2023 02:07:29 +0530 Subject: [PATCH] bugfix: Fixed a bug in forwarding packets. updated logging --- src/processor.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/processor.rs b/src/processor.rs index 262edd3..89b1f8d 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -49,15 +49,13 @@ impl Processor { packet.answers.iter().map(|q| q.name).collect::>() ); for conf in &self.config.mdns { - let mut forward = false; let mut dst_ifs = vec![]; for query in &packet.questions { - forward |= conf.destinations.contains(&src_ifname) + if conf.destinations.contains(&src_ifname) && (conf.filters.is_empty() - || conf.filters.contains(&query.qname.to_string())); - - if forward { + || conf.filters.contains(&query.qname.to_string())) + { dst_ifs.extend( conf.sources .iter() @@ -67,11 +65,10 @@ impl Processor { } for answer in &packet.answers { - forward |= conf.sources.contains(&src_ifname) + if conf.sources.contains(&src_ifname) && (conf.filters.is_empty() - || conf.filters.contains(&answer.name.to_string())); - - if forward { + || conf.filters.contains(&answer.name.to_string())) + { dst_ifs.extend( conf.destinations .iter() @@ -84,8 +81,8 @@ impl Processor { let dst_ifid = ifname_to_ifidx(dst_if.name.to_string()); info!( - "forwarding {:?} from {:?} to {:?}({})", - packet, src_ifname, dst_if, dst_ifid + "forwarding {:?} from {} to {}", + packet, src_ifname, dst_if.name ); // TODO(ishan): Take a note of transaction id // and avoid feedback loops