From 40536b13da4d4b720bddb590f9158f110a9ef6fa Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Wed, 11 Feb 2026 18:21:19 +0000 Subject: [PATCH] feat: Add experimental http3 support Only enabled in Docker builds for now, due to build config required. Not sure if more work is needed for 0RTT. --- Cargo.lock | 37 +++++++++++++++++++++++++++++++++++++ docker/Dockerfile | 10 ++++++++++ docs/deploying/generic.mdx | 2 ++ src/api/Cargo.toml | 4 ++++ src/core/Cargo.toml | 3 +++ src/main/Cargo.toml | 5 +++++ src/service/Cargo.toml | 3 +++ 7 files changed, 64 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 54ea9964..639a2507 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1857,6 +1857,12 @@ dependencies = [ "zune-inflate", ] +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "fax" version = "0.2.6" @@ -2157,6 +2163,34 @@ dependencies = [ "tracing", ] +[[package]] +name = "h3" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10872b55cfb02a821b69dc7cf8dc6a71d6af25eb9a79662bec4a9d016056b3be" +dependencies = [ + "bytes", + "fastrand", + "futures-util", + "http", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "h3-quinn" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2e732c8d91a74731663ac8479ab505042fbf547b9a207213ab7fbcbfc4f8b4" +dependencies = [ + "bytes", + "futures", + "h3", + "quinn", + "tokio", + "tokio-util", +] + [[package]] name = "half" version = "2.7.1" @@ -3919,6 +3953,7 @@ checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" dependencies = [ "bytes", "cfg_aliases", + "futures-io", "pin-project-lite", "quinn-proto", "quinn-udp", @@ -4171,6 +4206,8 @@ dependencies = [ "futures-core", "futures-util", "h2", + "h3", + "h3-quinn", "hickory-resolver", "http", "http-body", diff --git a/docker/Dockerfile b/docker/Dockerfile index 7239a08e..76b8bcb1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -162,6 +162,7 @@ ENV CONDUWUIT_VERSION_EXTRA=$CONDUWUIT_VERSION_EXTRA ENV CONTINUWUITY_VERSION_EXTRA=$CONTINUWUITY_VERSION_EXTRA ARG RUST_PROFILE=release +ARG CARGO_FEATURES="default,http3" # Build the binary RUN --mount=type=cache,target=/usr/local/cargo/registry \ @@ -171,11 +172,20 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \ set -o allexport set -o xtrace . /etc/environment + + # Check if http3 feature is enabled and set appropriate RUSTFLAGS + if echo "${CARGO_FEATURES}" | grep -q "http3"; then + export RUSTFLAGS="${RUSTFLAGS} --cfg reqwest_unstable" + else + export RUSTFLAGS="${RUSTFLAGS}" + fi + TARGET_DIR=($(cargo metadata --no-deps --format-version 1 | \ jq -r ".target_directory")) mkdir /out/sbin PACKAGE=conduwuit xx-cargo build --locked --profile ${RUST_PROFILE} \ + --no-default-features --features ${CARGO_FEATURES} \ -p $PACKAGE; BINARIES=($(cargo metadata --no-deps --format-version 1 | \ jq -r ".packages[] | select(.name == \"$PACKAGE\") | .targets[] | select( .kind | map(. == \"bin\") | any ) | .name")) diff --git a/docs/deploying/generic.mdx b/docs/deploying/generic.mdx index 9a501298..416cc694 100644 --- a/docs/deploying/generic.mdx +++ b/docs/deploying/generic.mdx @@ -56,6 +56,8 @@ If wanting to build using standard Rust toolchains, make sure you install: You can build Continuwuity using `cargo build --release`. +Continuwuity supports various optional features that can be enabled during compilation. Please see the Cargo.toml file for a comprehensive list, or ask in our rooms. + ### Building with Nix If you prefer, you can use Nix (or [Lix](https://lix.systems)) to build Continuwuity. This provides improved reproducibility and makes it easy to set up a build environment and generate output. This approach also allows for easy cross-compilation. diff --git a/src/api/Cargo.toml b/src/api/Cargo.toml index 393ceecf..6f1779bc 100644 --- a/src/api/Cargo.toml +++ b/src/api/Cargo.toml @@ -28,6 +28,10 @@ gzip_compression = [ "conduwuit-service/gzip_compression", "reqwest/gzip", ] +http3 = [ + "conduwuit-core/http3", + "conduwuit-service/http3", +] io_uring = [ "conduwuit-service/io_uring", ] diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index 8139f2d3..4edaad03 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -24,6 +24,9 @@ conduwuit_mods = [ gzip_compression = [ "reqwest/gzip", ] +http3 = [ + "reqwest/http3", +] hardened_malloc = [ "dep:hardened_malloc-rs" ] diff --git a/src/main/Cargo.toml b/src/main/Cargo.toml index 7a4dd4d6..0a02384a 100644 --- a/src/main/Cargo.toml +++ b/src/main/Cargo.toml @@ -99,6 +99,11 @@ gzip_compression = [ hardened_malloc = [ "conduwuit-core/hardened_malloc", ] +http3 = [ + "conduwuit-api/http3", + "conduwuit-core/http3", + "conduwuit-service/http3", +] io_uring = [ "conduwuit-database/io_uring", ] diff --git a/src/service/Cargo.toml b/src/service/Cargo.toml index c89b39b4..8591496b 100644 --- a/src/service/Cargo.toml +++ b/src/service/Cargo.toml @@ -32,6 +32,9 @@ gzip_compression = [ "conduwuit-core/gzip_compression", "reqwest/gzip", ] +http3 = [ + "conduwuit-core/http3", +] io_uring = [ "conduwuit-database/io_uring", ]