From 7bc230cbccdf11e5768bd53ac038a74d1590275b Mon Sep 17 00:00:00 2001 From: Oussama Teffahi <70609372+oteffahi@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:40:19 +0100 Subject: [PATCH] Use client multicast autoconnect config (#1712) * Use scouting/multicast/autoconnect/client config * Update default config to maintain client behavior * Update default gossip config for clients --- DEFAULT_CONFIG.json5 | 14 +++++++------- commons/zenoh-config/src/defaults.rs | 8 ++++---- zenoh/src/net/runtime/orchestrator.rs | 7 ++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/DEFAULT_CONFIG.json5 b/DEFAULT_CONFIG.json5 index 15bfab0290..3e7cc6ad7d 100644 --- a/DEFAULT_CONFIG.json5 +++ b/DEFAULT_CONFIG.json5 @@ -137,11 +137,11 @@ /// Accepts a single value (e.g. autoconnect: ["router", "peer"]) which applies whatever the configured "mode" is, /// or different values for router, peer or client mode (e.g. autoconnect: { router: [], peer: ["router", "peer"] }). /// Each value is a list of: "peer", "router" and/or "client". - autoconnect: { router: [], peer: ["router", "peer"], client: ["router", "peer"] }, + autoconnect: { router: [], peer: ["router", "peer"], client: ["router"] }, /// Whether or not to listen for scout messages on UDP multicast and reply to them. listen: true, }, - /// The gossip scouting configuration. + /// The gossip scouting configuration. Note that instances in "client" mode do not participate in gossip. gossip: { /// Whether gossip scouting is enabled or not enabled: true, @@ -153,14 +153,14 @@ multihop: false, /// Which type of Zenoh instances to send gossip messages to. /// Accepts a single value (e.g. target: ["router", "peer"]) which applies whatever the configured "mode" is, - /// or different values for router, peer or client mode (e.g. target: { router: ["router", "peer"], peer: ["router"] }). - /// Each value is a list of: "peer", "router" and/or "client". + /// or different values for router or peer mode (e.g. target: { router: ["router", "peer"], peer: ["router"] }). + /// Each value is a list of "peer" and/or "router". target: { router: ["router", "peer"], peer: ["router", "peer"]}, /// Which type of Zenoh instances to automatically establish sessions with upon discovery on gossip. /// Accepts a single value (e.g. autoconnect: ["router", "peer"]) which applies whatever the configured "mode" is, - /// or different values for router, peer or client mode (e.g. autoconnect: { router: [], peer: ["router", "peer"] }). - /// Each value is a list of: "peer", "router" and/or "client". - autoconnect: { router: [], peer: ["router", "peer"], client: ["router", "peer"] }, + /// or different values for router or peer mode (e.g. autoconnect: { router: [], peer: ["router", "peer"] }). + /// Each value is a list of: "peer" and/or "router". + autoconnect: { router: [], peer: ["router", "peer"] }, }, }, diff --git a/commons/zenoh-config/src/defaults.rs b/commons/zenoh-config/src/defaults.rs index 23887929d3..190cfd50f7 100644 --- a/commons/zenoh-config/src/defaults.rs +++ b/commons/zenoh-config/src/defaults.rs @@ -81,8 +81,8 @@ pub mod scouting { &crate::WhatAmIMatcher::empty(); pub const peer: &crate::WhatAmIMatcher = // "router|peer" &crate::WhatAmIMatcher::empty().router().peer(); - pub const client: &crate::WhatAmIMatcher = // "router|peer" - &crate::WhatAmIMatcher::empty().router().peer(); + pub const client: &crate::WhatAmIMatcher = // "router" + &crate::WhatAmIMatcher::empty().router(); mode_accessor!(crate::WhatAmIMatcher); } pub mod listen { @@ -109,8 +109,8 @@ pub mod scouting { &crate::WhatAmIMatcher::empty(); pub const peer: &crate::WhatAmIMatcher = // "router|peer" &crate::WhatAmIMatcher::empty().router().peer(); - pub const client: &crate::WhatAmIMatcher = // "router|peer" - &crate::WhatAmIMatcher::empty().router().peer(); + pub const client: &crate::WhatAmIMatcher = // "" + &crate::WhatAmIMatcher::empty(); mode_accessor!(crate::WhatAmIMatcher); } } diff --git a/zenoh/src/net/runtime/orchestrator.rs b/zenoh/src/net/runtime/orchestrator.rs index 15f7ca52a4..68e282100c 100644 --- a/zenoh/src/net/runtime/orchestrator.rs +++ b/zenoh/src/net/runtime/orchestrator.rs @@ -127,7 +127,7 @@ impl Runtime { } async fn start_client(&self) -> ZResult<()> { - let (peers, scouting, addr, ifaces, timeout, multicast_ttl) = { + let (peers, scouting, autoconnect, addr, ifaces, timeout, multicast_ttl) = { let guard = &self.state.config.lock().0; ( guard @@ -137,6 +137,7 @@ impl Runtime { .unwrap_or(&vec![]) .clone(), unwrap_or_default!(guard.scouting().multicast().enabled()), + *unwrap_or_default!(guard.scouting().multicast().autoconnect().client()), unwrap_or_default!(guard.scouting().multicast().address()), unwrap_or_default!(guard.scouting().multicast().interface()), std::time::Duration::from_millis(unwrap_or_default!(guard.scouting().timeout())), @@ -146,7 +147,7 @@ impl Runtime { match peers.len() { 0 => { if scouting { - tracing::info!("Scouting for router ..."); + tracing::info!("Scouting..."); let ifaces = Runtime::get_interfaces(&ifaces); if ifaces.is_empty() { bail!("Unable to find multicast interface!") @@ -158,7 +159,7 @@ impl Runtime { if sockets.is_empty() { bail!("Unable to bind UDP port to any multicast interface!") } else { - self.connect_first(&sockets, WhatAmI::Router.into(), &addr, timeout) + self.connect_first(&sockets, autoconnect, &addr, timeout) .await } }