From c4d7b497faefc091c21240353825b9a471a7ae7a Mon Sep 17 00:00:00 2001 From: rays Date: Sun, 22 Nov 2026 14:29:20 -0500 Subject: [PATCH] Torrents through qBittorrent instead of librqbit (#494) ipx ran a BitTorrent session of its own: it bound 6881, joined the DHT and seeded, and librqbit brought over a thousand lines of Cargo.lock with it, ringbuf's advisory (#281) and a second path to chrono (#493) among them. Tower already runs qBittorrent, so torrents go there through its Web API. ipx still fetches the .torrent itself, through the guarded client and under the 10 MB cap (#320, #330), and adds it with the enclosure's own folder as the save path (#318, #331), the files straight into it (NoSubfolder), the seed limits, and a tag ipx- to find it by, since a magnet has no hash until its metadata comes. A torrent already tagged when ipx starts again is taken up where qBittorrent has it (#410). It is polled to the end under the stall limit; a qBittorrent not answering counts as no progress rather than a failure. qBittorrent seeds to the limits; with none, ipx removes the torrent from it at the end, files kept. The session cookie is whatever qBittorrent sets with SID in its name: 5.x calls it QBT_SID_. torrents/info by POST with a tag was checked against Tower's 5.2.3. The ringbuf ignore leaves deny.toml; chrono's stays, for rss and atom_syndication alone. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RqkrVBuJRne2JAhFpaDV2U --- Cargo.lock | 1154 ++----------------------------------- Cargo.toml | 3 +- README.md | 6 +- crates/ipx/CHANGELOG.md | 1 + crates/ipx/Cargo.toml | 1 - crates/ipx/src/config.rs | 49 +- crates/ipx/src/ctx.rs | 8 +- crates/ipx/src/scan.rs | 22 +- crates/ipx/src/torrent.rs | 451 +++++++++------ deny.toml | 9 +- docker-compose.yml | 3 - docs/architecture.md | 4 +- docs/configuration.md | 22 +- 13 files changed, 364 insertions(+), 1369 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b11eeb1..82820ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,15 +124,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "arc-swap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b" -dependencies = [ - "rustversion", -] - [[package]] name = "argon2" version = "0.6.0" @@ -151,15 +142,6 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" -[[package]] -name = "assert_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e2651f366b7ee3f97729fded1441539b49d5f39eeb05b842689e11e84501b2" -dependencies = [ - "const_panic", -] - [[package]] name = "async-compression" version = "0.4.52" @@ -214,15 +196,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atoi" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a8bbe9949e43a1edaa043038c68703b04774156afdfb62ba2cef5bf93d67be" -dependencies = [ - "num-traits", -] - [[package]] name = "atom_syndication" version = "0.12.10" @@ -323,42 +296,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "axum-extra" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be44683b41ccb9ab2d23a5230015c9c3c55be97a25e4428366de8873103f7970" -dependencies = [ - "axum", - "axum-core", - "bytes", - "form_urlencoded", - "futures-core", - "futures-util", - "http", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "serde_core", - "serde_html_form", - "serde_path_to_error", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "backon" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef" -dependencies = [ - "fastrand", - "gloo-timers", - "tokio", -] - [[package]] name = "base64" version = "0.22.1" @@ -397,12 +334,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.1" @@ -412,18 +343,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "bitvec" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "blake2" version = "0.11.0" @@ -439,7 +358,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.9", + "generic-array", ] [[package]] @@ -496,26 +415,6 @@ dependencies = [ "alloc-stdlib", ] -[[package]] -name = "bs58" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "bstr" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" -dependencies = [ - "memchr", - "regex-automata", - "serde_core", -] - [[package]] name = "bumpalo" version = "3.20.3" @@ -584,17 +483,6 @@ dependencies = [ "rand_core 0.10.1", ] -[[package]] -name = "chardetng" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13de944a44b5064ee5d3a5ceccc49a41bfec50f2580e66f82e87703acdb88b53" -dependencies = [ - "cfg-if", - "encoding_rs", - "memchr", -] - [[package]] name = "chrono" version = "0.4.45" @@ -602,10 +490,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", - "js-sys", "num-traits", "serde", - "wasm-bindgen", "windows-link", ] @@ -714,15 +600,6 @@ version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" -[[package]] -name = "const_panic" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9603f79528ece8163c496f8932121cb36cfe46259e9c907bb3d8205139d7caa3" -dependencies = [ - "typewit", -] - [[package]] name = "convert_case" version = "0.10.0" @@ -827,7 +704,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ - "bitflags 2.13.1", + "bitflags", "crossterm_winapi", "derive_more", "document-features", @@ -854,7 +731,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.9", + "generic-array", "typenum", ] @@ -956,58 +833,6 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "dashmap" -version = "6.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", - "serde", -] - -[[package]] -name = "data-encoding" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" - -[[package]] -name = "defmt" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1" -dependencies = [ - "bitflags 1.3.2", - "defmt-macros", -] - -[[package]] -name = "defmt-macros" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8" -dependencies = [ - "defmt-parser", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "defmt-parser" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" -dependencies = [ - "thiserror 2.0.20", -] - [[package]] name = "deranged" version = "0.5.8" @@ -1112,27 +937,6 @@ dependencies = [ "chrono", ] -[[package]] -name = "directories" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.61.2", -] - [[package]] name = "displaydoc" version = "0.2.7" @@ -1153,18 +957,6 @@ dependencies = [ "litrs", ] -[[package]] -name = "dontfrag" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117949f5a8b25ba471b4dfea927a07a2f8730c585532a2eb4294e18f5155397" -dependencies = [ - "cfg-if", - "libc", - "tokio", - "windows-sys 0.52.0", -] - [[package]] name = "dotenvy" version = "0.15.7" @@ -1192,12 +984,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - [[package]] name = "either" version = "1.18.0" @@ -1331,27 +1117,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - [[package]] name = "futures-channel" version = "0.3.34" @@ -1419,19 +1184,12 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" -[[package]] -name = "futures-timer" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af43fadb8a98512d547e37b4e92e0ced13e205c061b87b4623eff01d918d6968" - [[package]] name = "futures-util" version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ - "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -1442,15 +1200,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.9" @@ -1481,11 +1230,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", - "js-sys", "libc", "r-efi 5.3.0", "wasip2", - "wasm-bindgen", ] [[package]] @@ -1502,41 +1249,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gloo-timers" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "governor" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9efcab3c1958580ff1f25a2a41be1668f7603d849bb63af523b208a3cc1223b8" -dependencies = [ - "cfg-if", - "dashmap", - "futures-sink", - "futures-timer", - "futures-util", - "getrandom 0.3.4", - "hashbrown 0.16.1", - "nonzero_ext", - "parking_lot", - "portable-atomic", - "quanta", - "rand 0.9.5", - "smallvec", - "spinning_top", - "web-time", -] - [[package]] name = "h2" version = "0.4.20" @@ -1549,7 +1261,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.14.2", + "indexmap", "slab", "tokio", "tokio-util", @@ -1575,24 +1287,12 @@ version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0c43e7c3212bd992c11b6b9796563388170950521ae8487f5cdf6f6e792f1c8" dependencies = [ - "bitflags 2.13.1", + "bitflags", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hashbrown" version = "0.15.5" @@ -1936,17 +1636,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.14.2" @@ -1955,8 +1644,6 @@ checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown 0.17.1", - "serde", - "serde_core", ] [[package]] @@ -1981,15 +1668,6 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "intervaltree" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "270bc34e57047cab801a8c871c124d9dc7132f6473c6401f645524f4e6edd111" -dependencies = [ - "smallvec", -] - [[package]] name = "ipnet" version = "2.12.2" @@ -2013,7 +1691,6 @@ dependencies = [ "ipx-play", "ipx-wire", "jsonwebtoken", - "librqbit", "opentelemetry", "opentelemetry_sdk", "opml", @@ -2159,15 +1836,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.18" @@ -2180,59 +1848,6 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47f142fe24a9c9944451e8349de0a56af5f3e7226dc46f3ed4d4ecc0b85af75e" -[[package]] -name = "jiff" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" -dependencies = [ - "defmt", - "jiff-core", - "jiff-static", - "jiff-tzdb-platform", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09" -dependencies = [ - "defmt", -] - -[[package]] -name = "jiff-static" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" -dependencies = [ - "jiff-core", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "jiff-tzdb" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" - -[[package]] -name = "jiff-tzdb-platform" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" -dependencies = [ - "jiff-tzdb", -] - [[package]] name = "jni" version = "0.22.4" @@ -2336,17 +1951,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "leaky-bucket" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a396bb213c2d09ed6c5495fd082c991b6ab39c9daf4fff59e6727f85c73e4c5" -dependencies = [ - "parking_lot", - "pin-project-lite", - "tokio", -] - [[package]] name = "libc" version = "0.2.189" @@ -2377,311 +1981,6 @@ dependencies = [ "libc", ] -[[package]] -name = "librqbit" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4349c0f35ede576a87cc2881dc6eb286ff7a1c8fc4d1f7fef95b5c5a530a7174" -dependencies = [ - "anyhow", - "arc-swap", - "async-compression", - "async-stream", - "async-trait", - "axum-extra", - "backon", - "base64 0.23.1", - "bitvec", - "byteorder", - "bytes", - "dashmap", - "futures", - "governor", - "hex", - "http", - "intervaltree", - "itertools 0.15.0", - "librqbit-bencode", - "librqbit-buffers", - "librqbit-clone-to-owned", - "librqbit-core", - "librqbit-dht", - "librqbit-dualstack-sockets", - "librqbit-lsd", - "librqbit-peer-protocol", - "librqbit-sha1-wrapper", - "librqbit-tracker-comms", - "librqbit-upnp", - "librqbit-utp", - "memmap2", - "mime_guess", - "nix 0.30.1", - "parking_lot", - "rand 0.10.2", - "regex", - "reqwest", - "rlimit", - "serde", - "serde_derive", - "serde_json", - "serde_urlencoded", - "serde_with", - "size_format", - "socket2", - "thiserror 2.0.20", - "tokio", - "tokio-socks", - "tokio-stream", - "tokio-util", - "tracing", - "url", - "urlencoding", - "uuid", - "walkdir", - "windows", -] - -[[package]] -name = "librqbit-bencode" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be6410a7434e6c2b148931b6d109b57939cfed04cefa86451197c5f5198edf91" -dependencies = [ - "anyhow", - "arrayvec", - "atoi 3.1.0", - "bytes", - "librqbit-buffers", - "librqbit-clone-to-owned", - "serde", - "serde_derive", - "thiserror 2.0.20", -] - -[[package]] -name = "librqbit-buffers" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00e4b6780a30d3c204f778ad64b3c917b842f5c54df38455c361761e7d12ce2" -dependencies = [ - "bytes", - "librqbit-clone-to-owned", - "serde", - "serde_derive", -] - -[[package]] -name = "librqbit-clone-to-owned" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929ff2b22b1596c3f3689a79c0b84ee8a01a650a2dd0b6eb7322d6a3b9be0e0e" -dependencies = [ - "bytes", -] - -[[package]] -name = "librqbit-core" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c33158d5c47ac68771dcf7cca13eb2fa2ee2980efbb6bb5645273e2f08c69b" -dependencies = [ - "anyhow", - "bytes", - "chardetng", - "data-encoding", - "directories", - "encoding_rs", - "hex", - "itertools 0.15.0", - "librqbit-bencode", - "librqbit-buffers", - "librqbit-clone-to-owned", - "librqbit-sha1-wrapper", - "memchr", - "parking_lot", - "rand 0.10.2", - "serde", - "serde_derive", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tracing", - "url", -] - -[[package]] -name = "librqbit-dht" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "575f94f543c16de3088f8aa84175203d65437c8886dc24d383941f408dc26488" -dependencies = [ - "anyhow", - "backon", - "bytes", - "chrono", - "dashmap", - "futures", - "indexmap 2.14.2", - "leaky-bucket", - "librqbit-bencode", - "librqbit-buffers", - "librqbit-clone-to-owned", - "librqbit-core", - "librqbit-dualstack-sockets", - "parking_lot", - "rand 0.10.2", - "serde", - "serde_derive", - "serde_json", - "thiserror 2.0.20", - "tokio", - "tokio-stream", - "tokio-util", - "tracing", -] - -[[package]] -name = "librqbit-dualstack-sockets" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7189f1ff66ca75055137a38b062ba7df9691d071b7172e5090997c62eb4b4de" -dependencies = [ - "axum", - "backon", - "futures", - "libc", - "network-interface", - "socket2", - "thiserror 2.0.20", - "tokio", - "tracing", -] - -[[package]] -name = "librqbit-lsd" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1d2699a46a9dc83693c5fbbf288a17b77a24b9924815a69bfc97853a47af42" -dependencies = [ - "anyhow", - "atoi 3.1.0", - "bstr", - "futures", - "httparse", - "librqbit-core", - "librqbit-dualstack-sockets", - "parking_lot", - "rand 0.10.2", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "librqbit-peer-protocol" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43e4b11349070274a1f77fb432d5e764ed38b310e7cdae8d2c37e0568ceb950e" -dependencies = [ - "anyhow", - "bitvec", - "byteorder", - "bytes", - "itertools 0.15.0", - "librqbit-bencode", - "librqbit-buffers", - "librqbit-clone-to-owned", - "librqbit-core", - "serde", - "serde_derive", - "thiserror 2.0.20", - "tracing", -] - -[[package]] -name = "librqbit-sha1-wrapper" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf23eeda5a8999809c0be52e36b711d062f1d52e2f3cae42d71b7b012a466c7" -dependencies = [ - "assert_cfg", - "aws-lc-rs", -] - -[[package]] -name = "librqbit-tracker-comms" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b561cb29abec85eee031c998f9e0c987f82d3e193b087f4d2bdc8f00d825796c" -dependencies = [ - "anyhow", - "async-stream", - "backon", - "byteorder", - "futures", - "itertools 0.15.0", - "librqbit-bencode", - "librqbit-buffers", - "librqbit-core", - "librqbit-dualstack-sockets", - "parking_lot", - "rand 0.10.2", - "reqwest", - "serde", - "serde_derive", - "serde_with", - "tokio", - "tokio-util", - "tracing", - "url", - "urlencoding", -] - -[[package]] -name = "librqbit-upnp" -version = "9.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b950b4dfe2102d3047f3fac70763c494b63a50f04a00d3dd36102d740e9bf33" -dependencies = [ - "anyhow", - "bstr", - "futures", - "httparse", - "librqbit-dualstack-sockets", - "network-interface", - "quick-xml 0.41.0", - "reqwest", - "serde", - "serde_derive", - "socket2", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "librqbit-utp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3bfdc73944bc76cab24d5690a98816770040a654c449edf5ff2b9ba22626aa" -dependencies = [ - "bitvec", - "dontfrag", - "lazy_static", - "libc", - "librqbit-dualstack-sockets", - "metrics", - "parking_lot", - "rand 0.9.5", - "ringbuf", - "rustc-hash", - "socket2", - "thiserror 2.0.20", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "libsqlite3-sys" version = "0.40.0" @@ -2699,7 +1998,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e752191d037c44ad111a8caa762921926658402f01cc1253f7bef2020ece4f5e" dependencies = [ - "bitflags 2.13.1", + "bitflags", ] [[package]] @@ -2822,7 +2121,7 @@ version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" dependencies = [ - "nix 0.29.0", + "nix", "serde", "winapi", ] @@ -2875,15 +2174,6 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" -[[package]] -name = "memmap2" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" -dependencies = [ - "libc", -] - [[package]] name = "memoffset" version = "0.9.1" @@ -2893,16 +2183,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "metrics" -version = "0.24.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89550ee9f79e88fef3119de263694973a8adb26c21d75322164fb8c493039fe2" -dependencies = [ - "portable-atomic", - "rapidhash", -] - [[package]] name = "miette" version = "7.6.0" @@ -3005,18 +2285,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" -[[package]] -name = "network-interface" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ddcb8865ad3d9950f22f42ffa0ef0aecbfbf191867b3122413602b0a360b2a6" -dependencies = [ - "cc", - "libc", - "thiserror 2.0.20", - "winapi", -] - [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -3029,31 +2297,13 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.13.1", + "bitflags", "cfg-if", "cfg_aliases", "libc", "memoffset", ] -[[package]] -name = "nix" -version = "0.30.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" -dependencies = [ - "bitflags 2.13.1", - "cfg-if", - "cfg_aliases", - "libc", -] - -[[package]] -name = "nonzero_ext" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -3063,19 +2313,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "num" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" -dependencies = [ - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.8" @@ -3086,16 +2323,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-conv" version = "0.2.2" @@ -3111,27 +2338,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -3156,7 +2362,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.13.1", + "bitflags", ] [[package]] @@ -3268,12 +2474,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "ordered-float" version = "2.10.1" @@ -3378,7 +2578,7 @@ checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" dependencies = [ "fixedbitset", "hashbrown 0.15.5", - "indexmap 2.14.2", + "indexmap", ] [[package]] @@ -3468,15 +2668,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" -[[package]] -name = "portable-atomic-util" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" -dependencies = [ - "portable-atomic", -] - [[package]] name = "potential_utf" version = "0.1.6" @@ -3552,7 +2743,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" dependencies = [ "heck 0.4.1", - "itertools 0.14.0", + "itertools", "log", "multimap", "petgraph", @@ -3571,7 +2762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools", "proc-macro2", "quote", "syn 2.0.119", @@ -3634,7 +2825,7 @@ version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db2be46835f013dd3f4fa7f5f7402c537787b54ebb6fe2b94bbdd7e2669bb7b" dependencies = [ - "bitflags 2.13.1", + "bitflags", "memchr", "pulldown-cmark-escape", "unicase", @@ -3646,21 +2837,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" -[[package]] -name = "quanta" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" -dependencies = [ - "crossbeam-utils", - "libc", - "once_cell", - "raw-cpuid", - "wasi", - "web-sys", - "winapi", -] - [[package]] name = "quick-xml" version = "0.41.0" @@ -3669,7 +2845,6 @@ checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" dependencies = [ "encoding_rs", "memchr", - "serde", ] [[package]] @@ -3759,12 +2934,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.8" @@ -3850,15 +3019,6 @@ dependencies = [ "rand_core 0.10.1", ] -[[package]] -name = "rapidhash" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" -dependencies = [ - "rustversion", -] - [[package]] name = "ratatui" version = "0.30.2" @@ -3878,10 +3038,10 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbb175c433c8e28a809d1f5773a2ae96e68c0ce40db865cbab1020bf33ae479c" dependencies = [ - "bitflags 2.13.1", + "bitflags", "compact_str", "hashbrown 0.17.1", - "itertools 0.14.0", + "itertools", "kasuari", "lru", "palette", @@ -3911,11 +3071,11 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66e3d19bcc9130ca376277d93b60767ff121ace3be06f5f95f81dd68956407d1" dependencies = [ - "bitflags 2.13.1", + "bitflags", "hashbrown 0.17.1", "indoc", "instability", - "itertools 0.14.0", + "itertools", "line-clipping", "ratatui-core", "serde", @@ -3925,53 +3085,13 @@ dependencies = [ "unicode-width 0.2.3", ] -[[package]] -name = "raw-cpuid" -version = "11.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" -dependencies = [ - "bitflags 2.13.1", -] - [[package]] name = "redox_syscall" version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.1", -] - -[[package]] -name = "redox_users" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" -dependencies = [ - "getrandom 0.2.17", - "libredox", - "thiserror 2.0.20", -] - -[[package]] -name = "ref-cast" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", + "bitflags", ] [[package]] @@ -4025,6 +3145,7 @@ dependencies = [ "js-sys", "log", "mime", + "mime_guess", "percent-encoding", "pin-project-lite", "quinn", @@ -4033,6 +3154,7 @@ dependencies = [ "rustls-platform-verifier", "serde", "serde_json", + "serde_urlencoded", "sync_wrapper", "tokio", "tokio-rustls", @@ -4061,26 +3183,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ringbuf" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe47b720588c8702e34b5979cb3271a8b1842c7cb6f57408efa70c779363488c" -dependencies = [ - "crossbeam-utils", - "portable-atomic", - "portable-atomic-util", -] - -[[package]] -name = "rlimit" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f35ee2729c56bb610f6dba436bf78135f728b7373bdffae2ec815b2d3eb98cc3" -dependencies = [ - "libc", -] - [[package]] name = "rss" version = "2.1.1" @@ -4130,7 +3232,7 @@ version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -4243,30 +3345,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "schemars" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687274d293b6cdc6e73e0fee520bf2049650090d7164f87672d212a3c530cf4a" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -4298,7 +3376,7 @@ dependencies = [ "derive-where", "derive_more", "futures-util", - "itertools 0.14.0", + "itertools", "log", "mac_address", "pgvector", @@ -4327,7 +3405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e24c82fc1e76c014dffe5ecdac8f654da73161d703a16ea13414581e07459c83" dependencies = [ "heck 0.5.0", - "itertools 0.14.0", + "itertools", "pluralizer", "proc-macro2", "quote", @@ -4402,7 +3480,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -4465,19 +3543,6 @@ dependencies = [ "syn 3.0.5", ] -[[package]] -name = "serde_html_form" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2f2d7ff8a2140333718bb329f5c40fc5f0865b84c426183ce14c97d2ab8154f" -dependencies = [ - "form_urlencoded", - "indexmap 2.14.2", - "itoa", - "ryu", - "serde_core", -] - [[package]] name = "serde_json" version = "1.0.151" @@ -4523,39 +3588,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "3.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "935177bb8c0cd8ca1a4e6d1a2ac8988bea69cab4f9d3a31311e012ad27868ea4" -dependencies = [ - "base64 0.23.1", - "bs58", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.14.2", - "jiff", - "schemars 0.9.0", - "schemars 1.2.2", - "serde_core", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d607aa01a3cb0ad757d6fd216136910db3c97b102fe686585689615a02dbcdc" -dependencies = [ - "darling 0.24.1", - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "sha1" version = "0.11.0" @@ -4672,16 +3704,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" -[[package]] -name = "size_format" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed5f6ab2122c6dec69dca18c72fa4590a27e581ad20d44960fe74c032a0b23b" -dependencies = [ - "generic-array 0.12.4", - "num", -] - [[package]] name = "slab" version = "0.4.12" @@ -4716,15 +3738,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "spinning_top" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" -dependencies = [ - "lock_api", -] - [[package]] name = "sqlx" version = "0.9.1" @@ -4757,7 +3770,7 @@ dependencies = [ "futures-util", "hashbrown 0.16.1", "hashlink", - "indexmap 2.14.2", + "indexmap", "log", "memchr", "percent-encoding", @@ -4818,7 +3831,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19eeb93b96eb10a3a59dfb436f3daf87d2fc41168ed9e9dc153ec8257dd6a761" dependencies = [ - "bitflags 2.13.1", + "bitflags", "byteorder", "bytes", "crc", @@ -4827,7 +3840,7 @@ dependencies = [ "either", "futures-core", "futures-util", - "generic-array 0.14.9", + "generic-array", "log", "percent-encoding", "serde", @@ -4844,9 +3857,9 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0e9e02f764a1fe640eeefc8eb33eeddd274204654ec9f2db8ff851a1dee2364" dependencies = [ - "atoi 2.0.0", + "atoi", "base64 0.22.1", - "bitflags 2.13.1", + "bitflags", "byteorder", "crc", "dotenvy", @@ -4879,7 +3892,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88b6b78a34ddcb1db4046d462db8f79cee811019d7297b99fca8fac5de26672e" dependencies = [ - "atoi 2.0.0", + "atoi", "flume", "form_urlencoded", "futures-channel", @@ -5036,7 +4049,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -5051,12 +4064,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tempfile" version = "3.27.0" @@ -5221,18 +4228,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-socks" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e2948f60dbe26b35f2c7fb74ac2854c1fddded0fe9d7548fcc674a246f7615" -dependencies = [ - "either", - "futures-util", - "thiserror 1.0.69", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.19" @@ -5242,7 +4237,6 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", - "tokio-util", ] [[package]] @@ -5265,7 +4259,7 @@ version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785" dependencies = [ - "indexmap 2.14.2", + "indexmap", "serde_core", "serde_spanned", "toml_datetime", @@ -5289,7 +4283,7 @@ version = "0.25.15+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614" dependencies = [ - "indexmap 2.14.2", + "indexmap", "toml_datetime", "toml_parser", "winnow", @@ -5333,7 +4327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ "async-compression", - "bitflags 2.13.1", + "bitflags", "bytes", "futures-core", "futures-util", @@ -5356,7 +4350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" dependencies = [ "async-compression", - "bitflags 2.13.1", + "bitflags", "bytes", "futures-core", "futures-util", @@ -5488,12 +4482,6 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" -[[package]] -name = "typewit" -version = "1.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214ca0b2191785cbc06209b9ca1861e048e39b5ba33574b3cedd58363d5bb5f6" - [[package]] name = "unicase" version = "2.9.0" @@ -5539,7 +4527,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5" dependencies = [ - "itertools 0.14.0", + "itertools", "unicode-segmentation", "unicode-width 0.2.3", ] @@ -5584,15 +4572,8 @@ dependencies = [ "idna", "percent-encoding", "serde", - "serde_derive", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf8_iter" version = "1.0.4" @@ -5611,10 +4592,7 @@ version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5772d71c9be8a8a6ac2117d949c5b224c1b72241bb611d9a3012edcf8af7812" dependencies = [ - "getrandom 0.4.3", - "js-sys", "serde_core", - "wasm-bindgen", ] [[package]] @@ -5831,27 +4809,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" -dependencies = [ - "windows-collections", - "windows-core", - "windows-future", - "windows-numerics", -] - -[[package]] -name = "windows-collections" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" -dependencies = [ - "windows-core", -] - [[package]] name = "windows-core" version = "0.62.2" @@ -5865,17 +4822,6 @@ dependencies = [ "windows-strings", ] -[[package]] -name = "windows-future" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" -dependencies = [ - "windows-core", - "windows-link", - "windows-threading", -] - [[package]] name = "windows-implement" version = "0.60.2" @@ -5904,16 +4850,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-numerics" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" -dependencies = [ - "windows-core", - "windows-link", -] - [[package]] name = "windows-registry" version = "0.6.1" @@ -5977,15 +4913,6 @@ dependencies = [ "windows_x86_64_msvc", ] -[[package]] -name = "windows-threading" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" -dependencies = [ - "windows-link", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -6055,15 +4982,6 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "xmlparser" version = "0.13.6" diff --git a/Cargo.toml b/Cargo.toml index 4f28e1c..d78330b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ chrono = { version = "0.4.45", default-features = false, features = ["std", "clo clap = { version = "4.6.6", features = ["derive"] } futures-util = { version = "0.3.34", default-features = false, features = ["std"] } jsonwebtoken = { version = "11.1.0", default-features = false, features = ["aws_lc_rs"] } -librqbit = { version = "9.0.1", default-features = false, features = ["rust-tls", "http-api-client"] } opentelemetry = { version = "0.33", default-features = false, features = ["trace"] } opentelemetry-otlp = { version = "0.33", default-features = false, features = ["trace", "http-proto", "reqwest-blocking-client", "gzip-http"] } opentelemetry_sdk = { version = "0.33", default-features = false, features = ["trace"] } @@ -42,7 +41,7 @@ http = "1.5.0" hyper-util = { version = "0.1.20", features = ["client-legacy"] } percent-encoding = "2.3.2" quick-xml = { version = "0.42.0", features = ["escape-html"] } -reqwest = { version = "0.13.5", default-features = false, features = ["rustls", "http2", "gzip", "brotli", "zstd", "stream", "json", "charset", "system-proxy"] } +reqwest = { version = "0.13.5", default-features = false, features = ["rustls", "http2", "gzip", "brotli", "zstd", "stream", "json", "form", "multipart", "charset", "system-proxy"] } rss = "2.1.1" sea-orm = { version = "2.0.3", default-features = false, features = ["sqlx-sqlite", "sqlx-postgres", "runtime-tokio-rustls", "macros", "with-json", "sqlite-use-returning-for-3_35"] } serde = { version = "1.0.229", features = ["derive"] } diff --git a/README.md b/README.md index 85d3cec..d3a6299 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ behind iPodderX (2004-2008, Ray Slakinski & August Trometer). - **Scanning.** Feeds are checked on a schedule, globally or per feed, and a feed's own TTL is honoured. Keyword, explicit-content and media-type filters decide what is downloaded, with a limit on how many of a feed's newest episodes are downloaded. -- **Downloads.** Files come over HTTP or BitTorrent and are filed into a folder per feed. +- **Downloads.** Files come over HTTP, or BitTorrent through qBittorrent, and are filed into a folder per feed. Retention deletes the oldest files to stay under a disk quota or an age limit, and never touches an item someone has pinned. - **OPML.** You can import and export your own subscriptions. You can also subscribe to an OPML @@ -37,8 +37,8 @@ docker compose up -d `docker-compose.yml` is a sample: ipx, with its database in SQLite and its three volumes (`/config`, `/data` and `/downloads`) in folders beside the file, and ipx-web, the page, served by -Caddy in front of it. Change them to suit. The UI is on port 8099. BitTorrent uses 6881 -over TCP and UDP. Files are written as `PUID`/`PGID`, 99:100 by default. +Caddy in front of it. Change them to suit. The UI is on port 8099. Torrents need a qBittorrent +of your own, set in `[torrent]` (docs/configuration.md). Files are written as `PUID`/`PGID`, 99:100 by default. From source: diff --git a/crates/ipx/CHANGELOG.md b/crates/ipx/CHANGELOG.md index a2c532a..8b653aa 100644 --- a/crates/ipx/CHANGELOG.md +++ b/crates/ipx/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Torrents go to qBittorrent through its Web API, set in `[torrent]` (`qbittorrent_url`, `username`, `password`, `save_path`), which downloads and seeds them; ipx no longer runs a BitTorrent client of its own or listens on 6881, and `port_range` is gone. Without a qBittorrent set, torrents are held back as when they are turned off (#494). - The server's command is `ipxd`, not `ipx`: `ipxd daemon`, `ipxd status`, `ipxd user add` and the rest, in the container as `docker exec iPX ipxd ...`. `ipx` is now the reader in a terminal (#437). - The log no longer has a line for every request that went well, over half its size: `/metrics` counts each request and its time by route and status as `ipx_http_request_duration_seconds`, a request that failed keeps its warning, and the admin page's log view still shows them all (#364). diff --git a/crates/ipx/Cargo.toml b/crates/ipx/Cargo.toml index a4e232f..1f18aa4 100644 --- a/crates/ipx/Cargo.toml +++ b/crates/ipx/Cargo.toml @@ -27,7 +27,6 @@ chrono.workspace = true clap.workspace = true futures-util.workspace = true jsonwebtoken.workspace = true -librqbit.workspace = true opentelemetry.workspace = true opentelemetry_sdk.workspace = true opml.workspace = true diff --git a/crates/ipx/src/config.rs b/crates/ipx/src/config.rs index 6222a04..7e181b6 100644 --- a/crates/ipx/src/config.rs +++ b/crates/ipx/src/config.rs @@ -112,10 +112,17 @@ impl Push { #[serde(default)] pub struct Torrent { pub enabled: bool, - /// Stop seeding at this ratio, or after seed_time_mins, whichever comes first. + /// qBittorrent's Web UI, which does the downloading and seeding (#494), e.g. + /// "http://qbittorrent:8080". Empty: torrents are held back, as when not enabled. + pub qbittorrent_url: String, + /// Empty when qBittorrent lets ipx's address in without signing in. + pub username: String, + pub password: String, + /// Where qBittorrent sees `download_dir`, when its mount is not at the same path as ipx's. + pub save_path: String, + /// qBittorrent stops seeding at this ratio, or after seed_time_mins, whichever comes first. pub seed_ratio: f64, pub seed_time_mins: u64, - pub port_range: String, /// Drop a torrent that has made no progress for this long. pub stall_mins: u64, } @@ -265,7 +272,16 @@ impl Default for General { impl Default for Torrent { fn default() -> Self { - Self { enabled: true, seed_ratio: 1.0, seed_time_mins: 60, port_range: "6881-6889".into(), stall_mins: 30 } + Self { + enabled: true, + qbittorrent_url: String::new(), + username: String::new(), + password: String::new(), + save_path: String::new(), + seed_ratio: 1.0, + seed_time_mins: 60, + stall_mins: 30, + } } } @@ -313,16 +329,9 @@ pub fn parse_interval(s: &str) -> Option { } impl Torrent { - /// Inclusive listen port range. Falls back to the BitTorrent default on garbage input. - pub fn ports(&self) -> (u16, u16) { - let parse = || -> Option<(u16, u16)> { - let (lo, hi) = self.port_range.split_once('-')?; - Some((lo.trim().parse().ok()?, hi.trim().parse().ok()?)) - }; - match parse() { - Some((lo, hi)) if lo <= hi => (lo, hi), - _ => (6881, 6889), - } + /// Torrents are fetched only with somewhere to send them. + pub fn on(&self) -> bool { + self.enabled && !self.qbittorrent_url.trim().is_empty() } } @@ -714,15 +723,13 @@ mod tests { } #[test] - fn port_range_falls_back_when_malformed() { + fn torrents_are_on_only_with_a_qbittorrent_to_send_them_to() { let mut t = Torrent::default(); - assert_eq!(t.ports(), (6881, 6889)); - t.port_range = "51413-51420".into(); - assert_eq!(t.ports(), (51413, 51420)); - t.port_range = "nonsense".into(); - assert_eq!(t.ports(), (6881, 6889)); - t.port_range = "900-100".into(); - assert_eq!(t.ports(), (6881, 6889), "reversed range is not a range"); + assert!(!t.on(), "enabled, but nowhere to send them"); + t.qbittorrent_url = "http://qbittorrent:8080".into(); + assert!(t.on()); + t.enabled = false; + assert!(!t.on()); } #[test] diff --git a/crates/ipx/src/ctx.rs b/crates/ipx/src/ctx.rs index 8fee01e..d495004 100644 --- a/crates/ipx/src/ctx.rs +++ b/crates/ipx/src/ctx.rs @@ -29,15 +29,14 @@ pub struct Ctx { /// that moved for good from one sent elsewhere for now. pub feed_client: reqwest::Client, pub out: Emitter, - /// Started on first use: a BitTorrent session binds ports and starts a DHT, which is - /// rude to do for a config that has never seen a torrent. + /// qBittorrent's client and session cookie, made on first use (#494). pub torrents: OnceCell, /// Caps how many torrents run at once when they are detached. pub torrent_slots: Arc, /// Needed because a subscribed OPML rewrites the feed list as it syncs. pub config_path: PathBuf, /// Run torrents off the command worker. A torrent takes minutes to fetch metadata and - /// then seeds for up to an hour, and the worker is sequential -- inline, one torrent + /// more to download, and the worker is sequential -- inline, one torrent /// stops every feed scan, every HTTP download and every status command behind it. /// A one-shot CLI run keeps them inline, or the process would exit mid-download. pub detach_torrents: bool, @@ -209,8 +208,7 @@ impl Ctx { } pub(crate) async fn torrents(&self) -> Result<&torrent::Torrents> { - let cfg = self.cfg(); - self.torrents.get_or_try_init(|| torrent::Torrents::new(&cfg)).await + self.torrents.get_or_try_init(|| async { torrent::Torrents::new() }).await } } diff --git a/crates/ipx/src/scan.rs b/crates/ipx/src/scan.rs index 73eb244..3709e51 100644 --- a/crates/ipx/src/scan.rs +++ b/crates/ipx/src/scan.rs @@ -3,7 +3,7 @@ use crate::catalogue::Sub; use crate::ctx::Ctx; use crate::ipc::Event; -use crate::{catalogue, cli, config, db, download, feed, lists, metrics, signals, torrent}; +use crate::{catalogue, cli, config, db, download, feed, lists, metrics, signals}; use anyhow::Result; use std::collections::HashSet; use std::path::Path; @@ -533,7 +533,7 @@ pub(crate) async fn scan_one( for item in ctx.db.pending(id, budget).await? { if download::looks_like_torrent(&item.url, item.mime.as_deref()) { - if !ctx.cfg().torrent.enabled { + if !ctx.cfg().torrent.on() { ctx.db.mark_enclosure(&item.url, "skipped", Some("torrents disabled")).await?; ctx.out.emit(Event::TorrentDeferred { feed: id.to_string(), url: item.url.clone() }); scan.torrents += 1; @@ -750,7 +750,7 @@ pub(crate) async fn fetch_one( // The MIME lied. Hand the URL to the torrent session instead of filing a .torrent // as if it were an episode. let _ = tokio::fs::remove_file(&got.tmp).await; - if !ctx.cfg().torrent.enabled { + if !ctx.cfg().torrent.on() { ctx.db.mark_enclosure(url, "skipped", Some("torrents disabled")).await?; anyhow::bail!("body is a torrent and torrents are disabled"); } @@ -831,13 +831,13 @@ pub(crate) async fn download_one(ctx: &Arc, id: i64) -> Result<()> { ctx.out.emit(Event::FeedStart { feed: enc.feed_id.clone() }); let is_torrent = download::looks_like_torrent(&enc.url, enc.mime.as_deref()); - if is_torrent && cfg.torrent.enabled && ctx.detach_torrents { + if is_torrent && cfg.torrent.on() && ctx.detach_torrents { ctx.db.mark_enclosure(&enc.url, "downloading", None).await?; spawn_torrent(ctx, enc.feed_id.clone(), enc.id, enc.url.clone(), dest_dir); return Ok(()); } let result = if is_torrent { - if !cfg.torrent.enabled { + if !cfg.torrent.on() { Err(anyhow::anyhow!("torrents are disabled")) } else { torrent_one(ctx, &enc.feed_id, enc.id, &enc.url, &dest_dir).await.map(Some) @@ -889,7 +889,7 @@ pub(crate) async fn torrent_one( let cfg = ctx.cfg(); ctx.torrents() .await? - .fetch(&cfg, &ctx.client, url, &torrent::own_folder(dest_dir, enclosure), |done, total| { + .fetch(&cfg, &ctx.client, url, dest_dir, enclosure, |done, total| { if let Some(pct) = (done * 100).checked_div(total).map(|p| p as i64) && pct > last_pct { @@ -1089,17 +1089,17 @@ mod tests { let state = |ctx: Arc| async move { ctx.db.strings_for_test("SELECT state FROM enclosures").await }; // Detached, as the daemon runs them: no slot free, so it waits its turn as 'downloading'. - let mut ctx = test_ctx(config::Config::default()).await; + let mut on = config::Config::default(); + on.torrent.qbittorrent_url = "http://127.0.0.1:9".into(); + let mut ctx = test_ctx(on).await; ctx.detach_torrents = true; ctx.torrent_slots = Arc::new(tokio::sync::Semaphore::new(0)); let ctx = Arc::new(ctx); assert_eq!(scan(ctx.clone()).await, (0, 1), "counted as a torrent, not a download"); assert_eq!(state(ctx).await, ["downloading"], "so the next scan does not queue it again"); - // Turned off, it is skipped and still counted. - let mut cfg = config::Config::default(); - cfg.torrent.enabled = false; - let ctx = Arc::new(test_ctx(cfg).await); + // With no qBittorrent to send it to, it is skipped and still counted. + let ctx = Arc::new(test_ctx(config::Config::default()).await); assert_eq!(scan(ctx.clone()).await, (0, 1)); assert_eq!(state(ctx).await, ["skipped"]); } diff --git a/crates/ipx/src/torrent.rs b/crates/ipx/src/torrent.rs index 880e16c..06531da 100644 --- a/crates/ipx/src/torrent.rs +++ b/crates/ipx/src/torrent.rs @@ -1,20 +1,39 @@ -//! Torrent enclosures via librqbit. Replaces iPXDownloader.getTorrent and the vendored -//! BitTorrent 4.2.1 + khashmir tree. +//! Torrent enclosures through qBittorrent's Web API (#494). ipx fetches the .torrent itself, hands +//! it over with the enclosure's own folder as its save path, and watches it to the end; qBittorrent +//! downloads it and seeds it to the limits set here. Until then ipx ran a BitTorrent session of its +//! own (librqbit), which replaced iPXDownloader.getTorrent and the vendored BitTorrent 4.2.1. -use anyhow::{Context, Result, bail}; -use librqbit::{AddTorrent, AddTorrentOptions, AddTorrentResponse, Session, SessionOptions}; -use std::net::SocketAddr; +use anyhow::{Context, Result, anyhow, bail}; +use reqwest::header::{COOKIE, SET_COOKIE}; +use reqwest::multipart::{Form, Part}; +use serde::Deserialize; use std::path::{Path, PathBuf}; -use std::sync::Arc; use std::time::{Duration, Instant}; use crate::config::Config; -use librqbit::{ListenerOptions, ManagedTorrent}; pub struct Torrents { - session: Arc, + /// Not the guarded client feeds are fetched with: qBittorrent is on the LAN by design, at the + /// address the admin gave, which the guard would refuse (#320). + http: reqwest::Client, + /// The session cookie, `name=value`; qBittorrent 5 names it after its port. + cookie: tokio::sync::Mutex>, } +/// What `torrents/info` says of one torrent, as much as ipx reads. +#[derive(Debug, Default, Deserialize)] +#[serde(default)] +struct Info { + hash: String, + state: String, + progress: f64, + total_size: i64, + completed: i64, +} + +/// How often a running torrent is looked at. +const POLL: Duration = Duration::from_secs(2); + /// How long a torrent may make no progress before we give up on it. The original called /// this torrentMaxBeatTime and counted display ticks; a wall clock is easier to reason about. fn stall_limit(cfg: &Config) -> Duration { @@ -22,132 +41,175 @@ fn stall_limit(cfg: &Config) -> Duration { } impl Torrents { - pub async fn new(cfg: &Config) -> Result { - let (lo, _hi) = cfg.torrent.ports(); - let listen_addr: SocketAddr = format!("0.0.0.0:{lo}").parse()?; - - let opts = SessionOptions { - listen: Some(ListenerOptions { listen_addr, ..Default::default() }), - client_name_and_version: Some(concat!("ipx ", env!("CARGO_PKG_VERSION")).into()), - // A test's swarm is two sessions and a tracker on 127.0.0.1, not the public DHT or the LAN. - dht: if cfg!(test) { None } else { Some(Default::default()) }, - disable_local_service_discovery: cfg!(test), - ..Default::default() - }; - - // The session root is only a fallback; every torrent names its own output folder. - let session = Session::new_with_opts(cfg.general.download_dir.clone(), opts) - .await - .context("starting the torrent session")?; - Ok(Self { session }) + pub fn new() -> Result { + let http = reqwest::Client::builder().timeout(Duration::from_secs(30)).build()?; + Ok(Self { http, cookie: Default::default() }) } - /// Downloads a torrent (a .torrent URL or a magnet link) straight into `dest_dir`, - /// seeds it up to the configured limit, then stops. `dest_dir` is the torrent's own - /// folder (`own_folder`), and it is the path returned: a file of several or one. - /// - /// Downloading in place rather than into a staging dir is deliberate: seeding serves - /// the files it downloaded, so moving them first would break it. + /// Downloads a torrent (a .torrent URL or a magnet link) through qBittorrent into the + /// enclosure's own folder inside `feed_dir`, which is the path returned: a file of several or + /// one. Done once qBittorrent has all of it; the seeding is qBittorrent's. pub async fn fetch( &self, cfg: &Config, client: &reqwest::Client, url: &str, - dest_dir: &Path, + feed_dir: &Path, + enclosure: i64, mut on_progress: impl FnMut(u64, u64), ) -> Result<(PathBuf, u64)> { - tokio::fs::create_dir_all(dest_dir).await?; - + let dir = own_folder(feed_dir, enclosure); + tokio::fs::create_dir_all(&dir).await?; let limit = stall_limit(cfg); - let source = if url.starts_with("http://") || url.starts_with("https://") { - // Under the stall budget as well: a body sent a byte a minute stays inside the cap. - let file = tokio::time::timeout(limit, torrent_file(client, url)) - .await - .map_err(|_| anyhow::anyhow!("no .torrent after {} minutes, gave up", limit.as_secs() / 60))??; - AddTorrent::from_bytes(file) - } else { - AddTorrent::from_url(url) - }; + // How ipx finds it again: qBittorrent names a torrent by its hash, which a magnet does not + // say until its metadata has come. + let tag = format!("ipx-{enclosure}"); - // Resolving a magnet's metadata happens inside add_torrent, and against a dead - // swarm it never returns. The stall budget has to cover this phase too, or a - // torrent nobody is seeding wedges the scan forever. - let added = tokio::time::timeout( - limit, - self.session.add_torrent( - source, - Some(AddTorrentOptions { - output_folder: Some(dest_dir.to_string_lossy().into_owned()), - overwrite: true, - ..Default::default() - }), - ), - ) - .await - .map_err(|_| anyhow::anyhow!("no metadata after {} minutes, gave up", limit.as_secs() / 60))? - .context("adding the torrent")?; - - let (id, handle) = match added { - AddTorrentResponse::Added(id, h) | AddTorrentResponse::AlreadyManaged(id, h) => (id, h), - AddTorrentResponse::ListOnly(_) => bail!("torrent added in list-only mode"), - }; - - let mut last_progress = 0u64; - let mut last_move = Instant::now(); - - loop { - tokio::time::sleep(Duration::from_secs(1)).await; - let stats = handle.stats(); - - if let Some(err) = &stats.error { - let _ = self.session.delete(id.into(), false).await; - bail!("torrent failed: {err}"); + // There already when ipx stopped while it ran (#410): taken up where qBittorrent has it. + if self.info(cfg, &tag).await?.is_none() { + let file = if url.starts_with("http://") || url.starts_with("https://") { + // Under the stall budget as well: a body sent a byte a minute stays inside the cap. + let got = tokio::time::timeout(limit, torrent_file(client, url)) + .await + .map_err(|_| anyhow!("no .torrent after {} minutes, gave up", limit.as_secs() / 60))??; + Some(got) + } else { + None + }; + let t = &cfg.torrent; + let save = save_path(cfg, &dir); + let said = self + .api(cfg, "torrents/add", |req| { + let form = Form::new() + .text("savepath", save.clone()) + .text("tags", tag.clone()) + // The files straight into the folder, as the path recorded says (#318). + .text("contentLayout", "NoSubfolder") + .text("ratioLimit", t.seed_ratio.to_string()) + .text("seedingTimeLimit", t.seed_time_mins.to_string()); + req.multipart(match &file { + Some(b) => form.part("torrents", Part::bytes(b.clone()).file_name("episode.torrent")), + None => form.text("urls", url.to_owned()), + }) + }) + .await?; + if said.trim() == "Fails." { + bail!("qBittorrent would not take the torrent; it may have it already"); } - on_progress(stats.progress_bytes, stats.total_bytes); + } - if stats.finished { - break; + let mut last = (-1i64, Instant::now()); + let done = loop { + tokio::time::sleep(POLL).await; + // A qBittorrent restarting is a pause, not a failure, until the stall limit says so. + let info = match self.info(cfg, &tag).await { + Ok(i) => i, + Err(e) if last.1.elapsed() < limit => { + tracing::debug!(error = %format!("{e:#}"), "qBittorrent did not answer"); + continue; + } + Err(e) => return Err(e), + }; + let Some(info) = info else { bail!("the torrent is no longer in qBittorrent") }; + if matches!(info.state.as_str(), "error" | "missingFiles") { + self.delete(cfg, &info.hash).await; + bail!("qBittorrent says the torrent failed ({})", info.state); } - if stats.progress_bytes > last_progress { - last_progress = stats.progress_bytes; - last_move = Instant::now(); - } else if last_move.elapsed() > limit { + on_progress(info.completed.max(0) as u64, info.total_size.max(0) as u64); + if info.progress >= 1.0 && info.total_size > 0 { + break info; + } + if info.completed > last.0 { + last = (info.completed, Instant::now()); + } else if last.1.elapsed() > limit { // Leave the partial files behind; the row records the failure. - let _ = self.session.delete(id.into(), false).await; + self.delete(cfg, &info.hash).await; bail!("no progress for {} minutes, gave up", limit.as_secs() / 60); } + }; + + // shortcut: a torrent seeding when the reaper deletes its files shows as missing files in + // qBittorrent until someone removes it there; have the reaper delete it too if that bothers. + if cfg.torrent.seed_ratio <= 0.0 || cfg.torrent.seed_time_mins == 0 { + self.delete(cfg, &done.hash).await; } - - // The torrent's own name is the publisher's to choose, and librqbit checks it only when it - // picks the folder itself: joined on, "/config" or ".." pointed Delete, the reaper and - // /media at anything the daemon can reach (#318). The folder is ours, so it is the path. - let path = dest_dir.to_owned(); - let size = handle.stats().total_bytes; - - self.seed(cfg, &handle).await; - self.session.delete(id.into(), false).await.context("releasing the torrent")?; - - Ok((path, size)) + Ok((dir, done.total_size as u64)) } - /// Seeds until the ratio or the time limit is reached, whichever comes first. - async fn seed(&self, cfg: &Config, handle: &Arc) { - if cfg.torrent.seed_ratio <= 0.0 || cfg.torrent.seed_time_mins == 0 { - return; + async fn info(&self, cfg: &Config, tag: &str) -> Result> { + let body = self.api(cfg, "torrents/info", |req| req.form(&[("tag", tag)])).await?; + let mut all: Vec = serde_json::from_str(&body).context("reading qBittorrent's torrent list")?; + Ok((!all.is_empty()).then(|| all.swap_remove(0))) + } + + /// Takes the torrent out of qBittorrent, keeping its files. A failure is logged, not raised: + /// what called it is already giving up, or done. + async fn delete(&self, cfg: &Config, hash: &str) { + let form = [("hashes", hash), ("deleteFiles", "false")]; + if let Err(e) = self.api(cfg, "torrents/delete", |req| req.form(&form)).await { + tracing::warn!(error = %format!("{e:#}"), "could not remove the torrent from qBittorrent"); } - let deadline = Instant::now() + Duration::from_secs(cfg.torrent.seed_time_mins * 60); - loop { - let stats = handle.stats(); - if ratio(stats.uploaded_bytes, stats.total_bytes) >= cfg.torrent.seed_ratio { - tracing::info!(ratio = cfg.torrent.seed_ratio, "seed ratio reached"); - return; + } + + /// One call to the Web API, signing in first when a user is set, and again once if the session + /// has expired (a 403). The answer's body. + async fn api( + &self, + cfg: &Config, + path: &str, + body: impl Fn(reqwest::RequestBuilder) -> reqwest::RequestBuilder, + ) -> Result { + let base = cfg.torrent.qbittorrent_url.trim_end_matches('/'); + for retry in [false, true] { + let cookie = self.cookie(cfg, retry).await?; + let mut req = body(self.http.post(format!("{base}/api/v2/{path}"))); + if let Some(c) = cookie { + req = req.header(COOKIE, c); } - if Instant::now() >= deadline { - tracing::info!(mins = cfg.torrent.seed_time_mins, "seed time reached"); - return; + let resp = req.send().await.with_context(|| format!("asking qBittorrent ({path})"))?; + if resp.status() == reqwest::StatusCode::FORBIDDEN && !retry && !cfg.torrent.username.is_empty() { + continue; } - tokio::time::sleep(Duration::from_secs(5)).await; + let resp = resp.error_for_status().with_context(|| format!("qBittorrent refused {path}"))?; + return Ok(resp.text().await?); } + unreachable!("the second try returns") + } + + async fn cookie(&self, cfg: &Config, fresh: bool) -> Result> { + let t = &cfg.torrent; + if t.username.is_empty() { + return Ok(None); + } + let mut held = self.cookie.lock().await; + if fresh || held.is_none() { + let resp = self + .http + .post(format!("{}/api/v2/auth/login", t.qbittorrent_url.trim_end_matches('/'))) + .form(&[("username", t.username.as_str()), ("password", t.password.as_str())]) + .send() + .await + .context("signing in to qBittorrent")?; + let got = resp + .headers() + .get_all(SET_COOKIE) + .iter() + .filter_map(|v| v.to_str().ok()?.split(';').next()) + .find(|c| c.split_once('=').is_some_and(|(name, _)| name.contains("SID"))) + .map(str::to_owned); + *held = Some(got.ok_or_else(|| anyhow!("qBittorrent refused ipx's username and password"))?); + } + Ok(held.clone()) + } +} + +/// Where qBittorrent is to write `dir`: the same path, or `save_path` in place of `download_dir` +/// when qBittorrent's mount of it is somewhere else. +fn save_path(cfg: &Config, dir: &Path) -> String { + let theirs = cfg.torrent.save_path.trim(); + match dir.strip_prefix(&cfg.general.download_dir) { + Ok(rest) if !theirs.is_empty() => Path::new(theirs).join(rest).display().to_string(), + _ => dir.display().to_string(), } } @@ -175,93 +237,95 @@ pub fn own_folder(feed_dir: &Path, enclosure: i64) -> PathBuf { feed_dir.join(format!("torrent-{enclosure}")) } -/// Uploaded over total. A zero-byte torrent counts as fully seeded rather than dividing by zero. -pub fn ratio(uploaded: u64, total: u64) -> f64 { - if total == 0 { - return f64::INFINITY; - } - uploaded as f64 / total as f64 -} - #[cfg(test)] mod tests { use super::*; + use std::sync::Arc; - fn free_port() -> u16 { - std::net::TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port() - } - - /// A swarm on 127.0.0.1: a seeding session holding `file`, and a web server answering for the - /// .torrent (`/ep.torrent`) and as its tracker, naming the seed as the one peer. The server's - /// address, and the seeding session, which stops seeding when dropped. - async fn swarm(file: &Path) -> (SocketAddr, Arc) { + /// A qBittorrent that wants a sign-in, and as the feed's server serves the .torrent too. A + /// torrent added is finished at once: the file is written into its save path, as qBittorrent + /// would. Its address, and the hashes deleted. + async fn qbittorrent(episode: Vec) -> (std::net::SocketAddr, Arc>>) { + use axum::http::{HeaderMap, StatusCode}; + use axum::response::IntoResponse; + use axum::routing::{get, post}; + type Held = Arc>>; + let held: Held = Default::default(); + let deleted: Arc>> = Default::default(); + let signed_in = |h: &HeaderMap| h.get("cookie").is_some_and(|c| c == "QBT_SID_8080=abc"); + // The multipart body read as text: enough to find a field's value in a test. + let field = |body: &str, name: &str| { + let at = body.find(&format!("name=\"{name}\"\r\n\r\n")).unwrap() + name.len() + 11; + body[at..].split("\r\n").next().unwrap().to_owned() + }; + let (h1, h2, d) = (held.clone(), held.clone(), deleted.clone()); + let app = axum::Router::new() + .route("/ep.torrent", get(|| async { "d4:infode" })) + .route( + "/api/v2/auth/login", + post(|body: String| async move { + if body == "username=ipx&password=pw" { + ([("set-cookie", "QBT_SID_8080=abc; HttpOnly; path=/")], "Ok.").into_response() + } else { + "Fails.".into_response() + } + }), + ) + .route( + "/api/v2/torrents/add", + post(move |h: HeaderMap, body: axum::body::Bytes| async move { + if !signed_in(&h) { + return (StatusCode::FORBIDDEN, "Forbidden").into_response(); + } + let body = String::from_utf8_lossy(&body); + assert!(body.contains("d4:infode"), "the .torrent ipx fetched"); + assert_eq!(field(&body, "contentLayout"), "NoSubfolder"); + let save = field(&body, "savepath"); + std::fs::write(Path::new(&save).join("episode.mp3"), &episode).unwrap(); + let n = episode.len(); + h1.lock().unwrap().push(serde_json::json!({"hash": "h1", "tags": field(&body, "tags"), + "state": "uploading", "progress": 1.0, "total_size": n, "completed": n})); + "Ok.".into_response() + }), + ) + .route( + "/api/v2/torrents/info", + post(move |h: HeaderMap, body: String| async move { + if !signed_in(&h) { + return (StatusCode::FORBIDDEN, "Forbidden").into_response(); + } + let tag = body.strip_prefix("tag=").unwrap().to_owned(); + let all = h2.lock().unwrap().iter().filter(|t| t["tags"] == tag).cloned().collect::>(); + axum::Json(all).into_response() + }), + ) + .route( + "/api/v2/torrents/delete", + post(move |body: String| async move { + d.lock().unwrap().push(body); + "Ok." + }), + ); let web = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); let at = web.local_addr().unwrap(); - let seed_port = free_port(); - let made = librqbit::create_torrent( - file, - librqbit::CreateTorrentOptions { - name: None, - trackers: vec![format!("http://{at}/announce")], - piece_length: Some(16 * 1024), - }, - &librqbit::spawn_utils::BlockingSpawner::new(2), - ) - .await - .unwrap(); - let torrent = made.as_bytes().unwrap(); - // Compact peers: the address's four bytes, then the port's two. - let mut peers = b"d8:intervali60e5:peers6:".to_vec(); - peers.extend_from_slice(&[127, 0, 0, 1]); - peers.extend_from_slice(&seed_port.to_be_bytes()); - peers.push(b'e'); - let app = axum::Router::new() - .route("/ep.torrent", axum::routing::get(move || std::future::ready(torrent.clone()))) - .route("/announce", axum::routing::get(move || std::future::ready(peers.clone()))); tokio::spawn(async move { axum::serve(web, app).await }); - - let seed = Session::new_with_opts( - file.parent().unwrap().to_owned(), - SessionOptions { - dht: None, - disable_local_service_discovery: true, - listen: Some(ListenerOptions { - listen_addr: format!("127.0.0.1:{seed_port}").parse().unwrap(), - ..Default::default() - }), - ..Default::default() - }, - ) - .await - .unwrap(); - seed.add_torrent( - AddTorrent::from_bytes(made.as_bytes().unwrap()), - Some(AddTorrentOptions { - output_folder: Some(file.parent().unwrap().display().to_string()), - overwrite: true, - ..Default::default() - }), - ) - .await - .unwrap(); - (at, seed) + (at, deleted) } #[tokio::test(flavor = "multi_thread")] async fn a_detached_torrent_lands_in_its_own_folder_is_recorded_and_frees_its_slot() { let root = std::env::temp_dir().join(format!("ipx-torrent-{}", std::process::id())); let _ = std::fs::remove_dir_all(&root); - let (seeded, downloads) = (root.join("seed"), root.join("downloads")); - std::fs::create_dir_all(&seeded).unwrap(); + let downloads = root.join("downloads"); let episode: Vec = (0..200_000u32).map(|i| (i * 7 % 251) as u8).collect(); - std::fs::write(seeded.join("episode.mp3"), &episode).unwrap(); - let (at, _seed) = swarm(&seeded.join("episode.mp3")).await; + let (at, deleted) = qbittorrent(episode.clone()).await; let mut cfg = Config::default(); cfg.general.download_dir = downloads.clone(); - cfg.torrent.enabled = true; - let port = free_port(); - cfg.torrent.port_range = format!("{port}-{port}"); + cfg.general.fetch_internal = vec!["127.0.0.1".into()]; + cfg.torrent.qbittorrent_url = format!("http://{at}/"); + cfg.torrent.username = "ipx".into(); + cfg.torrent.password = "pw".into(); cfg.torrent.seed_ratio = 0.0; let mut ctx = crate::test_util::test_ctx(cfg.clone()).await; ctx.detach_torrents = true; @@ -275,7 +339,7 @@ mod tests { .unwrap(); crate::scan::spawn_torrent(&ctx, "f".into(), 9, url.clone(), downloads.join("Show")); - let row = tokio::time::timeout(Duration::from_secs(90), async { + let row = tokio::time::timeout(Duration::from_secs(30), async { loop { let row = ctx.db.enclosure(9).await.unwrap().unwrap(); if row.state != "downloading" { @@ -285,17 +349,32 @@ mod tests { } }) .await - .expect("the torrent finished within 90 s"); + .expect("the torrent finished within 30 s"); let folder = own_folder(&downloads.join("Show"), 9); assert_eq!((row.state.as_str(), row.last_error.as_deref()), ("done", None)); assert_eq!(row.path.as_deref(), Some(folder.display().to_string().as_str()), "the folder is ours (#318)"); assert_eq!(std::fs::read(folder.join("episode.mp3")).unwrap(), episode); + assert_eq!( + *deleted.lock().unwrap(), + ["hashes=h1&deleteFiles=false"], + "no seeding asked for: let go, files kept" + ); // The slot is let go once the row is written; give the task its moment. tokio::time::sleep(Duration::from_millis(200)).await; assert_eq!(ctx.torrent_slots.available_permits(), 2, "the slot is free again"); let _ = std::fs::remove_dir_all(&root); } + #[test] + fn the_save_path_is_where_qbittorrent_sees_the_folder() { + let mut cfg = Config::default(); + cfg.general.download_dir = "/downloads".into(); + let dir = Path::new("/downloads/Show/torrent-9"); + assert_eq!(save_path(&cfg, dir), "/downloads/Show/torrent-9", "the same mount"); + cfg.torrent.save_path = "/data/ipx".into(); + assert_eq!(save_path(&cfg, dir), "/data/ipx/Show/torrent-9"); + } + #[tokio::test] async fn a_torrent_file_from_an_internal_address_is_refused_unless_allowed() { let app = axum::Router::new().route("/ep.torrent", axum::routing::get(|| async { "d4:infode" })); @@ -317,14 +396,6 @@ mod tests { ); } - #[test] - fn ratio_handles_the_empty_torrent() { - assert_eq!(ratio(0, 100), 0.0); - assert_eq!(ratio(50, 100), 0.5); - assert_eq!(ratio(200, 100), 2.0); - assert!(ratio(0, 0).is_infinite(), "must not divide by zero or seed forever"); - } - #[tokio::test] async fn an_endless_torrent_file_stops_at_the_cap() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/deny.toml b/deny.toml index 5295555..2e36dee 100644 --- a/deny.toml +++ b/deny.toml @@ -7,12 +7,9 @@ targets = ["x86_64-unknown-linux-gnu"] [advisories] ignore = [ - # ringbuf 0.4's double free needs an element whose Drop panics; librqbit-utp's buffer holds - # only u8, which has no Drop. Its fix is ringbuf 0.5, which librqbit 9.0.1 cannot take (#281). - { id = "RUSTSEC-2026-0293", reason = "librqbit-utp's ring buffer holds u8: no Drop to panic" }, - # chrono is unmaintained, every version, and no vulnerability is known. rss, atom_syndication and - # librqbit-dht depend on it, so ipx's own code moving off it would not take it out (#493). - { id = "RUSTSEC-2026-0543", reason = "unmaintained, not vulnerable; the feed parsers and librqbit depend on it (#493)" }, + # chrono is unmaintained, every version, and no vulnerability is known. rss and atom_syndication + # depend on it, so ipx's own code moving off it would not take it out (#493). + { id = "RUSTSEC-2026-0543", reason = "unmaintained, not vulnerable; the feed parsers depend on it (#493)" }, ] [licenses] diff --git a/docker-compose.yml b/docker-compose.yml index b351466..2b6a8ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,9 +16,6 @@ services: # For Postgres instead of SQLite: # IPX_DATABASE_URL: "postgres://ipx:password@db-host:5432/ipx" # No web port of its own: ipx-web is the way in, and passes the API on to it. - ports: - - "6881:6881/tcp" # BitTorrent peers - - "6881:6881/udp" # DHT volumes: - ./config:/config # config.toml, written on first start - ./data:/data # state.db diff --git a/docs/architecture.md b/docs/architecture.md index 46c3489..6558519 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -53,7 +53,7 @@ id, and Caddy's request lines theirs. ipx also serves Prometheus metrics (`[web] | `crates/feed/src/jev.rs` | Jev's pick of a category | — | | `crates/feed/src/guard.rs` | The connection guard against internal addresses (#320) | — | | `crates/ipx/src/download.rs` | Streaming download, naming, type sniffing, placement | `iPXDownloader.getFile` | -| `crates/ipx/src/torrent.rs` | librqbit session, seeding limits, stall abort | vendored BitTorrent 4.2.1 | +| `crates/ipx/src/torrent.rs` | Hands torrents to qBittorrent's Web API and watches them to the end, stall abort | vendored BitTorrent 4.2.1 | | `crates/ipx/src/retention.rs` | Quota and age sweeps | `iPXQuotaManager.py` | | `crates/ipx/src/ipc.rs` | Event and command types, the socket server | `printMSG` on stdout | | `crates/ipx/src/auth.rs` | Argon2id hashing, session tokens, header names | — | @@ -102,7 +102,7 @@ and the files, and no page. a reason. What a filter skipped is judged again every scan, so a change of settings brings it back. A feed in a group takes your settings on the group for anything you have not set on it. 7. Download what is still pending, newest first, up to the per-scan cap. A `.torrent` body goes to - the torrent path whatever its advertised type; an HTML body is a failed download — a login wall + qBittorrent whatever its advertised type; an HTML body is a failed download — a login wall or an error page — and is deleted. ## Data model diff --git a/docs/configuration.md b/docs/configuration.md index 6537c2d..f77b242 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -89,15 +89,23 @@ database as described above; `download_dir`, `socket`, `organize` and `fetch_int ```toml [torrent] -enabled = true -seed_ratio = 1.0 # stop seeding at this ratio ... -seed_time_mins = 60 # ... or after this long, whichever comes first -port_range = "6881-6889" -stall_mins = 30 # give up on a torrent making no progress +enabled = true +qbittorrent_url = "http://qbittorrent:8080" # its Web UI; empty holds torrents back +username = "ipx" # empty when qBittorrent lets ipx's address in without one +password = "" +save_path = "" # where qBittorrent sees download_dir, if not at the same path +seed_ratio = 1.0 # qBittorrent stops seeding at this ratio ... +seed_time_mins = 60 # ... or after this long, whichever comes first +stall_mins = 30 # give up on a torrent making no progress ``` -A `.torrent` body is handed to the torrent path whatever MIME type it was advertised as. Torrents -run on their own tasks (two at a time) so a slow swarm never blocks a scan. +Torrents go to [qBittorrent](https://www.qbittorrent.org/) through its Web API: ipx fetches the +`.torrent` (or passes on the magnet link), adds it with the episode's own folder as its save path, +and records the episode once qBittorrent has all of it. qBittorrent does the seeding. It has to be +able to write to `download_dir`: mount the same folder into its container, and if the path is not +the same as in ipx's, say where in `save_path`. A `.torrent` body is handed to qBittorrent whatever +MIME type it was advertised as. Torrents are watched on their own tasks (two at a time) so a slow +swarm never blocks a scan. ## `[web]`