From 15c078619c1787a819994554581ee9168e804266 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Mon, 26 Feb 2024 22:41:36 +0000 Subject: [PATCH] Compile times are even worse now --- Cargo.lock | 21 ++++++++++++++ Cargo.toml | 4 +-- crates/librqbit/Cargo.toml | 1 + crates/librqbit/src/lib.rs | 3 -- crates/librqbit/src/session.rs | 23 +++++++-------- crates/tracker_comms/Cargo.toml | 27 ++++++++++++++++++ .../test/udp-tracker-announce-response.bin | Bin 0 -> 1220 bytes crates/tracker_comms/src/lib.rs | 5 ++++ .../src/tracker_comms.rs | 0 .../src/tracker_comms_http.rs | 0 .../src/tracker_comms_udp.rs | 10 +++---- 11 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 crates/tracker_comms/Cargo.toml create mode 100644 crates/tracker_comms/resources/test/udp-tracker-announce-response.bin create mode 100644 crates/tracker_comms/src/lib.rs rename crates/{librqbit => tracker_comms}/src/tracker_comms.rs (100%) rename crates/{librqbit => tracker_comms}/src/tracker_comms_http.rs (100%) rename crates/{librqbit => tracker_comms}/src/tracker_comms_udp.rs (97%) diff --git a/Cargo.lock b/Cargo.lock index 08ff622..f967a0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1278,6 +1278,7 @@ dependencies = [ "librqbit-dht", "librqbit-peer-protocol", "librqbit-sha1-wrapper", + "librqbit-tracker-comms", "librqbit-upnp", "openssl", "parking_lot", @@ -1397,6 +1398,26 @@ dependencies = [ "sha1", ] +[[package]] +name = "librqbit-tracker-comms" +version = "1.0.0" +dependencies = [ + "anyhow", + "async-stream", + "byteorder", + "futures", + "librqbit-bencode", + "librqbit-buffers", + "librqbit-core", + "rand", + "reqwest", + "serde", + "tokio", + "tracing", + "url", + "urlencoding", +] + [[package]] name = "librqbit-upnp" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index a3a89a4..22f0267 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ "crates/peer_binary_protocol", "crates/dht", "crates/upnp" -] +, "crates/tracker_comms"] [profile.dev] panic = "abort" @@ -22,4 +22,4 @@ debug = true [profile.release-github] inherits = "release" -debug = false \ No newline at end of file +debug = false diff --git a/crates/librqbit/Cargo.toml b/crates/librqbit/Cargo.toml index b840cf8..e05ceb5 100644 --- a/crates/librqbit/Cargo.toml +++ b/crates/librqbit/Cargo.toml @@ -23,6 +23,7 @@ rust-tls = ["reqwest/rustls-tls"] [dependencies] bencode = {path = "../bencode", default-features=false, package="librqbit-bencode", version="2.2.1"} +tracker_comms = {path = "../tracker_comms", default-features=false, package="librqbit-tracker-comms", version="1.0.0"} buffers = {path = "../buffers", package="librqbit-buffers", version = "2.2.1"} librqbit-core = {path = "../librqbit_core", version = "3.5.0"} clone_to_owned = {path = "../clone_to_owned", package="librqbit-clone-to-owned", version = "2.2.1"} diff --git a/crates/librqbit/src/lib.rs b/crates/librqbit/src/lib.rs index 817c086..d16c427 100644 --- a/crates/librqbit/src/lib.rs +++ b/crates/librqbit/src/lib.rs @@ -36,9 +36,6 @@ mod session; mod spawn_utils; mod torrent_state; pub mod tracing_subscriber_config_utils; -pub mod tracker_comms; -pub mod tracker_comms_http; -pub mod tracker_comms_udp; mod type_aliases; pub use api::Api; diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index 529be59..2252332 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -9,6 +9,16 @@ use std::{ time::Duration, }; +use crate::{ + dht_utils::{read_metainfo_from_peer_receiver, ReadMetainfoResult}, + peer_connection::PeerConnectionOptions, + read_buf::ReadBuf, + spawn_utils::BlockingSpawner, + torrent_state::{ + ManagedTorrentBuilder, ManagedTorrentHandle, ManagedTorrentState, TorrentStateLive, + }, + type_aliases::PeerStream, +}; use anyhow::{bail, Context}; use bencode::{bencode_serialize_to_writer, BencodeDeserializer}; use buffers::{ByteBuf, ByteBufT, ByteString}; @@ -32,18 +42,7 @@ use tokio::net::{TcpListener, TcpStream}; use tokio_stream::StreamExt; use tokio_util::sync::{CancellationToken, DropGuard}; use tracing::{debug, error, error_span, info, trace, warn, Instrument}; - -use crate::{ - dht_utils::{read_metainfo_from_peer_receiver, ReadMetainfoResult}, - peer_connection::PeerConnectionOptions, - read_buf::ReadBuf, - spawn_utils::BlockingSpawner, - torrent_state::{ - ManagedTorrentBuilder, ManagedTorrentHandle, ManagedTorrentState, TorrentStateLive, - }, - tracker_comms::TrackerComms, - type_aliases::PeerStream, -}; +use tracker_comms::TrackerComms; pub const SUPPORTED_SCHEMES: [&str; 3] = ["http:", "https:", "magnet:"]; diff --git a/crates/tracker_comms/Cargo.toml b/crates/tracker_comms/Cargo.toml new file mode 100644 index 0000000..98329ec --- /dev/null +++ b/crates/tracker_comms/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "librqbit-tracker-comms" +version = "1.0.0" +edition = "2018" +description = "Common interface around various sha1 implementations used in rqbit torrent client." +license = "Apache-2.0" +documentation = "https://docs.rs/librqbit-tracker-comms" +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 + +[dependencies] +tokio = "1" +anyhow = "1" +futures = "0.3" +async-stream = "0.3.5" +buffers = {path = "../buffers", package="librqbit-buffers", version = "2.2.1"} +librqbit-core = {path = "../librqbit_core", version = "3.5.0"} +byteorder = "1.5" +serde = {version = "1", features=["derive"]} +urlencoding = "2" +rand = "0.8" +tracing = "0.1.40" +reqwest = {version="0.11.22", default-features=false, features = ["json"]} +bencode = {path = "../bencode", default-features=false, package="librqbit-bencode", version="2.2.1"} +url = "2" \ No newline at end of file diff --git a/crates/tracker_comms/resources/test/udp-tracker-announce-response.bin b/crates/tracker_comms/resources/test/udp-tracker-announce-response.bin new file mode 100644 index 0000000000000000000000000000000000000000..4b1bc3aa41c1c1041424a3e05d07afc867a90614 GIT binary patch literal 1220 zcmV;#1Uvfx0005yl-(2n00wjb0099201XW;06%FO;aa^eBT~JI)Uu;p4zg9SG!TmLd0%M0?s}SDDZaHjGh6NClg6@HZ7+t7PE(7s zImp#dp>-^V1*FIB4nUbD<4I1H*;A?*x;cd9UF^5|P_mz-SK64$b-86BNA9bSV41RCL7|N2cT zDOn_>T6i)~i{CGYc0P>sJ29&+@-r6)v?YueV6R>U14pb2Z5>!KQht(K` zDoOvmq6|_nh`a!)Ro=X^%={`wTC!QJ3QH)mLW3rMNU+pj`B9g!z?qz8d2Rekgz@ZO zns#P`j9(hlva)1dt7g77@?3n)h|^?Q7~{w?W>D>17goMct8tlXmQ8HcNvH)bioW9- z;U(5cCK}-aKV_$@4AtJ^cXX4&yOp;_6uiF`GWg8MS6#r2bJT6MxlTE?eAJSgN8|b(*-&=2UGxpR1};qInr~C{R$u7XGR}*}fQJqb>k62v`s$ zaK6?tXeBw3#VA$<|G$ywh6Rh_yoTP?+~q-IxYQuP$f`TM^oJwfDZC-+X#Z5KZ>;Ue z)ouLNSVQMu-NkhZL0?WV75ar=JHuYY5?>`pS}Y)68cM<7EngY1-GwJ!8RPm@2woII zH7fpF)`^;jc3Js=%Dc)~ljwt>`&Enq9i2s0bzMGL6I3VkZ(B%Di9K8O1l*2*165+*L zp}91T=Z5*Rn-O{7$*^>#+mf2Fb7Al4RIp}5)F)eQ{E(Q=VQr(>-;pR^8PE8FuU{D? zT-Bpq6Wq|J99%v-F-Y=UC62OH`d9fq(!wuPHU)Thl23j}PN*d=@(VISqAsm8rdKpB ziV-483oa@+lgQO2PFajCTLt7%>l)z&rH_z48(Y7EWxt46@p1RA?Zwn;u`&vaoRYDMU)KsYl)b literal 0 HcmV?d00001 diff --git a/crates/tracker_comms/src/lib.rs b/crates/tracker_comms/src/lib.rs new file mode 100644 index 0000000..74cc980 --- /dev/null +++ b/crates/tracker_comms/src/lib.rs @@ -0,0 +1,5 @@ +mod tracker_comms; +mod tracker_comms_http; +mod tracker_comms_udp; + +pub use tracker_comms::*; diff --git a/crates/librqbit/src/tracker_comms.rs b/crates/tracker_comms/src/tracker_comms.rs similarity index 100% rename from crates/librqbit/src/tracker_comms.rs rename to crates/tracker_comms/src/tracker_comms.rs diff --git a/crates/librqbit/src/tracker_comms_http.rs b/crates/tracker_comms/src/tracker_comms_http.rs similarity index 100% rename from crates/librqbit/src/tracker_comms_http.rs rename to crates/tracker_comms/src/tracker_comms_http.rs diff --git a/crates/librqbit/src/tracker_comms_udp.rs b/crates/tracker_comms/src/tracker_comms_udp.rs similarity index 97% rename from crates/librqbit/src/tracker_comms_udp.rs rename to crates/tracker_comms/src/tracker_comms_udp.rs index 1e72ae8..35af733 100644 --- a/crates/librqbit/src/tracker_comms_udp.rs +++ b/crates/tracker_comms/src/tracker_comms_udp.rs @@ -12,9 +12,9 @@ const ACTION_ANNOUNCE: u32 = 1; // const ACTION_ERROR: u32 = 3; pub const EVENT_NONE: u32 = 0; -pub const EVENT_COMPLETED: u32 = 1; -pub const EVENT_STARTED: u32 = 2; -pub const EVENT_STOPPED: u32 = 3; +// pub const EVENT_COMPLETED: u32 = 1; +// pub const EVENT_STARTED: u32 = 2; +// pub const EVENT_STOPPED: u32 = 3; pub type ConnectionId = u64; const CONNECTION_ID_MAGIC: ConnectionId = 0x41727101980; @@ -293,7 +293,7 @@ mod tests { Response::Connect(connection_id) => { dbg!(connection_id) } - other => panic!("unexpected response {other:?}"), + other => panic!("unexpected response {:?}", other), }; let hash = Id20::from_str("775459190aa65566591634203f8d9f17d341f969").unwrap(); @@ -335,7 +335,7 @@ mod tests { Response::Announce(r) => { dbg!(r); } - other => panic!("unexpected response {other:?}"), + other => panic!("unexpected response {:?}", other), } } }