From 45abb881a3389bea913ae10af32fb837060787ab Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 26 Nov 2025 10:38:44 +0000 Subject: [PATCH] node: Only consider onion addresses if configured There is an unfortunate lack of single-responsibility with handling the addresses to connect to. This is a band-aid fix until the point in time where this can better improved. --- crates/radicle-protocol/src/service.rs | 1 + crates/radicle/src/node.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/crates/radicle-protocol/src/service.rs b/crates/radicle-protocol/src/service.rs index d0a53bbb..1e56eddf 100644 --- a/crates/radicle-protocol/src/service.rs +++ b/crates/radicle-protocol/src/service.rs @@ -2490,6 +2490,7 @@ where .filter(|entry| !self.sessions.contains_key(&entry.node)) .filter(|entry| !self.config.external_addresses.contains(&entry.address.addr)) .filter(|entry| &entry.node != self.nid()) + .filter(|entry| !entry.address.addr.is_onion() || self.config.onion.is_some()) .fold(HashMap::new(), |mut acc, entry| { acc.entry(entry.node) .and_modify(|e: &mut Peer| e.addresses.push(entry.address.clone())) diff --git a/crates/radicle/src/node.rs b/crates/radicle/src/node.rs index 62525075..e02fb2c1 100644 --- a/crates/radicle/src/node.rs +++ b/crates/radicle/src/node.rs @@ -484,6 +484,14 @@ impl Address { &self.0.host } + /// Returns `true` if the [`HostName`] is a Tor onion address. + pub fn is_onion(&self) -> bool { + match self.0.host { + HostName::Tor(_) => true, + _ => false, + } + } + /// Return the port number of the [`Address`]. pub fn port(&self) -> u16 { self.0.port