Preferences That Matter
Outcome: you can read the program's
settings as one JSON document, change
exactly the ones you mean to, and read
back the proof. Evidence: transcript
t02, with the speed limit set in t05
and exercised in t06.
One document in, one document out
Every preference lives behind two calls:
# read all of them
curl -s -b cookies.txt \
http://127.0.0.1:18088/api/v2/app/preferences
# change some of them
curl -s -b cookies.txt --data-urlencode \
'json={"save_path":"/some/folder"}' \
http://127.0.0.1:18088/api/v2/app/setPreferences
There are well over a hundred keys; the
working style is to pick fields out
with jq rather than read the flood.
The lab's first read, trimmed to what
mattered:
{"save_path": ".../instance-a/qBittorrent/downloads",
"listen_port": 48188, "web_ui_port": 18088,
"dl_limit": 0, "up_limit": 0,
"dht": true, "pex": true, "lsd": true}
Note listen_port: it picked up the
--torrenting-port the program was
started with. Command line, config file
and API are three doors into the same
room — chapter 2's qBittorrent.conf
holds the same values in plain text
(Session\Port=48188,
Session\DefaultSavePath=..., both in
t11), and a change made in the WebUI's
options pages is the same change again.
The settings the lab changed, and why
save_path — where finished and
in-progress files live. The default sits
inside the profile (.../qBittorrent/
downloads); the lab pointed each
instance at its own folder outside the
profile, so downloaded data and program
state could be told apart at a glance.
dht, pex, lsd — set to false.
The three discovery systems of chapter
2, switched off so the lab's two
instances could only meet by
deliberate introduction. On a real
machine feeding on real swarms you
would leave them on; the lesson is that
they are switches, with names, and you
can state the state of each.
dl_limit — a speed limit in bytes
per second (0 = no limit). Instance B
got 131072 — 128 KiB/s — purely so the
2 MiB transfer of chapter 7 would run
slowly enough to watch. Limits also
exist per torrent (torrents/
setDownloadLimit) and on a schedule;
the global one is the blunt instrument
that is usually the right one. Two
honest observations from that transfer:
a limit is a ceiling, not a promise —
early readings sat well under it while
the connection warmed up — and the
reading to trust is dlspeed in the
torrent's own record, not the number
you set.
The WebUI's own guards, seen in
t10: web_ui_max_auth_fail_count (5)
and web_ui_ban_duration (3600 seconds)
decide when a persistent guesser gets
an hour of silence. Worth knowing they
exist before a script of yours
mistypes a password five times.
The rules of safe changing
Change few keys per call — a call sets
exactly the keys it names and leaves
the rest alone. Read back after every
change; the read-back in t02 is two
lines long and is the whole proof. And
remember the one key you cannot read
back: the password of chapter 4 is
write-only, verified by logging in,
never by inspection.