From 547625d5fe1bfdb78a6c0910e412e844aa4c2084 Mon Sep 17 00:00:00 2001 From: Yoga07 Date: Fri, 18 Jun 2021 18:45:36 +0530 Subject: [PATCH] fix(filter): ignore JoinRequests from filtering --- Cargo.toml | 2 +- src/routing/core/mod.rs | 9 ++++++--- src/routing/mod.rs | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e8bdae197f..292e458df7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ qp2p = "~0.12.0" rand = "~0.7.3" rand_chacha = "~0.2.2" resource_proof = "0.8.0" -sn_messaging = "37.0.0" +sn_messaging = "37.1.0" sn_data_types = "~0.18.3" thiserror = "1.0.23" tokio = "1.3.0" diff --git a/src/routing/core/mod.rs b/src/routing/core/mod.rs index ae4d329a47..0e07c10dc5 100644 --- a/src/routing/core/mod.rs +++ b/src/routing/core/mod.rs @@ -31,7 +31,7 @@ use secured_linked_list::SecuredLinkedList; use sn_messaging::node::SignatureAggregator; use sn_messaging::{ node::{Network, Proposal, RoutingMsg, Section, SectionSigned, Variant}, - DestInfo, DstLocation, MessageId, SectionAuthorityProvider, + DestInfo, DstLocation, MessageId, SectionAuthorityProvider, WireMsg, }; use std::collections::BTreeSet; use tokio::sync::mpsc; @@ -92,8 +92,11 @@ impl Core { // Miscellaneous //////////////////////////////////////////////////////////////////////////// - pub async fn add_to_filter(&mut self, msg_id: &MessageId) -> bool { - self.msg_filter.add_to_filter(msg_id).await + pub async fn add_to_filter(&mut self, wire_msg: &WireMsg) -> bool { + if let Ok(true) = wire_msg.is_join_request() { + return true; + } + self.msg_filter.add_to_filter(&wire_msg.msg_id()).await } async fn check_for_entropy( diff --git a/src/routing/mod.rs b/src/routing/mod.rs index 733be0782f..d5b2cb7fcf 100644 --- a/src/routing/mod.rs +++ b/src/routing/mod.rs @@ -485,7 +485,7 @@ async fn handle_message(dispatcher: Arc, bytes: Bytes, sender: Socke let span = { let mut state = dispatcher.core.write().await; - if !state.add_to_filter(&wire_msg.msg_id()).await { + if !state.add_to_filter(&wire_msg).await { trace!( "not handling message - already handled: {:?}", wire_msg.msg_id()