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-<enclosure> 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_<port>. 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkrVBuJRne2JAhFpaDV2U
This commit is contained in:
2026-11-22 14:29:20 -05:00
parent 2c8b4d925e
commit c4d7b497fa
13 changed files with 364 additions and 1369 deletions

View File

@@ -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

View File

@@ -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]`