diff --git a/src/connect.rs b/src/connect.rs index e944469..5d8220d 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -97,6 +97,9 @@ impl IntermeshClient { } /// Connect to a mesh name. + /// + /// If the name resolves to multiple IMIDs, an arbitrary but deterministic + /// choice is made (the `Ord`-minimum IMID). pub(crate) async fn connect_name( &mut self, name: &Name, @@ -107,22 +110,23 @@ impl IntermeshClient { .derivation() .name_to_imid .get(name) - .and_then(|s| s.iter().next()) + .and_then(|s| s.first()) .cloned() .ok_or_else(|| anyhow!("failed to resolve name to IMID: {name}"))?; - self.connect_imid(&imid, port).await } /// Connect to an IMID. + /// + /// If the IMID resolves to multiple IPs, an arbitrary but deterministic + /// choice is made (the `Ord`-minimum IP). async fn connect_imid(&mut self, imid: &Imid, port: u16) -> Result> { - // Trust engine is authoritative; bootstrap hint is fallback for bootstrap. let te_ip = self .te .derivation() .imid_to_ip .get(imid) - .and_then(|s| s.iter().next()) + .and_then(|s| s.first()) .copied(); let hint_ip = self .bootstrap_hint