diff --git a/.github/workflows/moq-ci.yml b/.github/workflows/moq-ci.yml new file mode 100644 index 0000000000..ca185fcbf0 --- /dev/null +++ b/.github/workflows/moq-ci.yml @@ -0,0 +1,53 @@ +# The fork's own CI. Upstream's workflows stay in the tree so a sync never +# conflicts on them, but they are disabled in the repository settings because +# they need n0's self-hosted runners and secrets. +name: moq-ci + +on: + pull_request: + push: + branches: + - main + +concurrency: + group: moq-ci-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + RUST_BACKTRACE: 1 + RUSTFLAGS: -Dwarnings + RUSTDOCFLAGS: -Dwarnings + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + # The same rustfmt options as upstream's `cargo make format-check`. + - run: cargo fmt --all --check -- --config unstable_features=true --config imports_granularity=Crate,group_imports=Preserve,reorder_imports=false,format_code_in_doc_comments=true,comment_width=100,wrap_comments=true + - run: cargo clippy --workspace --all-targets --locked + - run: cargo doc --workspace --no-deps --locked + - run: cargo test --workspace --locked + # Every commit must stay publishable, so the release job cannot fail on metadata. + - run: cargo publish --workspace --locked --dry-run + + parent: + name: PARENT names an upstream commit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - run: | + parent=$(cat PARENT) + git fetch --depth=1 https://github.com/n0-computer/noq.git "$parent" diff --git a/.github/workflows/moq-release.yml b/.github/workflows/moq-release.yml new file mode 100644 index 0000000000..0229f0513a --- /dev/null +++ b/.github/workflows/moq-release.yml @@ -0,0 +1,37 @@ +# Publishes moq-noq-proto, moq-noq-udp, and moq-noq when a `v*` tag is pushed. +# The tag must match `workspace.package.version`. +# +# Uses crates.io trusted publishing, so each crate must list this repository +# and workflow as a trusted publisher. The very first version of a crate has to +# be published with a token from a maintainer's machine. +name: moq-release + +on: + push: + tags: + - "v*" + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + timeout-minutes: 30 + environment: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@stable + - name: Tag matches the workspace version + run: | + version=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "moq-noq") | .version') + test "v$version" = "${GITHUB_REF_NAME}" || { echo "tag ${GITHUB_REF_NAME} but Cargo.toml says $version"; exit 1; } + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + - run: cargo publish --workspace --locked + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} diff --git a/.github/workflows/moq-sync.yml b/.github/workflows/moq-sync.yml new file mode 100644 index 0000000000..e3aa57c76d --- /dev/null +++ b/.github/workflows/moq-sync.yml @@ -0,0 +1,49 @@ +# Merges n0-computer/noq main into the fork weekly and opens a pull request +# with the result, so drift is visible before it is expensive. A merge that +# conflicts fails the job; resolve it by hand with the same commands. +name: moq-sync + +on: + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + sync: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Merge upstream main + id: merge + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git remote add upstream https://github.com/n0-computer/noq.git + git fetch upstream main + parent=$(git rev-parse upstream/main) + if test "$(cat PARENT)" = "$parent"; then + echo "up to date with $parent" + echo "changed=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + git merge --no-edit upstream/main + echo "$parent" > PARENT + git commit -am "chore: record parent $parent" + echo "changed=true" >> "$GITHUB_OUTPUT" + echo "parent=$parent" >> "$GITHUB_OUTPUT" + - uses: peter-evans/create-pull-request@v7 + if: steps.merge.outputs.changed == 'true' + with: + branch: sync/upstream + title: "chore: sync with n0-computer/noq" + body: | + Merges n0-computer/noq main at ${{ steps.merge.outputs.parent }}. + + Compare the carried set with `git log --no-merges upstream/main..main`. diff --git a/Cargo.lock b/Cargo.lock index e8930ee9a9..b6f50b8475 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -425,7 +425,7 @@ dependencies = [ "bytes", "clap", "hdrhistogram", - "noq", + "moq-noq", "rcgen", "rustls", "tokio", @@ -1174,7 +1174,7 @@ version = "0.1.0" dependencies = [ "arbitrary", "libfuzzer-sys", - "noq-proto", + "moq-noq-proto", ] [[package]] @@ -1793,30 +1793,7 @@ dependencies = [ ] [[package]] -name = "n0-qlog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1c2fc610d1facce51b0bf5d8245b309c91996a933defdf7742c92ac78a58cb" -dependencies = [ - "humantime", - "serde", - "serde_json", - "serde_with", - "strum", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "noq" +name = "moq-noq" version = "1.3.0" dependencies = [ "anyhow", @@ -1837,8 +1814,8 @@ dependencies = [ "gcc", "http", "lazy_static", - "noq-proto", - "noq-udp", + "moq-noq-proto", + "moq-noq-udp", "pin-project-lite", "rand 0.10.2", "rcgen", @@ -1859,7 +1836,7 @@ dependencies = [ ] [[package]] -name = "noq-proto" +name = "moq-noq-proto" version = "1.3.0" dependencies = [ "aes-gcm", @@ -1899,7 +1876,7 @@ dependencies = [ ] [[package]] -name = "noq-udp" +name = "moq-noq-udp" version = "1.3.0" dependencies = [ "cfg_aliases", @@ -1912,6 +1889,29 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "n0-qlog" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1c2fc610d1facce51b0bf5d8245b309c91996a933defdf7742c92ac78a58cb" +dependencies = [ + "humantime", + "serde", + "serde_json", + "serde_with", + "strum", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -2058,8 +2058,8 @@ dependencies = [ "clap", "console-subscriber", "hdrhistogram", - "noq", - "noq-proto", + "moq-noq", + "moq-noq-proto", "rcgen", "rustls", "serde", diff --git a/Cargo.toml b/Cargo.toml index 74a2fa6886..1f0f4c0d0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ version = "1.3.0" rust-version = "1.88" edition = "2024" license = "MIT OR Apache-2.0" -repository = "https://github.com/n0-computer/noq" +repository = "https://github.com/moq-dev/noq" keywords = ["quic"] categories = ["network-programming", "asynchronous"] diff --git a/PARENT b/PARENT new file mode 100644 index 0000000000..741de3e945 --- /dev/null +++ b/PARENT @@ -0,0 +1 @@ +1a26a8b064d21e316fe6769f068617975bd8a27b diff --git a/README.md b/README.md index e00038532a..d1039b1940 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ +# noq (moq-dev fork) + +This is [moq-dev](https://github.com/moq-dev)'s fork of +[n0-computer/noq](https://github.com/n0-computer/noq), published on crates.io as +`moq-noq`, `moq-noq-proto`, and `moq-noq-udp`. It carries the QUIC features +[Media over QUIC](https://github.com/moq-dev/moq) needs before they land +upstream, and it never publishes under the parent's names. `PARENT` names the +upstream commit each release includes, and `moq-sync` merges upstream weekly. +General changes are offered upstream once their shape settles; the carried set +is `git log --no-merges upstream/main..main`. + +The upstream README follows. + +--- + # noq [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square)](https://docs.rs/noq/) diff --git a/bench/Cargo.toml b/bench/Cargo.toml index 68c30c9d99..994735cadd 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -10,7 +10,7 @@ anyhow = { workspace = true } bytes = { workspace = true } clap = { workspace = true } hdrhistogram = { workspace = true } -noq = { package = "noq", path = "../noq", features = ["ring"] } +noq = { package = "moq-noq", path = "../noq", features = ["ring"] } rcgen = { workspace = true } rustls = { workspace = true } tokio = { workspace = true, features = ["rt", "rt-multi-thread"] } diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 266b03c27b..cae1c440b3 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4.2" [dependencies.proto] features = ["arbitrary"] path = "../noq-proto" -package = "noq-proto" +package = "moq-noq-proto" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ["cfg(fuzzing)"] } diff --git a/noq-proto/Cargo.toml b/noq-proto/Cargo.toml index 4a41a898f3..ae07a5cd05 100644 --- a/noq-proto/Cargo.toml +++ b/noq-proto/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "noq-proto" +name = "moq-noq-proto" version.workspace = true edition.workspace = true rust-version.workspace = true license.workspace = true repository.workspace = true -description = "State machine for the QUIC transport protocol" +description = "MoQ fork of noq-proto: state machine for the QUIC transport protocol" keywords.workspace = true categories.workspace = true workspace = ".." diff --git a/noq-proto/benches/send_buffer.rs b/noq-proto/benches/send_buffer.rs index fc9bddb869..0065421356 100644 --- a/noq-proto/benches/send_buffer.rs +++ b/noq-proto/benches/send_buffer.rs @@ -1,5 +1,5 @@ use criterion::{criterion_group, criterion_main}; -use noq_proto::bench_exports::send_buffer_benches::*; +use moq_noq_proto::bench_exports::send_buffer_benches::*; // Since we can't easily access test utilities, this is a minimal benchmark // that measures the actual problematic operations directly diff --git a/noq-proto/src/config/transport.rs b/noq-proto/src/config/transport.rs index d8388ea17b..734e0ca315 100644 --- a/noq-proto/src/config/transport.rs +++ b/noq-proto/src/config/transport.rs @@ -101,7 +101,7 @@ impl TransportConfig { /// /// ``` /// # use std::{convert::TryInto, time::Duration}; - /// # use noq_proto::{TransportConfig, VarInt, VarIntBoundsExceeded}; + /// # use moq_noq_proto::{TransportConfig, VarInt, VarIntBoundsExceeded}; /// # fn main() -> Result<(), VarIntBoundsExceeded> { /// let mut config = TransportConfig::default(); /// @@ -339,7 +339,7 @@ impl TransportConfig { /// /// # Example /// ``` - /// # use noq_proto::*; use std::sync::Arc; + /// # use moq_noq_proto::*; use std::sync::Arc; /// let mut config = TransportConfig::default(); /// config.congestion_controller_factory(Arc::new(congestion::NewRenoConfig::default())); /// ``` @@ -900,7 +900,7 @@ impl Default for MtuDiscoveryConfig { /// /// ``` /// # use std::{convert::TryFrom, time::Duration}; -/// # use noq_proto::{IdleTimeout, VarIntBoundsExceeded, VarInt}; +/// # use moq_noq_proto::{IdleTimeout, VarIntBoundsExceeded, VarInt}; /// # fn main() -> Result<(), VarIntBoundsExceeded> { /// // A `VarInt`-encoded value in milliseconds /// let timeout = IdleTimeout::from(VarInt::from_u32(10_000)); diff --git a/noq-proto/src/endpoint.rs b/noq-proto/src/endpoint.rs index 62428f1c04..d4a29c33b2 100644 --- a/noq-proto/src/endpoint.rs +++ b/noq-proto/src/endpoint.rs @@ -1508,7 +1508,7 @@ impl IncomingImproperDropWarner { impl Drop for IncomingImproperDropWarner { fn drop(&mut self) { warn!( - "noq_proto::Incoming dropped without passing to Endpoint::accept/refuse/retry/ignore \ + "moq_noq_proto::Incoming dropped without passing to Endpoint::accept/refuse/retry/ignore \ (may cause memory leak and eventual inability to accept new connections)" ); } diff --git a/noq-udp/Cargo.toml b/noq-udp/Cargo.toml index dea12eb5c1..ee73fa9bdf 100644 --- a/noq-udp/Cargo.toml +++ b/noq-udp/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "noq-udp" +name = "moq-noq-udp" version.workspace = true edition.workspace = true rust-version.workspace = true license.workspace = true repository.workspace = true -description = "UDP sockets with ECN information for the QUIC transport protocol" +description = "MoQ fork of noq-udp: UDP sockets with ECN information for the QUIC transport protocol" keywords.workspace = true categories.workspace = true workspace = ".." diff --git a/noq-udp/benches/throughput.rs b/noq-udp/benches/throughput.rs index 26818c29ac..cb89899ce0 100644 --- a/noq-udp/benches/throughput.rs +++ b/noq-udp/benches/throughput.rs @@ -8,7 +8,7 @@ use std::{ use criterion::{Criterion, criterion_group, criterion_main}; use tokio::{io::Interest, runtime::Runtime}; -use noq_udp::{BATCH_SIZE, RecvMeta, Transmit, UdpSocketState}; +use moq_noq_udp::{BATCH_SIZE, RecvMeta, Transmit, UdpSocketState}; pub fn criterion_benchmark(c: &mut Criterion) { const TOTAL_BYTES: usize = 10 * 1024 * 1024; diff --git a/noq-udp/tests/tests.rs b/noq-udp/tests/tests.rs index f78d1d9c33..15e1bb7f15 100644 --- a/noq-udp/tests/tests.rs +++ b/noq-udp/tests/tests.rs @@ -6,7 +6,7 @@ use std::{ slice, }; -use noq_udp::{EcnCodepoint, RecvMeta, Transmit, UdpSocketState}; +use moq_noq_udp::{EcnCodepoint, RecvMeta, Transmit, UdpSocketState}; use socket2::Socket; /// Detect if running under Wine (test helper) @@ -546,7 +546,7 @@ fn apple_fast_datapath() { ); assert_eq!( send_state.max_gso_segments().get(), - noq_udp::BATCH_SIZE, + moq_noq_udp::BATCH_SIZE, "max_gso_segments should be BATCH_SIZE after enabling fast path" ); diff --git a/noq/Cargo.toml b/noq/Cargo.toml index a23779c55e..723bfea097 100644 --- a/noq/Cargo.toml +++ b/noq/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "noq" +name = "moq-noq" version.workspace = true license.workspace = true repository.workspace = true -description = "General purpose QUIC transport protocol implementation" +description = "MoQ fork of noq: general purpose QUIC transport protocol implementation" readme = "../README.md" keywords.workspace = true categories.workspace = true @@ -67,13 +67,13 @@ derive_more = { workspace = true } futures-io = { workspace = true, optional = true } rustc-hash = { workspace = true } pin-project-lite = { workspace = true } -proto = { package = "noq-proto", path = "../noq-proto", version = "1.3.0", default-features = false } +proto = { package = "moq-noq-proto", path = "../noq-proto", version = "1.3.0", default-features = false } rustls = { workspace = true, optional = true } smol = { workspace = true, optional = true } thiserror = { workspace = true } tracing = { workspace = true } tokio = { workspace = true } -udp = { package = "noq-udp", path = "../noq-udp", version = "1.3.0", default-features = false, features = ["tracing"] } +udp = { package = "moq-noq-udp", path = "../noq-udp", version = "1.3.0", default-features = false, features = ["tracing"] } # Fix minimal dependencies for indirect deps async-global-executor = { workspace = true, optional = true } @@ -149,9 +149,9 @@ features = ["__all_without_fips"] [package.metadata.cargo_check_external_types] allowed_external_types = [ - "noq_proto::*", - "noq_udp", - "noq_udp::*", + "moq_noq_proto::*", + "moq_noq_udp", + "moq_noq_udp::*", "bytes::bytes::Bytes", "futures_core::stream::Stream", "rustls", diff --git a/noq/benches/bench.rs b/noq/benches/bench.rs index 52dd309608..b440d0f634 100644 --- a/noq/benches/bench.rs +++ b/noq/benches/bench.rs @@ -10,7 +10,7 @@ use tokio::runtime::{Builder, Runtime}; use tracing::error_span; use tracing_futures::Instrument as _; -use noq::{Endpoint, TokioRuntime}; +use moq_noq::{Endpoint, TokioRuntime}; criterion_group!( benches, @@ -75,8 +75,8 @@ fn send_data(name: &str, c: &mut Criterion, data: &'static [u8], concurrent_stre } struct Context { - server_config: noq::ServerConfig, - client_config: noq::ClientConfig, + server_config: moq_noq::ServerConfig, + client_config: moq_noq::ClientConfig, } impl Context { @@ -86,7 +86,7 @@ impl Context { let cert = CertificateDer::from(cert.cert); let mut server_config = - noq::ServerConfig::with_single_cert(vec![cert.clone()], key.into()).unwrap(); + moq_noq::ServerConfig::with_single_cert(vec![cert.clone()], key.into()).unwrap(); let transport_config = Arc::get_mut(&mut server_config.transport).unwrap(); transport_config.max_concurrent_uni_streams(1024_u16.into()); @@ -95,7 +95,7 @@ impl Context { Self { server_config, - client_config: noq::ClientConfig::with_root_certificates(Arc::new(roots)).unwrap(), + client_config: moq_noq::ClientConfig::with_root_certificates(Arc::new(roots)).unwrap(), } } @@ -141,7 +141,7 @@ impl Context { pub(crate) fn make_client( &self, server_addr: SocketAddr, - ) -> (noq::Endpoint, noq::Connection, Runtime) { + ) -> (moq_noq::Endpoint, moq_noq::Connection, Runtime) { let runtime = rt(); let endpoint = { let _guard = runtime.enter(); diff --git a/noq/examples/client.rs b/noq/examples/client.rs index 0afbca3c80..0281da65e6 100644 --- a/noq/examples/client.rs +++ b/noq/examples/client.rs @@ -107,9 +107,9 @@ async fn run(options: Opt) -> Result<()> { .send_observed_address_reports(true) .receive_observed_address_reports(true); let mut client_config = - noq::ClientConfig::new(Arc::new(QuicClientConfig::try_from(client_crypto)?)); + moq_noq::ClientConfig::new(Arc::new(QuicClientConfig::try_from(client_crypto)?)); client_config.transport_config(Arc::new(transport)); - let endpoint = noq::Endpoint::client(options.bind)?; + let endpoint = moq_noq::Endpoint::client(options.bind)?; endpoint.set_default_client_config(client_config); let request = format!("GET {}\r\n", url.path()); diff --git a/noq/examples/common/mod.rs b/noq/examples/common/mod.rs index 9da55ea640..aa6af03ac4 100644 --- a/noq/examples/common/mod.rs +++ b/noq/examples/common/mod.rs @@ -1,7 +1,7 @@ #![cfg(all(feature = "rustls", any(feature = "aws-lc-rs", feature = "ring")))] //! Commonly used code in most examples. -use noq::{ClientConfig, Endpoint, ServerConfig}; +use moq_noq::{ClientConfig, Endpoint, ServerConfig}; use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer}; use std::{error::Error, net::SocketAddr, sync::Arc}; diff --git a/noq/examples/connection.rs b/noq/examples/connection.rs index ae9a2f07fb..76af2a7cf0 100644 --- a/noq/examples/connection.rs +++ b/noq/examples/connection.rs @@ -21,7 +21,7 @@ async fn main() -> Result<(), Box> { let conn = incoming_conn.await.unwrap(); println!( "[server] connection accepted: addr={}", - conn.path(noq::PathId::ZERO) + conn.path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") @@ -39,7 +39,7 @@ async fn main() -> Result<(), Box> { println!( "[client] connected: addr={}", connection - .path(noq::PathId::ZERO) + .path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") diff --git a/noq/examples/insecure_connection.rs b/noq/examples/insecure_connection.rs index d7fdc0a25e..fa2f8d63e6 100644 --- a/noq/examples/insecure_connection.rs +++ b/noq/examples/insecure_connection.rs @@ -8,7 +8,7 @@ use std::{ sync::Arc, }; -use noq::{ClientConfig, Endpoint}; +use moq_noq::{ClientConfig, Endpoint}; use proto::crypto::rustls::QuicClientConfig; use rustls::pki_types::{CertificateDer, ServerName, UnixTime}; @@ -32,7 +32,7 @@ async fn run_server(addr: SocketAddr) { let conn = incoming_conn.await.unwrap(); println!( "[server] connection accepted: addr={}", - conn.path(noq::PathId::ZERO) + conn.path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") @@ -58,7 +58,7 @@ async fn run_client(server_addr: SocketAddr) -> Result<(), Box Result<()> { } let mut server_config = - noq::ServerConfig::with_crypto(Arc::new(QuicServerConfig::try_from(server_crypto)?)); + moq_noq::ServerConfig::with_crypto(Arc::new(QuicServerConfig::try_from(server_crypto)?)); let transport_config = Arc::get_mut(&mut server_config.transport).unwrap(); transport_config .max_concurrent_uni_streams(0_u8.into()) @@ -141,7 +141,7 @@ async fn run(options: Opt) -> Result<()> { bail!("root path does not exist"); } - let endpoint = noq::Endpoint::server(server_config, options.listen)?; + let endpoint = moq_noq::Endpoint::server(server_config, options.listen)?; eprintln!("listening on {}", endpoint.local_addr()?); while let Some(conn) = endpoint.accept().await { @@ -171,15 +171,15 @@ async fn run(options: Opt) -> Result<()> { Ok(()) } -async fn handle_connection(root: Arc, conn: noq::Incoming) -> Result<()> { +async fn handle_connection(root: Arc, conn: moq_noq::Incoming) -> Result<()> { let connection = conn.await?; let span = info_span!( "connection", - remote = ?connection.path(noq::PathId::ZERO).and_then(|p| p.remote_address().ok()), + remote = ?connection.path(moq_noq::PathId::ZERO).and_then(|p| p.remote_address().ok()), protocol = %connection .handshake_data() .unwrap() - .downcast::().unwrap() + .downcast::().unwrap() .protocol .map_or_else(|| "".into(), |x| String::from_utf8_lossy(&x).into_owned()) ); @@ -200,7 +200,7 @@ async fn handle_connection(root: Arc, conn: noq::Incoming) -> Result<()> { loop { let stream = connection.accept_bi().await; let stream = match stream { - Err(noq::ConnectionError::ApplicationClosed { .. }) => { + Err(moq_noq::ConnectionError::ApplicationClosed { .. }) => { info!("connection closed"); return Ok(()); } @@ -227,7 +227,7 @@ async fn handle_connection(root: Arc, conn: noq::Incoming) -> Result<()> { async fn handle_request( root: Arc, - (mut send, mut recv): (noq::SendStream, noq::RecvStream), + (mut send, mut recv): (moq_noq::SendStream, moq_noq::RecvStream), ) -> Result<()> { let req = recv .read_to_end(64 * 1024) diff --git a/noq/examples/single_socket.rs b/noq/examples/single_socket.rs index cd0e081f8e..117ce7f02a 100644 --- a/noq/examples/single_socket.rs +++ b/noq/examples/single_socket.rs @@ -7,7 +7,7 @@ use std::{ net::{IpAddr, Ipv4Addr, SocketAddr}, }; -use noq::Endpoint; +use moq_noq::Endpoint; mod common; use common::{make_client_endpoint, make_server_endpoint}; @@ -51,7 +51,7 @@ fn run_server( println!( "[server] incoming connection: addr={}", connection - .path(noq::PathId::ZERO) + .path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") @@ -68,7 +68,7 @@ async fn run_client(endpoint: &Endpoint, server_addr: SocketAddr) { println!( "[client] connected: addr={}", connection - .path(noq::PathId::ZERO) + .path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") diff --git a/noq/src/endpoint.rs b/noq/src/endpoint.rs index 2bbabe4a5d..4472ad71d8 100644 --- a/noq/src/endpoint.rs +++ b/noq/src/endpoint.rs @@ -73,7 +73,7 @@ impl Endpoint { /// address. For example: /// /// ``` - /// noq::Endpoint::client((std::net::Ipv6Addr::UNSPECIFIED, 0).into()); + /// moq_noq::Endpoint::client((std::net::Ipv6Addr::UNSPECIFIED, 0).into()); /// ``` /// /// Some environments may not allow creation of dual-stack sockets, in which case an IPv6 diff --git a/noq/tests/many_connections.rs b/noq/tests/many_connections.rs index f0847dd4b0..76865d221d 100644 --- a/noq/tests/many_connections.rs +++ b/noq/tests/many_connections.rs @@ -7,7 +7,7 @@ use std::{ }; use crc::Crc; -use noq::{self, ConnectionError, ReadError, StoppedError, TransportConfig, WriteError}; +use moq_noq::{self, ConnectionError, ReadError, StoppedError, TransportConfig, WriteError}; use rand::{self, Rng}; use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer}; use tokio::runtime::Builder; @@ -30,7 +30,8 @@ fn connect_n_nodes_to_1_and_send_1mb_data() { let (cfg, listener_cert) = configure_listener(); let endpoint = - noq::Endpoint::server(cfg, SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)).unwrap(); + moq_noq::Endpoint::server(cfg, SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)) + .unwrap(); let listener_addr = endpoint.local_addr().unwrap(); let expected_messages = 50; @@ -74,7 +75,7 @@ fn connect_n_nodes_to_1_and_send_1mb_data() { }; runtime.spawn(async move { if let Err(e) = task.await { - use noq::ConnectionError::*; + use moq_noq::ConnectionError::*; match e { WriteError::ConnectionLost(ApplicationClosed { .. }) | WriteError::ConnectionLost(Reset) => {} @@ -92,7 +93,7 @@ fn connect_n_nodes_to_1_and_send_1mb_data() { } } -async fn read_from_peer(mut stream: noq::RecvStream) -> Result<(), ConnectionError> { +async fn read_from_peer(mut stream: moq_noq::RecvStream) -> Result<(), ConnectionError> { let crc = Crc::::new(&crc::CRC_32_ISO_HDLC); match stream.read_to_end(1024 * 1024 * 5).await { Ok(data) => { @@ -101,7 +102,7 @@ async fn read_from_peer(mut stream: noq::RecvStream) -> Result<(), ConnectionErr } Err(e) => { use ReadError::*; - use noq::ReadToEndError::*; + use moq_noq::ReadToEndError::*; match e { TooLong | Read(ClosedStream) | Read(ZeroRttRejected) => { unreachable!() @@ -113,7 +114,7 @@ async fn read_from_peer(mut stream: noq::RecvStream) -> Result<(), ConnectionErr } } -async fn write_to_peer(conn: noq::Connection, data: Vec) -> Result<(), WriteError> { +async fn write_to_peer(conn: moq_noq::Connection, data: Vec) -> Result<(), WriteError> { let mut s = conn.open_uni().await.map_err(WriteError::ConnectionLost)?; s.write_all(&data).await?; s.finish().unwrap(); @@ -126,23 +127,24 @@ async fn write_to_peer(conn: noq::Connection, data: Vec) -> Result<(), Write } /// Builds client configuration. Trusts given node certificate. -fn configure_connector(node_cert: CertificateDer<'static>) -> noq::ClientConfig { +fn configure_connector(node_cert: CertificateDer<'static>) -> moq_noq::ClientConfig { let mut roots = rustls::RootCertStore::empty(); roots.add(node_cert).unwrap(); let mut transport_config = TransportConfig::default(); transport_config.max_idle_timeout(Some(Duration::from_secs(20).try_into().unwrap())); - let mut peer_cfg = noq::ClientConfig::with_root_certificates(Arc::new(roots)).unwrap(); + let mut peer_cfg = moq_noq::ClientConfig::with_root_certificates(Arc::new(roots)).unwrap(); peer_cfg.transport_config(Arc::new(transport_config)); peer_cfg } /// Builds listener configuration along with its certificate. -fn configure_listener() -> (noq::ServerConfig, CertificateDer<'static>) { +fn configure_listener() -> (moq_noq::ServerConfig, CertificateDer<'static>) { let (our_cert, our_priv_key) = gen_cert(); let mut our_cfg = - noq::ServerConfig::with_single_cert(vec![our_cert.clone()], our_priv_key.into()).unwrap(); + moq_noq::ServerConfig::with_single_cert(vec![our_cert.clone()], our_priv_key.into()) + .unwrap(); let transport_config = Arc::get_mut(&mut our_cfg.transport).unwrap(); transport_config.max_idle_timeout(Some(Duration::from_secs(20).try_into().unwrap())); diff --git a/noq/tests/post_quantum.rs b/noq/tests/post_quantum.rs index cfa608f624..243bebd188 100644 --- a/noq/tests/post_quantum.rs +++ b/noq/tests/post_quantum.rs @@ -12,7 +12,7 @@ use rustls::{ }; use tracing::info; -use noq::{ +use moq_noq::{ Endpoint, crypto::rustls::{HandshakeData, QuicClientConfig, QuicServerConfig}, }; @@ -43,7 +43,7 @@ async fn check_post_quantum_key_exchange(min_mtu: u16) { let conn = incoming_conn.await.unwrap(); info!( "[server] connection accepted: addr={}", - conn.path(noq::PathId::ZERO) + conn.path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") @@ -69,7 +69,7 @@ async fn check_post_quantum_key_exchange(min_mtu: u16) { info!( "[client] connected: addr={}", connection - .path(noq::PathId::ZERO) + .path(moq_noq::PathId::ZERO) .expect("path open after connect") .remote_address() .expect("path is alive") @@ -98,7 +98,7 @@ fn make_client_endpoint( .with_no_client_auth(); let client_cfg = - noq::ClientConfig::new(Arc::new(QuicClientConfig::try_from(rustls_config).unwrap())); + moq_noq::ClientConfig::new(Arc::new(QuicClientConfig::try_from(rustls_config).unwrap())); let endpoint = Endpoint::client(bind_addr)?; endpoint.set_default_client_config(client_cfg); Ok(endpoint) @@ -111,7 +111,7 @@ fn make_server_endpoint( let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); let key = PrivatePkcs8KeyDer::from(cert.signing_key.serialize_der()); let cert = CertificateDer::from(cert.cert); - let mut server_config = noq::ServerConfig::with_crypto(Arc::new( + let mut server_config = moq_noq::ServerConfig::with_crypto(Arc::new( QuicServerConfig::try_from( rustls::ServerConfig::builder_with_provider(Arc::new( rustls::crypto::aws_lc_rs::default_provider(), diff --git a/perf/Cargo.toml b/perf/Cargo.toml index aafe3a3799..41eddfa975 100644 --- a/perf/Cargo.toml +++ b/perf/Cargo.toml @@ -30,8 +30,8 @@ bytes = { workspace = true } clap = { workspace = true } console-subscriber = { version = "0.5.0", features = ["parking_lot"], optional = true } hdrhistogram = { workspace = true } -noq = { package = "noq", path = "../noq" } -noq-proto = { package = "noq-proto", path = "../noq-proto" } +noq = { package = "moq-noq", path = "../noq" } +noq-proto = { package = "moq-noq-proto", path = "../noq-proto" } rcgen = { workspace = true } rustls = { workspace = true } serde = { workspace = true, optional = true }