From ecc05dad8a78437e2253200b1bc281e727107b74 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Wed, 11 Sep 2024 08:59:18 +0000 Subject: [PATCH] Don't auto-connect to configured connect endpoints --- zenoh/src/net/runtime/orchestrator.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/zenoh/src/net/runtime/orchestrator.rs b/zenoh/src/net/runtime/orchestrator.rs index fee4c86c1d..6bff4e75be 100644 --- a/zenoh/src/net/runtime/orchestrator.rs +++ b/zenoh/src/net/runtime/orchestrator.rs @@ -12,6 +12,7 @@ // ZettaScale Zenoh Team, // use std::{ + collections::HashSet, net::{IpAddr, Ipv6Addr, SocketAddr}, time::Duration, }; @@ -911,8 +912,23 @@ impl Runtime { } #[must_use] - async fn connect(&self, zid: &ZenohIdProto, locators: &[Locator]) -> bool { - const ERR: &str = "Unable to connect to newly scouted peer "; + async fn connect(&self, zid: &ZenohIdProto, scouted_locators: &[Locator]) -> bool { + const ERR: &str = "Unable to connect to newly scouted peer"; + + let configured_locators = self + .state + .config + .lock() + .connect() + .endpoints() + .get(self.whatami()) + .iter() + .flat_map(|e| e.iter().map(EndPoint::to_locator)) + .collect::>(); + + let locators = scouted_locators + .iter() + .filter(|l| !configured_locators.contains(l)); let inspector = LocatorInspector::default(); for locator in locators { @@ -968,7 +984,7 @@ impl Runtime { tracing::warn!( "Unable to connect to any locator of scouted peer {}: {:?}", zid, - locators + scouted_locators ); } else { tracing::trace!(