Skip to content

Commit

Permalink
Fix root crate compilation dependencies to force sha1*
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed Aug 28, 2024
1 parent 67f984a commit c063cc5
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions crates/librqbit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ http-api = ["axum", "tower-http"]
upnp-serve-adapter = ["upnp-serve"]
webui = []
timed_existence = []
default-tls = ["reqwest/default-tls", "sha1w/sha1-crypto-hash"]
rust-tls = ["reqwest/rustls-tls", "sha1w/sha1-ring"]
default-tls = [
"reqwest/default-tls",
"sha1w/sha1-crypto-hash",
"bencode/sha1-crypto-hash",
"librqbit-core/sha1-crypto-hash",
]
rust-tls = [
"reqwest/rustls-tls",
"sha1w/sha1-ring",
"sha1w/sha1-ring",
"bencode/sha1-ring",
"librqbit-core/sha1-ring",
]
storage_middleware = ["lru"]
storage_examples = []
tracing-subscriber-utils = ["tracing-subscriber"]
Expand Down
1 change: 1 addition & 0 deletions crates/librqbit_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ directories = "5"
tokio-util = "0.7.10"
data-encoding = "2.6.0"
bytes = "1.7.1"
assert_cfg = "0.1.0"


[dev-dependencies]
Expand Down
5 changes: 5 additions & 0 deletions crates/librqbit_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ pub mod speed_estimator;
pub mod torrent_metainfo;

pub use hash_id::Id20;

assert_cfg::exactly_one! {
feature = "sha1-crypto-hash",
feature = "sha1-ring",
}
6 changes: 5 additions & 1 deletion crates/librqbit_core/src/torrent_metainfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ pub fn torrent_from_bytes_ext<'de, BufType: Deserialize<'de> + From<&'de [u8]>>(
let mut t = TorrentMetaV1::deserialize(&mut de)?;
let (digest, info_bytes) = match (de.torrent_info_digest, de.torrent_info_bytes) {
(Some(digest), Some(info_bytes)) => (digest, info_bytes),
_ => anyhow::bail!("programming error"),
(o1, o2) => anyhow::bail!(
"programming error: digest.is_some()={}, info_bytes.is_some()={}. Probably one of bencode/sha1* features isn't enabled.",
o1.is_some(),
o2.is_some()
),
};
t.info_hash = Id20::new(digest);
Ok(ParsedTorrent {
Expand Down
1 change: 1 addition & 0 deletions crates/sha1w/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ sha1-crypto-hash = ["crypto-hash"]
sha1-ring = ["ring"]

[dependencies]
assert_cfg = "0.1.0"
crypto-hash = { version = "0.3", optional = true }
ring = { version = "0.17", optional = true }
5 changes: 5 additions & 0 deletions crates/sha1w/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ pub trait ISha1 {
fn finish(self) -> [u8; 20];
}

assert_cfg::exactly_one! {
feature = "sha1-crypto-hash",
feature = "sha1-ring",
}

#[cfg(feature = "sha1-crypto-hash")]
mod crypto_hash_impl {
use super::ISha1;
Expand Down

0 comments on commit c063cc5

Please sign in to comment.