mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-17 10:11:07 +00:00
* Add optional Rustls support
This commit adds a non-default feature flag to use Rustls instead of OpenSSL.
My personal motivation is to use Lychee on OpenBSD -current, where the
`openssl` crate frequently fails to link against the unreleased system
LibreSSL. Using the `vendored-openssl` feature helps with compilation, but
segfaults at runtime.
The commit adds three feature flags to the library, binary, benchmark, and all
examples:
- The `native-tls` feature flag toggles the `openssl` crate.
- The `rustls-tls` feature flag toggles the `rustls` crate.
- The `email-check` feature flag toggles the `check-if-email-exists` crate,
which is the only existing functionality currently incompatible with Rustls.
By default, `native-tls` and `email-check` are enabled. Thus, Lychee (bin and
lib) can be used as before unless default features are disabled.
To use the Rustls feature, pass `--no-default-features --features rustls` to
cargo check/build/test/..., e.g.,
$ cargo clippy --workspace --all-targets --no-default-features \ --features
rustls-tls -- --deny warnings
Checking email addresses requires both, `native-tls` and `email-check`, to be
enabled. Otherwise, email addresses are excluded.
The `email-check` feature flag is technically not necessary. I preferred it
over `not(rustls-tls)` because it's clearer and it addresses the AGPL license
issue #594. As far as I understand, a Lychee binary compiled without the
`email-check` feature could be distributed with file-based copyleft for the
MPL-licensed dependencies only. But that's out of scope here.
The benchmark shows a performance regression varying between 2% and 4.4% when
using Rustls instead of OpenSSL on my machine.
PS: The `ring` crate needs to be patched on OpenBSD 7.3 and later until the new
xonly patches have been upstreamed, see the `rust-ring` port.
* Use platform native certificates with Rustls
By default, reqwest uses the webpki-roots crate with Rustls, effectively
bundling Mozilla's root certificates.
This commit uses the rustls-native-certs crate instead to use locally
installed root certificates, to minimize the difference between the
native-tls and rustls-tls features.
* Document feature flags
110 lines
3.4 KiB
TOML
110 lines
3.4 KiB
TOML
[package]
|
|
name = "lychee"
|
|
authors = ["Matthias Endler <matthias@endler.dev>"]
|
|
description = "A fast, async link checker"
|
|
documentation = "https://docs.rs/lychee"
|
|
homepage = "https://github.com/lycheeverse/lychee"
|
|
edition = "2021"
|
|
keywords = [
|
|
"link",
|
|
"checker",
|
|
"cli",
|
|
"link-checker",
|
|
"validator",
|
|
]
|
|
license = "Apache-2.0/MIT"
|
|
repository = "https://github.com/lycheeverse/lychee"
|
|
version = "0.13.0"
|
|
|
|
[dependencies]
|
|
lychee-lib = { path = "../lychee-lib", version = "0.13.0", default-features = false }
|
|
anyhow = "1.0.71"
|
|
console = "0.15.7"
|
|
const_format = "0.2.31"
|
|
headers = "0.3.8"
|
|
http = "0.2.9"
|
|
indicatif = "0.17.5"
|
|
openssl-sys = { version = "0.9.88", optional = true }
|
|
pad = "0.1.6"
|
|
regex = "1.8.4"
|
|
reqwest = { version = "0.11.18", default-features = false, features = ["gzip", "json"] }
|
|
# Make build work on Apple Silicon.
|
|
# See https://github.com/briansmith/ring/issues/1163
|
|
# This is necessary for the homebrew build
|
|
# https://github.com/Homebrew/homebrew-core/pull/70216
|
|
ring = "0.16.20"
|
|
serde = { version = "1.0.164", features = ["derive"] }
|
|
serde_json = "1.0.96"
|
|
tabled = "0.12.1"
|
|
toml = "0.7.4"
|
|
tokio = { version = "1.28.2", features = ["full"] }
|
|
futures = "0.3.27"
|
|
tokio-stream = "0.1.14"
|
|
once_cell = "1.18.0"
|
|
dashmap = { version = "5.4.0", features = ["serde"] }
|
|
csv = "1.2.2"
|
|
humantime = "2.1.0"
|
|
humantime-serde = "1.1.1"
|
|
secrecy = { version = "0.8.0", features = ["serde"] }
|
|
supports-color = "2.0.0"
|
|
log = "0.4.19"
|
|
env_logger = "0.10.0"
|
|
strum = {version = "0.24.1" , features = ["derive"] }
|
|
assert-json-diff = "2.0.2"
|
|
|
|
[dependencies.clap]
|
|
version = "4.1.11"
|
|
features = ["env", "derive"]
|
|
|
|
[dev-dependencies]
|
|
assert_cmd = "2.0.11"
|
|
pretty_assertions = "1.3.0"
|
|
predicates = "3.0.3"
|
|
tempfile = "3.6.0"
|
|
uuid = { version = "1.3.4", features = ["v4"] }
|
|
wiremock = "0.5.19"
|
|
tracing-subscriber = { version = "0.3.17", default-features = false, features = ["fmt", "registry", "env-filter"] }
|
|
|
|
# console-subscriber is not yet published to crates.io
|
|
# Users have to uncomment this section and the feature below and build lychee
|
|
# locally
|
|
# TODO: Remove this git revision pin after publication
|
|
#[dependencies.console-subscriber]
|
|
#optional = true
|
|
#git = "https://github.com/tokio-rs/console"
|
|
#rev = "926de99ce4cbfd02c87190f9ec5f1c60b5c305d5"
|
|
|
|
[features]
|
|
#tokio-console = ["console-subscriber", "tracing-subscriber/registry"]
|
|
|
|
# Compile and statically link a copy of OpenSSL.
|
|
vendored-openssl = ["openssl-sys/vendored"]
|
|
|
|
# Allow checking example domains such as example.com.
|
|
check_example_domains = ["lychee-lib/check_example_domains"]
|
|
|
|
# Enable checking email addresses. Requires the native-tls feature.
|
|
email-check = ["lychee-lib/email-check"]
|
|
|
|
# Use platform-native TLS.
|
|
native-tls = ["lychee-lib/native-tls", "openssl-sys", "reqwest/native-tls"]
|
|
|
|
# Use Rustls TLS.
|
|
rustls-tls = ["lychee-lib/rustls-tls", "reqwest/rustls-tls-native-roots"]
|
|
|
|
default = ["native-tls", "email-check"]
|
|
|
|
# Unfortunately, it's not possible to automatically enable features
|
|
# for cargo test. See rust-lang/cargo#2911.
|
|
# As a workaround we introduce a new feature to allow example domains
|
|
# in integration tests.
|
|
[[test]]
|
|
name = "cli"
|
|
path = "tests/cli.rs"
|
|
required-features = ["check_example_domains"]
|
|
|
|
# metadata for cargo-binstall to get the right artifacts
|
|
[package.metadata.binstall]
|
|
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-v{ version }-{ target }{ archive-suffix }"
|
|
bin-dir = "{ bin }{ binary-ext }"
|
|
pkg-fmt = "tgz"
|