Skip to content

The Moving Parts

Outcome: you can name each part of a running qBittorrent, say which part holds what, and predict where a fact will be found — in the API, in the config file, or on disk. Everything in this chapter was seen in the lab; the profile listing is transcript t11.

The engine and the shell around it

Underneath, qBittorrent is a shell around libtorrent, the library that speaks the BitTorrent protocol: finding peers, requesting pieces, hashing what arrives. The lab's build reports its own stack (appendix evidence in t01b): qBittorrent 5.3.0, Web API 2.16.2, libtorrent 2.1.2.0, Qt 6.12. The shell adds everything a person touches — the torrent list, the settings, the WebUI, the RSS reader — and keeps the engine fed.

The profile: one folder is the whole memory

Everything an instance is lives in one profile folder, chosen with --profile=<dir>:

qBittorrent/
  config/
    qBittorrent.conf     every preference, as plain text
    categories.json      the categories you created
    rss/feeds.json       the feeds you added
  data/
    BT_backup/           one .torrent + one .fastresume
                         per torrent in the list
    logs/qbittorrent.log the program's own log

Delete the profile and the program has forgotten everything; copy it and you have cloned the instance. The lab ran two instances side by side simply by giving each its own profile folder.

Torrents, states, and the vocabulary of waiting

A torrent in the list is a job: a map (the .torrent file or a magnet link), a save path, and a position in its life. The life is reported as a state, and this guide uses the real words the API returns, because each names a different situation with a different remedy:

  • metaDL — has a magnet link, waiting for the map itself, which only the swarm can supply (seen in t10).
  • downloading — pieces are arriving.
  • stalledDL — started, but no pieces are moving: no peers, or none with anything to give (seen in t05).
  • checkingDL / checkingUP — re-reading its files on disk and re-verifying every piece hash; progress drops to 0 while it works and returns when done (caught live in t07).
  • uploading — complete, and actively serving pieces right now (t06).
  • stalledUP — complete and ready to serve, nobody asking (t04).
  • stoppedDL / stoppedUP — you stopped it; it will do nothing until started.

Finding peers: trackers and the three discoveries

A client cannot trade with a swarm it cannot find. There are four doors, and chapter 5 turns three of them off on purpose:

  • A tracker is a meeting point named inside the torrent: these addresses are interested in this file.
  • DHT (distributed hash table) asks other clients, with no centre.
  • PeX (peer exchange) asks each peer who else it knows.
  • LSD (local service discovery) shouts on the local network only.

The lab's torrent named no tracker, and the lab disabled DHT, PeX and LSD, so its two instances could only meet when introduced by hand — which is what makes the introduction in chapter 7 worth showing.

The WebUI and the API

The WebUI is a set of pages the program serves on its WebUI port (18088 in this lab). Everything the pages show comes from the API at /api/v2/... — the pages are one client of it, and curl in this guide is another. Access is by login: a username (always admin in this version unless changed) and a password earn a session cookie; without the cookie, the API answers 403 Forbidden, and a wrong password earns 401 Unauthorized (both in t01b and t10). The same API is what home-automation tools and phone apps talk to — nothing in this guide's lab needed the pages themselves.

The RSS reader

A smaller citizen lives inside: an RSS downloader that polls feeds you give it, reads the items they announce, and — where a rule matches an item's title — adds the item's torrent on its own (chapter 10). It has its own two switches in preferences, its own storage in the profile, and its own dialect, which chapter 10 meets honestly.