From c1278afdb8d847fb42e54c775a7f6ff5db4421b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:44:02 -0700 Subject: [PATCH 1/4] build(deps): bump the cargo-dependencies group with 17 updates (#193) Bumps the cargo-dependencies group with 17 updates: | Package | From | To | | --- | --- | --- | | [protocol-memcache](https://github.com/pelikan-io/pelikan) | ``f2f936b`` | ``51042d6`` | | [protocol-ping](https://github.com/pelikan-io/pelikan) | ``f2f936b`` | ``51042d6`` | | [session](https://github.com/pelikan-io/pelikan) | ``f2f936b`` | ``51042d6`` | | [warp](https://github.com/seanmonstar/warp) | `0.3.6` | `0.3.7` | | [cc](https://github.com/rust-lang/cc-rs) | `1.0.90` | `1.0.91` | | common | ``f2f936b`` | ``51042d6`` | | [config](https://github.com/mehcode/config-rs) | ``f2f936b`` | ``51042d6`` | | [getrandom](https://github.com/rust-random/getrandom) | `0.2.12` | `0.2.13` | | [half](https://github.com/starkat99/half-rs) | `2.4.0` | `2.4.1` | | [logger](https://github.com/iron/logger) | ``f2f936b`` | ``51042d6`` | | [prost](https://github.com/tokio-rs/prost) | `0.12.3` | `0.12.4` | | [prost-derive](https://github.com/tokio-rs/prost) | `0.12.3` | `0.12.4` | | protocol-common | ``f2f936b`` | ``51042d6`` | | [rustversion](https://github.com/dtolnay/rustversion) | `1.0.14` | `1.0.15` | | storage-types | ``f2f936b`` | ``51042d6`` | | [tokio-tungstenite](https://github.com/snapview/tokio-tungstenite) | `0.20.1` | `0.21.0` | | [tungstenite](https://github.com/snapview/tungstenite-rs) | `0.20.1` | `0.21.0` | Updates `protocol-memcache` from `f2f936b` to `51042d6` - [Commits](https://github.com/pelikan-io/pelikan/compare/f2f936b5017e11856a493255b0fbb3a845e65623...51042d6764afab0c5cca4b530d59b6ef8c6f022d) Updates `protocol-ping` from `f2f936b` to `51042d6` - [Commits](https://github.com/pelikan-io/pelikan/compare/f2f936b5017e11856a493255b0fbb3a845e65623...51042d6764afab0c5cca4b530d59b6ef8c6f022d) Updates `session` from `f2f936b` to `51042d6` - [Commits](https://github.com/pelikan-io/pelikan/compare/f2f936b5017e11856a493255b0fbb3a845e65623...51042d6764afab0c5cca4b530d59b6ef8c6f022d) Updates `warp` from 0.3.6 to 0.3.7 - [Release notes](https://github.com/seanmonstar/warp/releases) - [Changelog](https://github.com/seanmonstar/warp/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/warp/compare/v0.3.6...v0.3.7) Updates `cc` from 1.0.90 to 1.0.91 - [Release notes](https://github.com/rust-lang/cc-rs/releases) - [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.90...1.0.91) Updates `common` from `f2f936b` to `51042d6` Updates `config` from `f2f936b` to `51042d6` - [Changelog](https://github.com/mehcode/config-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/mehcode/config-rs/commits) Updates `getrandom` from 0.2.12 to 0.2.13 - [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/getrandom/compare/v0.2.12...v0.2.13) Updates `half` from 2.4.0 to 2.4.1 - [Release notes](https://github.com/starkat99/half-rs/releases) - [Changelog](https://github.com/starkat99/half-rs/blob/main/CHANGELOG.md) - [Commits](https://github.com/starkat99/half-rs/compare/v2.4.0...v2.4.1) Updates `logger` from `f2f936b` to `51042d6` - [Commits](https://github.com/iron/logger/commits) Updates `prost` from 0.12.3 to 0.12.4 - [Release notes](https://github.com/tokio-rs/prost/releases) - [Commits](https://github.com/tokio-rs/prost/compare/v0.12.3...v0.12.4) Updates `prost-derive` from 0.12.3 to 0.12.4 - [Release notes](https://github.com/tokio-rs/prost/releases) - [Commits](https://github.com/tokio-rs/prost/compare/v0.12.3...v0.12.4) Updates `protocol-common` from `f2f936b` to `51042d6` Updates `rustversion` from 1.0.14 to 1.0.15 - [Release notes](https://github.com/dtolnay/rustversion/releases) - [Commits](https://github.com/dtolnay/rustversion/compare/1.0.14...1.0.15) Updates `storage-types` from `f2f936b` to `51042d6` Updates `tokio-tungstenite` from 0.20.1 to 0.21.0 - [Changelog](https://github.com/snapview/tokio-tungstenite/blob/master/CHANGELOG.md) - [Commits](https://github.com/snapview/tokio-tungstenite/compare/v0.20.1...v0.21.0) Updates `tungstenite` from 0.20.1 to 0.21.0 - [Changelog](https://github.com/snapview/tungstenite-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/snapview/tungstenite-rs/compare/v0.20.1...v0.21.0) --- updated-dependencies: - dependency-name: protocol-memcache dependency-type: direct:production dependency-group: cargo-dependencies - dependency-name: protocol-ping dependency-type: direct:production dependency-group: cargo-dependencies - dependency-name: session dependency-type: direct:production dependency-group: cargo-dependencies - dependency-name: warp dependency-type: direct:production update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: cc dependency-type: indirect update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: common dependency-type: indirect dependency-group: cargo-dependencies - dependency-name: config dependency-type: indirect dependency-group: cargo-dependencies - dependency-name: getrandom dependency-type: indirect update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: half dependency-type: indirect update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: logger dependency-type: indirect dependency-group: cargo-dependencies - dependency-name: prost dependency-type: indirect update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: prost-derive dependency-type: indirect update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: protocol-common dependency-type: indirect dependency-group: cargo-dependencies - dependency-name: rustversion dependency-type: indirect update-type: version-update:semver-patch dependency-group: cargo-dependencies - dependency-name: storage-types dependency-type: indirect dependency-group: cargo-dependencies - dependency-name: tokio-tungstenite dependency-type: indirect update-type: version-update:semver-minor dependency-group: cargo-dependencies - dependency-name: tungstenite dependency-type: indirect update-type: version-update:semver-minor dependency-group: cargo-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 58 ++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b702d05e..548eb01f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -565,9 +565,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" dependencies = [ "jobserver", "libc", @@ -684,7 +684,7 @@ dependencies = [ [[package]] name = "common" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "boring", "clocksource", @@ -706,7 +706,7 @@ dependencies = [ [[package]] name = "config" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "common", "log", @@ -1059,9 +1059,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "libc", @@ -1120,9 +1120,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -1590,7 +1590,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "logger" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "common", "config", @@ -2055,7 +2055,7 @@ dependencies = [ [[package]] name = "pelikan-net" version = "0.1.0" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "boring", "boring-sys", @@ -2202,9 +2202,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", "prost-derive", @@ -2212,9 +2212,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", "itertools", @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "protocol-common" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "bytes", "common", @@ -2238,7 +2238,7 @@ dependencies = [ [[package]] name = "protocol-memcache" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "clocksource", "common", @@ -2251,7 +2251,7 @@ dependencies = [ [[package]] name = "protocol-ping" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "common", "config", @@ -2610,9 +2610,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -2741,7 +2741,7 @@ dependencies = [ [[package]] name = "session" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" dependencies = [ "bytes", "clocksource", @@ -2875,7 +2875,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "storage-types" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#f2f936b5017e11856a493255b0fbb3a845e65623" +source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" [[package]] name = "strsim" @@ -3083,9 +3083,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", @@ -3267,14 +3267,14 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ "byteorder", "bytes", "data-encoding", - "http 0.2.12", + "http 1.1.0", "httparse", "log", "rand", @@ -3388,9 +3388,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" +checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c" dependencies = [ "bytes", "futures-channel", @@ -3404,13 +3404,11 @@ dependencies = [ "multer", "percent-encoding", "pin-project", - "rustls-pemfile", "scoped-tls", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-stream", "tokio-tungstenite", "tokio-util", "tower-service", From af0f1d364d366420957c25d0398ea8b254e548e3 Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 8 Apr 2024 14:56:48 -0700 Subject: [PATCH 2/4] begin next development iteration (#195) Begin next development iteration --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 548eb01f..912f9fbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2487,7 +2487,7 @@ dependencies = [ [[package]] name = "rpc-perf" -version = "5.6.0" +version = "5.6.1-alpha.0" dependencies = [ "ahash", "async-channel", diff --git a/Cargo.toml b/Cargo.toml index 20ddea31..a8773203 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rpc-perf" description = "RPC Performance Testing" -version = "5.6.0" +version = "5.6.1-alpha.0" authors = ["Brian Martin "] edition = "2021" homepage = "https://github.com/iopsystems/rpc-perf" From 2866300fa77b37cdb957944edb52dd4fba4202e5 Mon Sep 17 00:00:00 2001 From: Mihir Nanavati <3020417+mihirn@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:35:46 -0400 Subject: [PATCH 3/4] feat: allow metrics to be sampled at custom intervals (#192) Adds a new config parameter to control the file-exposition interval. Previously, this functionality was limited to secondly sampling. Now the user may specify other values, including sub-secondly sampling. --- configs/segcache.toml | 3 +++ src/config/general.rs | 28 ++++++++++++++++++++++++++++ src/config/mod.rs | 16 +++++++++------- src/output/mod.rs | 2 +- src/workload/mod.rs | 1 - 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/configs/segcache.toml b/configs/segcache.toml index c459546c..cec5079b 100644 --- a/configs/segcache.toml +++ b/configs/segcache.toml @@ -13,6 +13,9 @@ duration = 300 # optionally, specify the format for the output stats file (default is json) # possible values are (json, msgpack, parquet). #metrics_format = "parquet" +# optionally, specify the sampling interval for metrics. Input is a string +# with the unit attached; for example "100ms" or "1s". Default to 100ms. +#metrics_interval = "1s" # run the admin thread with a HTTP listener at the address provided, this allows # stats exposition via HTTP admin = "127.0.0.1:9090" diff --git a/src/config/general.rs b/src/config/general.rs index d8e68bf1..48d24076 100644 --- a/src/config/general.rs +++ b/src/config/general.rs @@ -13,6 +13,10 @@ pub enum MetricsFormat { Parquet, } +pub fn metrics_interval() -> String { + "100ms".into() +} + #[derive(Clone, Deserialize)] pub struct General { /// The protocol to be used for the test. @@ -29,6 +33,9 @@ pub struct General { /// ignored if no metrics output is specified. #[serde(default)] metrics_format: MetricsFormat, + /// The reporting interval. Specify time along with unit; default to 100ms. + #[serde(default = "metrics_interval")] + metrics_interval: String, /// The admin listen address admin: String, /// The initial seed for initializing the PRNGs. This can be any string and @@ -57,6 +64,13 @@ impl General { self.metrics_format } + pub fn metrics_interval(&self) -> Duration { + self.metrics_interval + .parse::() + .unwrap() + .into() + } + pub fn admin(&self) -> String { self.admin.clone() } @@ -73,4 +87,18 @@ impl General { Seed512(seed) } } + + pub fn validate(&self) { + let interval = self.metrics_interval.parse::(); + if let Err(e) = interval { + eprintln!("metrics_interval is not valid: {e}"); + std::process::exit(1); + } + + let interval = interval.unwrap().as_millis(); + if interval < Duration::from_millis(10).as_millis() { + eprintln!("metrics_interval should be larger than 10ms"); + std::process::exit(1); + } + } } diff --git a/src/config/mod.rs b/src/config/mod.rs index f3e3cc43..0e28b72c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -59,14 +59,16 @@ impl Config { std::process::exit(1); } } - let toml = toml::from_str(&content); - match toml { - Ok(toml) => toml, - Err(error) => { - eprintln!("Failed to parse TOML config: {filename}\n{error}"); + let config: Config = toml::from_str(&content) + .map_err(|e| { + eprintln!("Failed to parse TOML config: {filename}\n{e}"); std::process::exit(1); - } - } + }) + .unwrap(); + + config.general.validate(); + config.workload.ratelimit().validate(); + config } pub fn general(&self) -> &General { diff --git a/src/output/mod.rs b/src/output/mod.rs index 83adb0c0..6fa466c2 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -239,7 +239,7 @@ pub async fn metrics(config: Config) { // get the stop time let stop = start + config.general().duration(); - let mut interval = tokio::time::interval_at(start, Duration::from_secs(1)); + let mut interval = tokio::time::interval_at(start, config.general().metrics_interval()); let snapshotter = SnapshotterBuilder::new() .metadata("source".to_string(), env!("CARGO_BIN_NAME").to_string()) diff --git a/src/workload/mod.rs b/src/workload/mod.rs index 35e54591..8bb2a14d 100644 --- a/src/workload/mod.rs +++ b/src/workload/mod.rs @@ -741,7 +741,6 @@ pub struct Ratelimit { impl Ratelimit { pub fn new(config: &Config) -> Option { let ratelimit_config = config.workload().ratelimit(); - ratelimit_config.validate(); if !ratelimit_config.is_dynamic() { return None; From ed01ba7f3a05947f58bf586f1ee9eef51811409a Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Wed, 10 Apr 2024 11:18:42 -0700 Subject: [PATCH 4/4] switch to openssl (#194) Adds support for openssl as a TLS/SSL provider. Makes it the new default. To switch back to boringssl, the `boringssl` feature must be enabled at build time. --- .github/workflows/cargo.yml | 21 +++- Cargo.lock | 141 ++++++++++++++++----- Cargo.toml | 16 ++- src/net/mod.rs | 236 ++++++++++++++++++++++++++++++++---- 4 files changed, 350 insertions(+), 64 deletions(-) diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 051caca8..eeb34b52 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -25,6 +25,19 @@ jobs: - name: cargo check run: | cargo check --all-targets + + check-powerset: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - uses: swlynch99/cargo-sweep-action@v1 + - uses: taiki-e/install-action@cargo-hack + + - name: check powerset + run: | + cargo hack --feature-powerset check --locked clippy: runs-on: ubuntu-latest @@ -116,16 +129,16 @@ jobs: - name: build shell: bash run: | - cargo build --workspace --all-features --all-targets --locked ${{ env.FLAGS }} + cargo build --workspace --all-targets --locked ${{ env.FLAGS }} - name: test shell: bash run: | - cargo test --workspace --all-features --tests --bins --locked ${{ env.FLAGS }} + cargo test --workspace --tests --bins --locked ${{ env.FLAGS }} - name: doctests if: ${{ matrix.profile == 'debug' }} shell: bash run: | - cargo test --workspace --all-features --locked -- --test-threads 16 + cargo test --workspace --locked -- --test-threads 16 - name: generate bin artifact if: ${{ matrix.profile == 'release' && matrix.os == 'ubuntu-latest' }} @@ -157,7 +170,7 @@ jobs: - name: build shell: bash run: | - cargo build --workspace --all-features --all-targets --locked --release + cargo build --workspace --all-targets --locked --release - name: test shell: bash run: | diff --git a/Cargo.lock b/Cargo.lock index 912f9fbc..91169a25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,7 +507,7 @@ checksum = "7ae1aba472e42d3cf45ac6d0a6c8fc3ddf743871209e1b40229aed9fbdf48ece" dependencies = [ "bitflags 2.5.0", "boring-sys", - "foreign-types", + "foreign-types 0.5.0", "libc", "once_cell", ] @@ -547,9 +547,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -565,9 +565,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -684,12 +684,11 @@ dependencies = [ [[package]] name = "common" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ - "boring", "clocksource", "metriken 0.3.5", - "pelikan-net 0.1.0 (git+https://github.com/pelikan-io/pelikan)", + "pelikan-net 0.2.0 (git+https://github.com/pelikan-io/pelikan)", "ringlog", "serde", ] @@ -706,7 +705,7 @@ dependencies = [ [[package]] name = "config" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ "common", "log", @@ -906,6 +905,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared 0.1.1", +] + [[package]] name = "foreign-types" version = "0.5.0" @@ -913,7 +921,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared", + "foreign-types-shared 0.3.1", ] [[package]] @@ -927,6 +935,12 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -1059,9 +1073,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", @@ -1390,9 +1404,9 @@ checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -1590,7 +1604,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "logger" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ "common", "config", @@ -1956,12 +1970,60 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types 0.3.2", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.2.3+3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + [[package]] name = "ordered-float" version = "2.10.1" @@ -2040,26 +2102,28 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pelikan-net" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b120fd5d897107cb459176e5db0dd409056b11848accd0f4dcfc690b8bdac9b3" +checksum = "4c373eceaca2782371375d31bb2f7cd5ef1b493516253efd32dfea907c21f2b7" dependencies = [ "boring", "boring-sys", - "foreign-types-shared", + "foreign-types-shared 0.1.1", + "foreign-types-shared 0.3.1", "libc", "metriken 0.3.5", "mio", + "openssl", + "openssl-sys", ] [[package]] name = "pelikan-net" -version = "0.1.0" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +version = "0.2.0" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ - "boring", - "boring-sys", - "foreign-types-shared", + "foreign-types-shared 0.1.1", + "foreign-types-shared 0.3.1", "libc", "metriken 0.3.5", "mio", @@ -2226,7 +2290,7 @@ dependencies = [ [[package]] name = "protocol-common" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ "bytes", "common", @@ -2238,7 +2302,7 @@ dependencies = [ [[package]] name = "protocol-memcache" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ "clocksource", "common", @@ -2251,7 +2315,7 @@ dependencies = [ [[package]] name = "protocol-ping" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ "common", "config", @@ -2497,7 +2561,7 @@ dependencies = [ "bytes", "chrono", "clap", - "foreign-types-shared", + "foreign-types-shared 0.3.1", "futures", "histogram 0.10.0", "http-body-util", @@ -2508,8 +2572,10 @@ dependencies = [ "mio", "momento", "once_cell", + "openssl", + "openssl-sys", "paste", - "pelikan-net 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pelikan-net 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "protocol-memcache", "protocol-ping", "rand", @@ -2526,6 +2592,7 @@ dependencies = [ "tempfile", "tokio", "tokio-boring", + "tokio-openssl", "toml", "warp", "zipf", @@ -2741,14 +2808,14 @@ dependencies = [ [[package]] name = "session" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" dependencies = [ "bytes", "clocksource", "common", "log", "metriken 0.3.5", - "pelikan-net 0.1.0 (git+https://github.com/pelikan-io/pelikan)", + "pelikan-net 0.2.0 (git+https://github.com/pelikan-io/pelikan)", "protocol-common", ] @@ -2875,7 +2942,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "storage-types" version = "0.3.1" -source = "git+https://github.com/pelikan-io/pelikan#51042d6764afab0c5cca4b530d59b6ef8c6f022d" +source = "git+https://github.com/pelikan-io/pelikan#9f50b746d7c50a25773c685cb47e9eed3551944c" [[package]] name = "strsim" @@ -3060,6 +3127,18 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "tokio-openssl" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ffab79df67727f6acf57f1ff743091873c24c579b1e2ce4d8f53e47ded4d63d" +dependencies = [ + "futures-util", + "openssl", + "openssl-sys", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" diff --git a/Cargo.toml b/Cargo.toml index a8773203..77551251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,8 @@ license = "MIT OR Apache-2.0" ahash = "0.8.3" async-channel = "1.9.0" backtrace = "0.3.69" -boring = "3.1.0" -boring-sys = "3.1.0" +boring = { version = "3.1.0", optional = true } +boring-sys = { version = "3.1.0", optional = true } bytes = "1.5.0" chrono = "0.4.31" clap = "4.4.6" @@ -27,8 +27,10 @@ metriken = "0.6.0" metriken-exposition = { version = "0.5.0", features = ["json", "parquet-conversion"] } mio = "0.8.8" momento = "0.32.1" -pelikan-net = "0.1.0" +pelikan-net = { version = "0.2.0", default-features = false } once_cell = "1.18.0" +openssl = { version = "0.10.64", optional = true } +openssl-sys = { version = "0.9.102", optional = true } paste = "1.0.14" protocol-memcache = { git = "https://github.com/pelikan-io/pelikan" } protocol-ping = { git = "https://github.com/pelikan-io/pelikan" } @@ -45,11 +47,17 @@ sha2 = "0.10.8" slab = "0.4.9" tempfile = "3.10.1" tokio = { version = "1.33.0", features = ["full"] } -tokio-boring = "3.1.0" +tokio-boring = { version = "3.1.0", optional = true } +tokio-openssl = { version = "0.6.4", optional = true } toml = "0.8.2" warp = "0.3.6" zipf = "7.0.1" +[features] +default = ["openssl"] +boringssl = ["dep:boring", "boring-sys", "tokio-boring", "pelikan-net/boringssl"] +openssl = ["dep:openssl", "openssl-sys", "openssl/vendored", "tokio-openssl", "pelikan-net/openssl"] + [profile.release] opt-level = 3 debug = true diff --git a/src/net/mod.rs b/src/net/mod.rs index 3ce0d4b1..ff948051 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -1,9 +1,37 @@ +use crate::error; use crate::Config; -use boring::ssl::{SslFiletype, SslMethod}; -use boring::x509::X509; -use std::io::{Error, ErrorKind, Result}; -use tokio::io::ReadBuf; -use tokio::io::{AsyncRead, AsyncWrite}; + +use std::io::Result; + +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; + +pub enum SslProvider { + #[cfg(feature = "boringssl")] + Boringssl, + #[cfg(feature = "openssl")] + Openssl, + Unknown, +} + +// clippy doesn't realize that the default changes depending on enabled features +// so we suppress this warning +#[allow(clippy::derivable_impls)] +#[allow(unreachable_code)] +impl Default for SslProvider { + fn default() -> Self { + #[cfg(feature = "boringssl")] + { + return SslProvider::Boringssl; + } + + #[cfg(feature = "openssl")] + { + return SslProvider::Openssl; + } + + SslProvider::Unknown + } +} pub struct Connector { inner: ConnectorImpl, @@ -11,6 +39,91 @@ pub struct Connector { impl Connector { pub fn new(config: &Config) -> Result { + if config.tls().is_none() { + Self::plaintext() + } else { + match SslProvider::default() { + #[cfg(feature = "boringssl")] + SslProvider::Boringssl => Self::boringssl(config), + #[cfg(feature = "openssl")] + SslProvider::Openssl => Self::openssl(config), + SslProvider::Unknown => { + error!("no TLS/SSL provider could be found. Check that rpc-perf was built with either boringssl or openssl support"); + std::process::exit(1); + } + } + } + } + + fn plaintext() -> Result { + Ok(Connector { + inner: ConnectorImpl::Tcp, + }) + } + + #[cfg(feature = "boringssl")] + fn boringssl(config: &Config) -> Result { + if config.tls().is_none() { + return Ok(Connector { + inner: ConnectorImpl::Tcp, + }); + } + + let tls_config = config.tls().unwrap(); + + let private_key = tls_config.private_key(); + let certificate = tls_config.certificate(); + let certificate_chain = tls_config.certificate_chain(); + + let mut ssl_connector = + boring::ssl::SslConnector::builder(boring::ssl::SslMethod::tls_client())?; + + if let Some(ca_file) = tls_config.ca_file() { + ssl_connector.set_ca_file(ca_file)?; + } + + // mTLS configuration + if private_key.is_some() && (certificate.is_some() || certificate_chain.is_some()) { + ssl_connector + .set_private_key_file(private_key.unwrap(), boring::ssl::SslFiletype::PEM)?; + + match (certificate, certificate_chain) { + (Some(cert), Some(chain)) => { + // assume cert is just a leaf and that we need to append the + // certs in the chain file after loading the leaf cert + + ssl_connector.set_certificate_file(cert, boring::ssl::SslFiletype::PEM)?; + let pem = std::fs::read(chain)?; + let chain = boring::x509::X509::stack_from_pem(&pem)?; + for cert in chain { + ssl_connector.add_extra_chain_cert(cert)?; + } + } + (Some(cert), None) => { + // treat cert file like it's a chain for convenience + ssl_connector.set_certificate_chain_file(cert)?; + } + (None, Some(chain)) => { + // load all certs from chain + ssl_connector.set_certificate_chain_file(chain)?; + } + (None, None) => unreachable!(), + } + } + + let ssl_connector = ssl_connector.build(); + + Ok(Connector { + inner: ConnectorImpl::BoringsslTlsTcp(BoringsslTlsTcp { + inner: ssl_connector, + verify_hostname: tls_config.verify_hostname(), + use_sni: tls_config.use_sni(), + }), + }) + } + + #[cfg(feature = "openssl")] + fn openssl(config: &Config) -> Result { if config.tls().is_none() { return Ok(Connector { inner: ConnectorImpl::Tcp, @@ -23,7 +136,8 @@ impl Connector { let certificate = tls_config.certificate(); let certificate_chain = tls_config.certificate_chain(); - let mut ssl_connector = boring::ssl::SslConnector::builder(SslMethod::tls_client())?; + let mut ssl_connector = + openssl::ssl::SslConnector::builder(openssl::ssl::SslMethod::tls_client())?; if let Some(ca_file) = tls_config.ca_file() { ssl_connector.set_ca_file(ca_file)?; @@ -31,16 +145,17 @@ impl Connector { // mTLS configuration if private_key.is_some() && (certificate.is_some() || certificate_chain.is_some()) { - ssl_connector.set_private_key_file(private_key.unwrap(), SslFiletype::PEM)?; + ssl_connector + .set_private_key_file(private_key.unwrap(), openssl::ssl::SslFiletype::PEM)?; match (certificate, certificate_chain) { (Some(cert), Some(chain)) => { // assume cert is just a leaf and that we need to append the // certs in the chain file after loading the leaf cert - ssl_connector.set_certificate_file(cert, SslFiletype::PEM)?; + ssl_connector.set_certificate_file(cert, openssl::ssl::SslFiletype::PEM)?; let pem = std::fs::read(chain)?; - let chain = X509::stack_from_pem(&pem)?; + let chain = openssl::x509::X509::stack_from_pem(&pem)?; for cert in chain { ssl_connector.add_extra_chain_cert(cert)?; } @@ -60,7 +175,7 @@ impl Connector { let ssl_connector = ssl_connector.build(); Ok(Connector { - inner: ConnectorImpl::TlsTcp(TlsTcpConnector { + inner: ConnectorImpl::OpensslTlsTcp(OpensslTlsTcp { inner: ssl_connector, verify_hostname: tls_config.verify_hostname(), use_sni: tls_config.use_sni(), @@ -80,7 +195,8 @@ impl Connector { inner: StreamImpl::Tcp(s), }) } - ConnectorImpl::TlsTcp(connector) => { + #[cfg(feature = "boringssl")] + ConnectorImpl::BoringsslTlsTcp(connector) => { let stream = tokio::net::TcpStream::connect(addr).await?; let domain = addr.split(':').next().unwrap().to_owned(); @@ -92,11 +208,40 @@ impl Connector { match tokio_boring::connect(config, &domain, stream).await { Ok(stream) => Ok(Stream { - inner: StreamImpl::TlsTcp(stream), + inner: StreamImpl::BoringsslTlsTcp(stream), }), Err(e) => match e.as_io_error() { - Some(e) => Err(Error::new(e.kind(), e.to_string())), - None => Err(Error::new(ErrorKind::Other, e.to_string())), + Some(e) => Err(std::io::Error::new(e.kind(), e.to_string())), + None => Err(std::io::Error::new( + std::io::ErrorKind::Other, + e.to_string(), + )), + }, + } + } + #[cfg(feature = "openssl")] + ConnectorImpl::OpensslTlsTcp(connector) => { + let stream = tokio::net::TcpStream::connect(addr).await?; + let domain = addr.split(':').next().unwrap().to_owned(); + + let config = connector + .inner + .configure()? + .verify_hostname(connector.verify_hostname) + .use_server_name_indication(connector.use_sni); + + let mut ssl = tokio_openssl::SslStream::new(config.into_ssl(&domain)?, stream)?; + + match tokio_openssl::SslStream::connect(std::pin::Pin::new(&mut ssl)).await { + Ok(_) => Ok(Stream { + inner: StreamImpl::OpensslTlsTcp(ssl), + }), + Err(e) => match e.io_error() { + Some(e) => Err(std::io::Error::new(e.kind(), e.to_string())), + None => Err(std::io::Error::new( + std::io::ErrorKind::Other, + e.to_string(), + )), }, } } @@ -106,22 +251,36 @@ impl Connector { enum ConnectorImpl { Tcp, - TlsTcp(TlsTcpConnector), + #[cfg(feature = "boringssl")] + BoringsslTlsTcp(BoringsslTlsTcp), + #[cfg(feature = "openssl")] + OpensslTlsTcp(OpensslTlsTcp), } -pub struct TlsTcpConnector { +#[cfg(feature = "boringssl")] +pub struct BoringsslTlsTcp { inner: boring::ssl::SslConnector, verify_hostname: bool, use_sni: bool, } +#[cfg(feature = "openssl")] +pub struct OpensslTlsTcp { + inner: openssl::ssl::SslConnector, + verify_hostname: bool, + use_sni: bool, +} + pub struct Stream { inner: StreamImpl, } enum StreamImpl { Tcp(tokio::net::TcpStream), - TlsTcp(tokio_boring::SslStream), + #[cfg(feature = "boringssl")] + BoringsslTlsTcp(tokio_boring::SslStream), + #[cfg(feature = "openssl")] + OpensslTlsTcp(tokio_openssl::SslStream), } impl AsyncRead for Stream { @@ -132,7 +291,10 @@ impl AsyncRead for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_read(cx, buf), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_read(cx, buf), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_read(cx, buf), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_read(cx, buf), } } } @@ -145,7 +307,10 @@ impl AsyncWrite for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), } } fn poll_flush( @@ -154,7 +319,10 @@ impl AsyncWrite for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_flush(cx), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_flush(cx), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_flush(cx), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_flush(cx), } } fn poll_shutdown( @@ -163,7 +331,10 @@ impl AsyncWrite for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), } } } @@ -179,7 +350,13 @@ impl hyper::rt::Read for Stream { let mut buf = ReadBuf::uninit(unsafe { rbc.as_mut() }); std::pin::Pin::new(s).poll_read(cx, &mut buf) } - StreamImpl::TlsTcp(s) => { + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => { + let mut buf = ReadBuf::uninit(unsafe { rbc.as_mut() }); + std::pin::Pin::new(s).poll_read(cx, &mut buf) + } + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => { let mut buf = ReadBuf::uninit(unsafe { rbc.as_mut() }); std::pin::Pin::new(s).poll_read(cx, &mut buf) } @@ -195,7 +372,10 @@ impl hyper::rt::Write for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_write(cx, buf), } } @@ -205,7 +385,10 @@ impl hyper::rt::Write for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_flush(cx), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_flush(cx), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_flush(cx), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_flush(cx), } } @@ -215,7 +398,10 @@ impl hyper::rt::Write for Stream { ) -> std::task::Poll> { match &mut self.inner { StreamImpl::Tcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), - StreamImpl::TlsTcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), + #[cfg(feature = "boringssl")] + StreamImpl::BoringsslTlsTcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), + #[cfg(feature = "openssl")] + StreamImpl::OpensslTlsTcp(s) => std::pin::Pin::new(s).poll_shutdown(cx), } } }