Skip to content

[WIP] feat: use quic multipath #3381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
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
82 changes: 64 additions & 18 deletions Cargo.lock

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

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,17 @@ unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)", "cfg(iroh_l

[workspace.lints.clippy]
unused-async = "warn"


[patch.crates-io]
rustls = { git = "https://github.com/n0-computer/rustls", rev = "be02113e7837df60953d02c2bdd0f4634fef3a80" }
netwatch = { git = "https://github.com/n0-computer/net-tools", branch = "feat-multipath" }

[patch."https://github.com/n0-computer/quinn"]
# iroh-quinn = { path = "../iroh-quinn/quinn" }
# iroh-quinn-proto = { path = "../iroh-quinn/quinn-proto" }
# iroh-quinn-udp = { path = "../iroh-quinn/quinn-udp" }

# iroh-quinn = { git = "https://github.com//n0-computer/quinn", branch = "flub/quinn-path-events-status" }
# iroh-quinn-proto = { git = "https://github.com//n0-computer/quinn", branch = "flub/quinn-path-events-status" }
# iroh-quinn-udp = { git = "https://github.com//n0-computer/quinn", branch = "flub/quinn-path-events-status" }
4 changes: 2 additions & 2 deletions iroh-relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ postcard = { version = "1", default-features = false, features = [
"use-std",
"experimental-derive",
] }
quinn = { package = "iroh-quinn", version = "0.14.0", default-features = false, features = ["rustls-ring"] }
quinn-proto = { package = "iroh-quinn-proto", version = "0.13.0" }
quinn = { package = "iroh-quinn", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x", default-features = false, features = ["rustls-ring"] }
quinn-proto = { package = "iroh-quinn-proto", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x" }
rand = "0.8"
reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls",
Expand Down
8 changes: 4 additions & 4 deletions iroh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ pin-project = "1"
pkarr = { version = "3.7", default-features = false, features = [
"relays",
] }
quinn = { package = "iroh-quinn", version = "0.14.0", default-features = false, features = ["rustls-ring"] }
quinn-proto = { package = "iroh-quinn-proto", version = "0.13.0" }
quinn-udp = { package = "iroh-quinn-udp", version = "0.5.7" }
quinn = { package = "iroh-quinn", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x", default-features = false, features = ["rustls-ring"] }
quinn-proto = { package = "iroh-quinn-proto", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x" }
quinn-udp = { package = "iroh-quinn-udp", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x" }
rand = "0.8"
reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls",
Expand Down Expand Up @@ -109,7 +109,7 @@ hickory-resolver = "0.25.1"
igd-next = { version = "0.16", features = ["aio_tokio"] }
netdev = { version = "0.31.0" }
portmapper = { version = "0.6.1", default-features = false }
quinn = { package = "iroh-quinn", version = "0.14.0", default-features = false, features = ["runtime-tokio", "rustls-ring"] }
quinn = { package = "iroh-quinn", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x", default-features = false, features = ["runtime-tokio", "rustls-ring"] }
tokio = { version = "1", features = [
"io-util",
"macros",
Expand Down
2 changes: 1 addition & 1 deletion iroh/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ iroh-metrics = "0.35"
n0-future = "0.1.1"
n0-snafu = "0.2.0"
n0-watcher = "0.2"
quinn = { package = "iroh-quinn", version = "0.14" }
quinn = { package = "iroh-quinn", git = "https://github.com/n0-computer/quinn", branch = "multipath-quinn-0.11.x" }
rand = "0.8"
rcgen = "0.13"
rustls = { version = "0.23", default-features = false, features = ["ring"] }
Expand Down
38 changes: 23 additions & 15 deletions iroh/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,6 @@ impl Endpoint {
self.add_node_addr(node_addr.clone())?;
}
let node_id = node_addr.node_id;
let direct_addresses = node_addr.direct_addresses.clone();
let relay_url = node_addr.relay_url.clone();

// Get the mapped IPv6 address from the magic socket. Quinn will connect to this
// address. Start discovery for this node if it's enabled and we have no valid or
Expand All @@ -751,12 +749,7 @@ impl Endpoint {
// Start connecting via quinn. This will time out after 10 seconds if no reachable
// address is available.

debug!(
?mapped_addr,
?direct_addresses,
?relay_url,
"Attempting connection..."
);
debug!(?mapped_addr, "Attempting connection...");
let client_config = {
let mut alpn_protocols = vec![alpn.to_vec()];
alpn_protocols.extend(options.additional_alpns);
Expand All @@ -769,15 +762,12 @@ impl Endpoint {
client_config
};

let dest_addr = mapped_addr.private_socket_addr();
let server_name = &tls::name::encode(node_id);
let connect = self
.msock
.endpoint()
.connect_with(
client_config,
mapped_addr.private_socket_addr(),
server_name,
)
.connect_with(client_config, dest_addr, server_name)
.context(QuinnSnafu)?;

Ok(Connecting {
Expand Down Expand Up @@ -1389,7 +1379,7 @@ impl Endpoint {
None
};
match addr {
Some(addr) => {
Some(maddr) => {
// We have some way of dialing this node, but that doesn't actually mean
// we can actually connect to any of these addresses.
// Therefore, we will invoke the discovery service if we haven't received from the
Expand All @@ -1401,7 +1391,7 @@ impl Endpoint {
let discovery = DiscoveryTask::maybe_start_after_delay(self, node_id, delay)
.ok()
.flatten();
Ok((addr, discovery))
Ok((maddr, discovery))
}

None => {
Expand Down Expand Up @@ -1768,6 +1758,24 @@ impl Future for Connecting {
Poll::Ready(Err(err)) => Poll::Ready(Err(err)),
Poll::Ready(Ok(inner)) => {
let conn = Connection { inner };

// Grab the remote identity and register this connection
if let Some(remote) = *this.remote_node_id {
let weak_handle = conn.inner.weak_handle();
let path_events = conn.inner.path_events();
this.ep
.msock
.register_connection(remote, weak_handle, path_events);
} else if let Ok(remote) = conn.remote_node_id() {
let weak_handle = conn.inner.weak_handle();
let path_events = conn.inner.path_events();
this.ep
.msock
.register_connection(remote, weak_handle, path_events);
} else {
warn!("unable to determine node id for the remote");
}

try_send_rtt_msg(&conn, this.ep, *this.remote_node_id);
Poll::Ready(Ok(conn))
}
Expand Down
Loading
Loading