Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<ClientTlsStream<TcpStream>> {
// 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
Expand Down
Loading