diff --git a/Cargo.lock b/Cargo.lock index fa03580..6f6e9fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,17 +147,6 @@ dependencies = [ "syn", ] -[[package]] -name = "async-recursion" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "async-stream" version = "0.3.5" @@ -1564,7 +1553,7 @@ dependencies = [ [[package]] name = "librqbit-bencode" -version = "3.0.0" +version = "3.0.1" dependencies = [ "anyhow", "bytes", @@ -1592,7 +1581,7 @@ dependencies = [ [[package]] name = "librqbit-core" -version = "4.0.0" +version = "4.0.1" dependencies = [ "anyhow", "bytes", @@ -1658,7 +1647,7 @@ dependencies = [ [[package]] name = "librqbit-sha1-wrapper" -version = "3.0.0" +version = "4.0.0" dependencies = [ "crypto-hash", "ring", @@ -1666,7 +1655,7 @@ dependencies = [ [[package]] name = "librqbit-tracker-comms" -version = "1.0.3" +version = "2.0.0" dependencies = [ "anyhow", "async-stream", @@ -1689,7 +1678,6 @@ name = "librqbit-upnp" version = "0.1.1" dependencies = [ "anyhow", - "async-recursion", "bstr", "futures", "httparse", @@ -1869,8 +1857,9 @@ dependencies = [ [[package]] name = "network-interface" -version = "1.1.1" -source = "git+https://github.com/ikatson/network-interface?branch=compile-on-freebsd#aca8a95ab1bb41a27bc82c6a2425eb4824bf0352" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433419f898328beca4f2c6c73a1b52540658d92b0a99f0269330457e0fd998d5" dependencies = [ "cc", "libc", diff --git a/crates/bencode/Cargo.toml b/crates/bencode/Cargo.toml index 0e77460..d518cde 100644 --- a/crates/bencode/Cargo.toml +++ b/crates/bencode/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "librqbit-bencode" -version = "3.0.0" +version = "3.0.1" edition = "2021" description = "Bencode serialization and deserialization using Serde" license = "Apache-2.0" @@ -19,5 +19,5 @@ serde = { version = "1", features = ["derive"] } buffers = { path = "../buffers", package = "librqbit-buffers", version = "4" } clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" } anyhow = "1" -sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "3.0.0" } +sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "4" } bytes = "1.7.1" diff --git a/crates/bencode/src/serde_bencode_de.rs b/crates/bencode/src/serde_bencode_de.rs index b6f3a47..1e4666f 100644 --- a/crates/bencode/src/serde_bencode_de.rs +++ b/crates/bencode/src/serde_bencode_de.rs @@ -1,6 +1,5 @@ use buffers::ByteBuf; use serde::de::Error as DeError; -use sha1w::{ISha1, Sha1}; pub struct BencodeDeserializer<'de> { buf: &'de [u8], @@ -539,16 +538,21 @@ impl<'a, 'de> serde::de::MapAccess<'de> for MapAccess<'a, 'de> { where V: serde::de::DeserializeSeed<'de>, { + #[cfg(any(feature = "sha1-crypto-hash", feature = "sha1-ring"))] let buf_before = self.de.buf; let value = seed.deserialize(&mut *self.de)?; - if self.de.is_torrent_info && self.de.field_context.as_slice() == [ByteBuf(b"info")] { - let len = self.de.buf.as_ptr() as usize - buf_before.as_ptr() as usize; - let mut hash = Sha1::new(); - let torrent_info_bytes = &buf_before[..len]; - hash.update(torrent_info_bytes); - let digest = hash.finish(); - self.de.torrent_info_digest = Some(digest); - self.de.torrent_info_bytes = Some(torrent_info_bytes); + #[cfg(any(feature = "sha1-crypto-hash", feature = "sha1-ring"))] + { + use sha1w::{ISha1, Sha1}; + if self.de.is_torrent_info && self.de.field_context.as_slice() == [ByteBuf(b"info")] { + let len = self.de.buf.as_ptr() as usize - buf_before.as_ptr() as usize; + let mut hash = Sha1::new(); + let torrent_info_bytes = &buf_before[..len]; + hash.update(torrent_info_bytes); + let digest = hash.finish(); + self.de.torrent_info_digest = Some(digest); + self.de.torrent_info_bytes = Some(torrent_info_bytes); + } } self.de.field_context.pop(); Ok(value) diff --git a/crates/dht/Cargo.toml b/crates/dht/Cargo.toml index db05ed8..6ee931c 100644 --- a/crates/dht/Cargo.toml +++ b/crates/dht/Cargo.toml @@ -32,7 +32,7 @@ rand = "0.8" indexmap = "2" dashmap = { version = "5.5.3", features = ["serde"] } clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" } -librqbit-core = { path = "../librqbit_core", version = "4" } +librqbit-core = { path = "../librqbit_core", default-features = false, version = "4" } chrono = { version = "0.4.31", features = ["serde"] } tokio-util = "0.7.10" bytes = "1.7.1" diff --git a/crates/librqbit/Cargo.toml b/crates/librqbit/Cargo.toml index d2dc451..f112817 100644 --- a/crates/librqbit/Cargo.toml +++ b/crates/librqbit/Cargo.toml @@ -32,12 +32,12 @@ sqlx = { version = "=0.8.0", features = [ "postgres", ], optional = true } bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "3" } -tracker_comms = { path = "../tracker_comms", default-features = false, package = "librqbit-tracker-comms", version = "1.0.3" } +tracker_comms = { path = "../tracker_comms", default-features = false, package = "librqbit-tracker-comms", version = "2" } buffers = { path = "../buffers", package = "librqbit-buffers", version = "4.1" } librqbit-core = { path = "../librqbit_core", version = "4" } clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" } peer_binary_protocol = { path = "../peer_binary_protocol", default-features = false, package = "librqbit-peer-protocol", version = "4.1" } -sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "3.0.0" } +sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "4" } dht = { path = "../dht", package = "librqbit-dht", version = "5.1.0" } librqbit-upnp = { path = "../upnp", version = "0.1.1" } upnp-serve = { path = "../upnp-serve", version = "0.1.0", optional = true } diff --git a/crates/librqbit_core/Cargo.toml b/crates/librqbit_core/Cargo.toml index 9c9b197..f1c16fa 100644 --- a/crates/librqbit_core/Cargo.toml +++ b/crates/librqbit_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "librqbit-core" -version = "4.0.0" +version = "4.0.1" edition = "2021" description = "Important utilities used throughout librqbit useful for working with torrents." license = "Apache-2.0" @@ -9,6 +9,10 @@ repository = "https://github.com/ikatson/rqbit" readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = ["sha1-crypto-hash"] +sha1-crypto-hash = ["bencode/sha1-crypto-hash"] +sha1-ring = ["bencode/sha1-ring"] [dependencies] tracing = "0.1.40" @@ -20,7 +24,7 @@ uuid = { version = "1", features = ["v4"] } parking_lot = "0.12" serde = { version = "1", features = ["derive"] } buffers = { path = "../buffers", package = "librqbit-buffers", version = "4" } -bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "3" } +bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "3.0.1" } clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" } itertools = "0.12" directories = "5" diff --git a/crates/peer_binary_protocol/Cargo.toml b/crates/peer_binary_protocol/Cargo.toml index 370fae9..4c2ebc5 100644 --- a/crates/peer_binary_protocol/Cargo.toml +++ b/crates/peer_binary_protocol/Cargo.toml @@ -16,7 +16,7 @@ byteorder = "1" buffers = { path = "../buffers", package = "librqbit-buffers", version = "4.1" } bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "3" } clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" } -librqbit-core = { path = "../librqbit_core", version = "4" } +librqbit-core = { path = "../librqbit_core", default-features = false, version = "4" } bitvec = "1" anyhow = "1" bytes = "1.7.1" diff --git a/crates/tracker_comms/Cargo.toml b/crates/tracker_comms/Cargo.toml index cc0c99a..5140aa1 100644 --- a/crates/tracker_comms/Cargo.toml +++ b/crates/tracker_comms/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "librqbit-tracker-comms" -version = "1.0.3" +version = "2.0.0" edition = "2018" description = "Common interface around various sha1 implementations used in rqbit torrent client." license = "Apache-2.0" diff --git a/crates/upnp/Cargo.toml b/crates/upnp/Cargo.toml index 16d0929..a4359ee 100644 --- a/crates/upnp/Cargo.toml +++ b/crates/upnp/Cargo.toml @@ -20,8 +20,7 @@ serde-xml-rs = "0.6.0" tokio = { version = "1", features = ["macros"] } futures = "0.3" url = "2" -async-recursion = "1" -network-interface = { git = 'https://github.com/ikatson/network-interface', branch = "compile-on-freebsd" } +network-interface = { version = "2" } httparse = "1.9.4" bstr = "1.10.0"