Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Merge remote-tracking branch 'origin/feat-multipath' into Frando/mp-m…
…etrics-basics
  • Loading branch information
Frando committed Nov 22, 2025
commit d44cfc298e182e292d3c09feaaaf37856f35fd1c
54 changes: 54 additions & 0 deletions iroh/src/magicsock/remote_map/remote_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,45 @@ impl RemoteStateActor {
}
}

fn handle_discovery_item(&mut self, item: Option<Result<DiscoveryItem, DiscoveryError>>) {
match item {
None => {
self.discovery_stream = Either::Left(n0_future::stream::pending());
self.paths.discovery_finished(Ok(()));
}
Some(Err(err)) => {
warn!("Discovery failed: {err:#}");
self.discovery_stream = Either::Left(n0_future::stream::pending());
self.paths.discovery_finished(Err(err));
}
Some(Ok(item)) => {
if item.endpoint_id() != self.endpoint_id {
warn!(?item, "Discovery emitted item for wrong remote endpoint");
} else {
let source = Source::Discovery {
name: item.provenance().to_string(),
};
let addrs =
to_transports_addr(self.endpoint_id, item.into_endpoint_addr().addrs);
self.paths.insert_multiple(addrs, source);
}
}
}
}

/// Triggers discovery for the remote endpoint, if needed.
///
/// Does not start discovery if we have a selected path or if discovery is currently running.
fn trigger_discovery(&mut self) {
if self.selected_path.get().is_some() || matches!(self.discovery_stream, Either::Right(_)) {
return;
}
match self.discovery.resolve(self.endpoint_id) {
Some(stream) => self.discovery_stream = Either::Right(SyncStream::new(stream)),
None => self.paths.discovery_finished(Ok(())),
}
}

/// Triggers holepunching to the remote endpoint.
///
/// This will manage the entire process of holepunching with the remote endpoint.
Expand Down Expand Up @@ -1433,3 +1472,18 @@ impl TransportSummary {
}
}
}

/// Converts an iterator of [`TransportAddr'] into an iterator of [`transports::Addr`].
fn to_transports_addr(
endpoint_id: EndpointId,
addrs: impl IntoIterator<Item = TransportAddr>,
) -> impl Iterator<Item = transports::Addr> {
addrs.into_iter().filter_map(move |addr| match addr {
TransportAddr::Relay(relay_url) => Some(transports::Addr::from((relay_url, endpoint_id))),
TransportAddr::Ip(sockaddr) => Some(transports::Addr::from(sockaddr)),
_ => {
warn!(?addr, "Unsupported TransportAddr");
None
}
})
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.