From b1b32e7717e7aaeca47dfbdfa704e96015e05609 Mon Sep 17 00:00:00 2001 From: Stefan Kreutz Date: Fri, 4 Aug 2023 15:11:29 +0200 Subject: [PATCH] Fix rustls-tls feature (#1194) * Fix rustls-tls feature Commit 14e74879 (cookie support #1146) re-introduced an unconditional dependency on the openssl-sys crate. That is, building Lychee with the Rustls TLS backend now requires OpenSSL. I suppose this change was unintended, maybe due to automatic conflict resolution. If not, please let me know. You can review the re-introduced dependency like so: ``` cargo tree --no-default-features --features rustls-tls -i openssl-sys ``` This commit puts the OpenSSL dependency behind the native-tls feature flag again. You can check the TLS features like so: ``` cargo check --workspace --all-targets --features vendored-openssl cargo check --workspace --all-targets --all-features cargo check --workspace --all-targets --no-default-features --features rustls-tls ``` Maybe this should be added to CI. But I don't want to waste anybody's time. * Check feature flags during CI Adds a new CI job 'check-feature-flags' to verify the following: - Lychee with rustls-tls feature only doesn't depend on OpenSSL - Cargo check passes with default features - Cargo check passes with all features - Cargo check passes with rustls-tls feature only --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ lychee-bin/src/main.rs | 1 - lychee-lib/Cargo.toml | 2 +- lychee-lib/src/client.rs | 6 +++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5860558..5cbc2bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,7 @@ jobs: needs: - test - lint + - check-feature-flags - publish-check runs-on: ubuntu-latest steps: @@ -109,3 +110,29 @@ jobs: with: command: publish args: --manifest-path lychee-bin/Cargo.toml + + check-feature-flags: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - name: Check that rustls-tls feature doesn't depend on OpenSSL + shell: bash + run: | + ! cargo tree --package lychee --no-default-features --features rustls-tls -i openssl-sys + - name: Run cargo check with default features + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace --all-targets + - name: Run cargo check with all features + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace --all-targets --all-features + - name: Run cargo check with rustls-tls feature + uses: actions-rs/cargo@v1 + with: + command: check + args: --workspace --all-targets --no-default-features --features rustls-tls diff --git a/lychee-bin/src/main.rs b/lychee-bin/src/main.rs index 0a56fc5..d056adb 100644 --- a/lychee-bin/src/main.rs +++ b/lychee-bin/src/main.rs @@ -73,7 +73,6 @@ use log::{error, info, warn}; #[cfg(feature = "native-tls")] use openssl_sys as _; // required for vendored-openssl feature -use openssl_sys as _; use options::LYCHEE_CONFIG_FILE; use ring as _; // required for apple silicon diff --git a/lychee-lib/Cargo.toml b/lychee-lib/Cargo.toml index a7447e1..3881dfb 100644 --- a/lychee-lib/Cargo.toml +++ b/lychee-lib/Cargo.toml @@ -41,7 +41,7 @@ pulldown-cmark = "0.9.3" regex = "1.9.1" # Use trust-dns to avoid lookup failures on high concurrency # https://github.com/seanmonstar/reqwest/issues/296 -reqwest = { version = "0.11.18", features = ["gzip", "trust-dns", "cookies"] } +reqwest = { version = "0.11.18", default-features = false, features = ["gzip", "trust-dns", "cookies"] } reqwest_cookie_store = "0.6.0" # Make build work on Apple Silicon. # See https://github.com/briansmith/ring/issues/1163 diff --git a/lychee-lib/src/client.rs b/lychee-lib/src/client.rs index 3bc1b04..6793f46 100644 --- a/lychee-lib/src/client.rs +++ b/lychee-lib/src/client.rs @@ -715,8 +715,12 @@ impl Client { } } + /// Check a mail address, or equivalently a `mailto` URI. + /// + /// This implementation simply excludes all email addresses. #[cfg(not(all(feature = "email-check", feature = "native-tls")))] - pub async fn check_mail(&self, uri: &Uri) -> Status { + #[allow(clippy::unused_async)] + pub async fn check_mail(&self, _uri: &Uri) -> Status { Status::Excluded } }