Skip to content
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

feat!(transport-quic): rework QUIC transport using transport framing #445

Merged
merged 5 commits into from
Nov 4, 2024
Merged
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
11 changes: 3 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ wrpc-runtime-wasmtime = { version = "0.24.1", path = "./crates/runtime-wasmtime"
wrpc-test = { path = "./crates/test", default-features = false }
wrpc-transport = { version = "0.28.2", path = "./crates/transport", default-features = false }
wrpc-transport-nats = { version = "0.27.1", path = "./crates/transport-nats", default-features = false }
wrpc-transport-quic = { version = "0.3", path = "./crates/transport-quic", default-features = false }
wrpc-transport-quic = { version = "0.4", path = "./crates/transport-quic", default-features = false }
wrpc-wasi-keyvalue = { version = "0.1", path = "./crates/wasi-keyvalue", default-features = false }
wrpc-wasi-keyvalue-mem = { version = "0.1", path = "./crates/wasi-keyvalue-mem", default-features = false }
wrpc-wasmtime-cli = { version = "0.2", path = "./crates/wasmtime-cli", default-features = false }
42 changes: 23 additions & 19 deletions crates/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ where

#[cfg(feature = "quic")]
pub async fn with_quic<T, Fut>(
names: &[&str],
f: impl FnOnce(u16, quinn::Endpoint, quinn::Endpoint) -> Fut,
f: impl FnOnce(quinn::Connection, quinn::Connection) -> Fut,
) -> anyhow::Result<T>
where
Fut: core::future::Future<Output = anyhow::Result<T>>,
Expand All @@ -92,27 +91,18 @@ where
use rcgen::{generate_simple_self_signed, CertifiedKey};
use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};
use rustls::version::TLS13;
use tokio::try_join;

let CertifiedKey {
cert: srv_crt,
key_pair: srv_key,
} = generate_simple_self_signed(
names
.iter()
.map(|name| format!("{name}.server.wrpc"))
.collect::<Vec<_>>(),
)
.context("failed to generate server certificate")?;
} = generate_simple_self_signed(["server.wrpc".to_string()])
.context("failed to generate server certificate")?;
let CertifiedKey {
cert: clt_crt,
key_pair: clt_key,
} = generate_simple_self_signed(
names
.iter()
.map(|name| format!("{name}.client.wrpc"))
.collect::<Vec<_>>(),
)
.context("failed to generate client certificate")?;
} = generate_simple_self_signed(["client.wrpc".to_string()])
.context("failed to generate client certificate")?;
let srv_crt = CertificateDer::from(srv_crt);

let mut ca = rustls::RootCertStore::empty();
Expand Down Expand Up @@ -149,7 +139,21 @@ where
Arc::new(TokioRuntime),
)
.context("failed to create server endpoint")?;
f(srv_addr.port(), clt_ep, srv_ep)
.await
.context("closure failed")

let (clt, srv) = try_join!(
async move {
let conn = clt_ep
.connect(srv_addr, "server.wrpc")
.context("failed to connect to server")?;
conn.await.context("failed to establish client connection")
},
async move {
let conn = srv_ep
.accept()
.await
.context("failed to accept connection")?;
conn.await.context("failed to establish server connection")
}
)?;
f(clt, srv).await.context("closure failed")
}
22 changes: 5 additions & 17 deletions crates/transport-quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wrpc-transport-quic"
version = "0.3.0"
version = "0.4.0"
description = "wRPC QUIC transport"

authors.workspace = true
Expand All @@ -12,24 +12,12 @@ repository.workspace = true
[dependencies]
anyhow = { workspace = true, features = ["std"] }
bytes = { workspace = true }
futures = { workspace = true }
pin-project-lite = { workspace = true }
quinn = { workspace = true, features = [
"log",
"platform-verifier",
"ring",
"runtime-tokio",
"rustls",
] }
tokio = { workspace = true, features = ["macros"] }
tokio-stream = { workspace = true }
tokio-util = { workspace = true, features = ["codec", "io"] }
tracing = { workspace = true, features = ["attributes"] }
wasm-tokio = { workspace = true }
quinn = { workspace = true, features = ["runtime-tokio"] }
tracing = { workspace = true }
wrpc-transport = { workspace = true }

[dev-dependencies]
rcgen = { workspace = true, features = ["crypto", "ring", "zeroize"] }
rustls = { workspace = true, features = ["logging", "ring"] }
futures = { workspace = true }
test-log = { workspace = true, features = ["color", "log", "trace"] }
tokio = { workspace = true, features = ["rt-multi-thread"] }
wrpc-test = { workspace = true, features = ["quic"] }
Loading
Loading