From f960bfa91b2bbbdbb2531c2e6e348452c7e43cd0 Mon Sep 17 00:00:00 2001 From: benedettadavico Date: Mon, 17 Nov 2025 11:40:27 +0100 Subject: [PATCH] probe fixes testing probe locally --- nym-gateway-probe/src/lib.rs | 4 ++-- nym-gateway-probe/src/nodes.rs | 10 ++++++++++ nym-gateway-probe/src/run.rs | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/nym-gateway-probe/src/lib.rs b/nym-gateway-probe/src/lib.rs index 76b8c5c567..2c2f16ab2f 100644 --- a/nym-gateway-probe/src/lib.rs +++ b/nym-gateway-probe/src/lib.rs @@ -186,7 +186,7 @@ impl Probe { ) -> anyhow::Result { let tickets_materials = self.credentials_args.decode_attached_ticket_materials()?; - let tested_entry = self.tested_node.is_same_as_entry(); + let tested_entry = !only_wireguard; let (mixnet_entry_gateway_id, node_info) = self.lookup_gateway(&directory).await?; let storage = Ephemeral::default(); @@ -232,7 +232,7 @@ impl Probe { only_wireguard: bool, min_mixnet_performance: Option, ) -> anyhow::Result { - let tested_entry = self.tested_node.is_same_as_entry(); + let tested_entry = !only_wireguard; let (mixnet_entry_gateway_id, node_info) = self.lookup_gateway(&directory).await?; if config_dir.is_file() { diff --git a/nym-gateway-probe/src/nodes.rs b/nym-gateway-probe/src/nodes.rs index 0726bb3b7d..773470859f 100644 --- a/nym-gateway-probe/src/nodes.rs +++ b/nym-gateway-probe/src/nodes.rs @@ -199,6 +199,16 @@ impl NymApiDirectory { .map(|(id, _)| *id) } + pub fn random_entry_gateway(&self) -> anyhow::Result { + info!("Selecting random entry gateway"); + self.nodes + .iter() + .filter(|(_, n)| n.described.description.declared_role.entry) + .choose(&mut rand::thread_rng()) + .ok_or(anyhow!("no entry gateways available")) + .map(|(id, _)| *id) + } + pub fn get_nym_node(&self, identity: NodeIdentity) -> anyhow::Result { self.nodes .get(&identity) diff --git a/nym-gateway-probe/src/run.rs b/nym-gateway-probe/src/run.rs index 9487b10905..064a0b49ef 100644 --- a/nym-gateway-probe/src/run.rs +++ b/nym-gateway-probe/src/run.rs @@ -126,8 +126,14 @@ pub(crate) async fn run() -> anyhow::Result { let entry = if let Some(gateway) = &args.entry_gateway { NodeIdentity::from_base58_string(gateway)? + } else if let Some(node) = args.node { + if directory.entry_gateway(&node).is_ok() { + node + } else { + directory.random_entry_gateway()? + } } else { - directory.random_exit_with_ipr()? + directory.random_entry_gateway()? }; let test_point = if let Some(node) = args.node {