Skip to content
Closed
Show file tree
Hide file tree
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
21 changes: 10 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ unused-async = "warn"
iroh-quinn = { git = "https://github.com/n0-computer/quinn", branch = "main-iroh" }
iroh-quinn-proto = { git = "https://github.com/n0-computer/quinn", branch = "main-iroh" }
iroh-quinn-udp = { git = "https://github.com/n0-computer/quinn", branch = "main-iroh" }
n0-watcher = { git = "https://github.com/n0-computer/n0-watcher", branch = "Frando/lazy-direct" }

# iroh-quinn = { path = "../iroh-quinn/quinn" }
# iroh-quinn-proto = { path = "../iroh-quinn/quinn-proto" }
Expand Down
18 changes: 9 additions & 9 deletions iroh/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use url::Url;

pub use super::magicsock::{
AddEndpointAddrError, ConnectionType, DirectAddr, DirectAddrType, PathInfo,
endpoint_map::{PathInfoList, Source},
endpoint_map::{PathInfoIter, Source},
};
#[cfg(wasm_browser)]
use crate::discovery::pkarr::PkarrResolver;
Expand Down Expand Up @@ -1804,9 +1804,9 @@ mod tests {
send.write_all(b"hello").await.anyerr()?;
let mut paths = conn.paths().stream();
info!("Waiting for direct connection");
while let Some(infos) = paths.next().await {
while let Some(mut infos) = paths.next().await {
info!(?infos, "new PathInfos");
if infos.iter().any(|info| info.is_ip()) {
if infos.any(|info| info.is_ip()) {
break;
}
}
Expand Down Expand Up @@ -1893,15 +1893,15 @@ mod tests {

// We should be connected via IP, because it is faster than the relay server.
// TODO: Maybe not panic if this is not true?
let path_info = conn.paths().get();
let mut path_info = conn.paths().get();
assert_eq!(path_info.len(), 1);
assert!(path_info.iter().next().unwrap().is_ip());
assert!(path_info.next().unwrap().is_ip());

let mut paths = conn.paths().stream();
time::timeout(Duration::from_secs(5), async move {
while let Some(infos) = paths.next().await {
while let Some(mut infos) = paths.next().await {
info!(?infos, "new PathInfos");
if infos.iter().any(|info| info.is_relay()) {
if infos.any(|info| info.is_relay()) {
break;
}
}
Expand Down Expand Up @@ -1944,9 +1944,9 @@ mod tests {
// being added on this side too.
let mut paths = conn.paths().stream();
time::timeout(Duration::from_secs(5), async move {
while let Some(infos) = paths.next().await {
while let Some(mut infos) = paths.next().await {
info!(?infos, "new PathInfos");
if infos.iter().any(|path| path.is_relay()) {
if infos.any(|path| path.is_relay()) {
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions iroh/src/endpoint/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::{
discovery::DiscoveryTask,
magicsock::{
EndpointStateActorStoppedError,
endpoint_map::{PathInfoList, PathsWatchable},
endpoint_map::{PathInfoIter, PathsWatcher},
},
};

Expand Down Expand Up @@ -1213,7 +1213,7 @@ pub struct Connection {
inner: quinn::Connection,
remote_id: EndpointId,
alpn: Vec<u8>,
paths: PathsWatchable,
paths: PathsWatcher,
}

#[allow(missing_docs)]
Expand Down Expand Up @@ -1462,7 +1462,7 @@ impl Connection {
///
/// [`PathInfo::is_selected`]: crate::magicsock::PathInfo::is_selected
/// [`PathInfo`]: crate::magicsock::PathInfo
pub fn paths(&self) -> impl Watcher<Value = PathInfoList> {
pub fn paths(&self) -> impl Watcher<Value = PathInfoIter> {
self.paths.watch(self.inner.weak_handle())
}

Expand Down
8 changes: 4 additions & 4 deletions iroh/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use crate::{
disco::{self, SendAddr},
discovery::{ConcurrentDiscovery, Discovery, EndpointData, UserData},
key::{DecryptionError, SharedSecret, public_ed_box, secret_ed_box},
magicsock::endpoint_map::PathsWatchable,
magicsock::endpoint_map::PathsWatcher,
metrics::EndpointMetrics,
net_report::{self, IfStateDetails, Report},
};
Expand Down Expand Up @@ -275,14 +275,14 @@ impl MagicSock {
/// The actor is responsible for holepunching and opening additional paths to this
/// connection.
///
/// Returns a future that resolves to [`PathsWatchable`].
/// Returns a future that resolves to [`PathsWatcher`].
///
/// The returned future is `'static`, so it can be stored without being liftetime-bound to `&self`.
pub(crate) fn register_connection(
&self,
remote: EndpointId,
conn: WeakConnectionHandle,
) -> impl Future<Output = Result<PathsWatchable, EndpointStateActorStoppedError>> + Send + 'static
) -> impl Future<Output = Result<PathsWatcher, EndpointStateActorStoppedError>> + Send + 'static
{
let (tx, rx) = oneshot::channel();
let sender = self.endpoint_map.endpoint_state_actor(remote);
Expand Down Expand Up @@ -1985,7 +1985,7 @@ mod tests {
info!("stats: {:#?}", stats);
// TODO: ensure panics in this function are reported ok
if matches!(loss, ExpectedLoss::AlmostNone) {
for info in conn.paths().get().iter() {
for info in conn.paths().get() {
assert!(
info.stats().lost_packets < 10,
"[receiver] path {:?} should not loose many packets",
Expand Down
4 changes: 2 additions & 2 deletions iroh/src/magicsock/endpoint_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ mod endpoint_state;
mod path_state;

pub(super) use endpoint_state::EndpointStateMessage;
pub(crate) use endpoint_state::PathsWatchable;
pub use endpoint_state::{ConnectionType, PathInfo, PathInfoList};
pub(crate) use endpoint_state::PathsWatcher;
pub use endpoint_state::{ConnectionType, PathInfo, PathInfoIter};
use endpoint_state::{EndpointStateActor, EndpointStateHandle};

// TODO: use this
Expand Down
Loading