From 535ff079873c5697424bedbbc1b18758b6854337 Mon Sep 17 00:00:00 2001 From: iHsin Date: Wed, 18 Dec 2024 14:24:04 +0800 Subject: [PATCH] fix: no process-level CryptoProvider available --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++--------- Cargo.lock | 1 + tuic-client/Cargo.toml | 12 ++++++++++-- tuic-client/src/connection/mod.rs | 6 +++++- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7884d1b0..7e52746d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,25 +43,29 @@ jobs: target: x86_64-unknown-linux-gnu release-name: x86_64-linux cross: true + extra-args: "--features jemallocator" - os: ubuntu-latest target: i686-unknown-linux-gnu release-name: i686-linux cross: true + extra-args: "--features jemallocator" # Linux x86 musl - os: ubuntu-latest target: x86_64-unknown-linux-musl release-name: x86_64-linux-musl cross: true + extra-args: "--features jemallocator" - os: ubuntu-latest target: i686-unknown-linux-musl release-name: i686-linux-musl cross: true - extra-args: "--no-default-features --features ring" + extra-args: "--no-default-features --features ring,jemallocator" # Linux arm - os: ubuntu-latest target: aarch64-unknown-linux-gnu release-name: aarch64-linux cross: true + extra-args: "--features jemallocator" - os: ubuntu-latest target: armv7-unknown-linux-gnueabi release-name: armv7-linux @@ -77,47 +81,47 @@ jobs: target: aarch64-unknown-linux-musl release-name: aarch64-linux-musl cross: true + extra-args: "--features jemallocator" - os: ubuntu-latest target: armv7-unknown-linux-musleabi release-name: armv7-linux-musl cross: true - extra-args: "--no-default-features --features ring" + extra-args: "--no-default-features --features ring,jemallocator" - os: ubuntu-latest target: armv7-unknown-linux-musleabihf release-name: armv7-linux-muslhf cross: true - extra-args: "--no-default-features --features ring" + extra-args: "--no-default-features --features ring,jemallocator" # Windows - os: windows-latest target: x86_64-pc-windows-msvc release-name: x86_64-windows cross: false postfix: ".exe" - extra-args: "--no-default-features --features aws-lc-rs" - os: windows-latest target: i686-pc-windows-msvc release-name: i686-windows cross: false postfix: ".exe" - extra-args: "--no-default-features --features ring" + extra-args: "--features ring" # Windows Arm - os: windows-latest target: aarch64-pc-windows-msvc release-name: aarch64-windows cross: false postfix: ".exe" - extra-args: "--no-default-features --features aws-lc-rs" - # MacOSX - os: macos-13 target: x86_64-apple-darwin release-name: x86_64-darwin cross: false - + extra-args: "--features jemallocator" + - os: macos-14 target: aarch64-apple-darwin release-name: aarch64-darwin cross: false + extra-args: "--features jemallocator" # FreeBSD # - os: ubuntu-latest @@ -195,7 +199,16 @@ jobs: with: use-cross: ${{ matrix.cross }} command: build - args: --release --target ${{ matrix.target }} ${{ matrix.extra-args }} + args: --package ${{ env.PACKAGE }} --release --target ${{ matrix.target }} ${{ matrix.extra-args }} + env: + RUSTFLAGS: ${{ matrix.rustflags }} + + - name: Cargo build + uses: clechasseur/rs-cargo@v2 + with: + use-cross: ${{ matrix.cross }} + command: build + args: --package ${{ env.PACKAGE2 }} --release --target ${{ matrix.target }} ${{ matrix.extra-args }} env: RUSTFLAGS: ${{ matrix.rustflags }} diff --git a/Cargo.lock b/Cargo.lock index 3f50c430..ac3036fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1979,6 +1979,7 @@ dependencies = [ "socks5-proto", "socks5-server", "thiserror", + "tikv-jemallocator", "tokio", "tokio-util", "tuic", diff --git a/tuic-client/Cargo.toml b/tuic-client/Cargo.toml index e0543d66..61069a2c 100644 --- a/tuic-client/Cargo.toml +++ b/tuic-client/Cargo.toml @@ -11,6 +11,12 @@ readme.workspace = true license.workspace = true repository.workspace = true +[features] +default = ["aws-lc-rs"] +ring = ["rustls/ring", "quinn/rustls-ring"] +aws-lc-rs = ["rustls/aws-lc-rs", "quinn/rustls-aws-lc-rs"] +jemallocator = ["tikv-jemallocator"] + [dependencies] bytes = { version = "1", default-features = false, features = ["std"] } @@ -29,7 +35,7 @@ socks5-server = { version = "0.8", default-features = false } uuid = { version = "1", default-features = false, features = ["serde", "std"] } # QUIC -quinn = { version = "0.11", default-features = false, features = ["runtime-tokio", "rustls", "log"] } +quinn = { version = "0.11", default-features = false, features = ["runtime-tokio","log"] } # TUIC tuic = { path = "../tuic", default-features = false } @@ -48,4 +54,6 @@ rustls-pemfile = { version = "2", default-features = false, features = ["std"] } # Error-handling thiserror = { version = "2", default-features = false } -anyhow = "1" \ No newline at end of file +anyhow = "1" + +tikv-jemallocator = { version = "0.6", optional = true } \ No newline at end of file diff --git a/tuic-client/src/connection/mod.rs b/tuic-client/src/connection/mod.rs index 6c8d92b9..a6bd7b6b 100644 --- a/tuic-client/src/connection/mod.rs +++ b/tuic-client/src/connection/mod.rs @@ -64,7 +64,11 @@ impl Connection { impl SkipServerVerification { fn new() -> Arc { - Arc::new(Self(Arc::new(rustls::crypto::ring::default_provider()))) + Arc::new(Self( + rustls::crypto::CryptoProvider::get_default() + .expect("Crypto not found") + .clone(), + )) } }