Torrents over a fail-closed VPN (#1026)

Torrents reach the Internet only through a fail-closed VPN (WireGuard or
OpenVPN, any provider), so peers never see a WROLPi's own address.

- A network namespace (Pi/Debian) or the vpn container (Docker) with an
  nftables kill switch; NAT-PMP or fixed port forwarding.
- qBittorrent inside it, sandboxed; torrents kept in config/torrents/.
- Torrent download form, Torrents page, Share as torrent, nav warning, and
  VPN settings in both Controller UIs.
- Help docs: Torrents, and The VPN for Torrents.

QA'd on a Raspberry Pi with a real provider over WireGuard and OpenVPN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-11-28 14:25:24 -07:00 • committed by Roland
parent 633b125dc6
commit 2c3300b8b0
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
80 changed files with 7516 additions and 45 deletions

View file

@ -314,6 +314,38 @@ if ! command -v dnsmasq &>/dev/null || ! command -v iw &>/dev/null || ! command
-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold dnsmasq-base iw rfkill
fi
# Install torrents (qBittorrent) and the VPN tools they use (the kill switch is nftables) if not already installed.
if ! command -v nft &>/dev/null || ! command -v openvpn &>/dev/null || ! command -v wg &>/dev/null \
|| ! command -v qbittorrent-nox &>/dev/null; then
echo "Installing nftables, openvpn, wireguard-tools, qbittorrent-nox..."
# An existing WROLPi may upgrade to this offline: without the tools torrents cannot run (the VPN refuses to start
# without nftables), but the rest of the upgrade still applies, and a later, online upgrade installs them.
if apt-get update; then
# Not their recommends (pcscd, opensc, easy-rsa, and an enabled openvpn.service), which WROLPi does not use.
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold nftables openvpn wireguard-tools \
qbittorrent-nox || echo "Installing the torrent and VPN tools failed, continuing..."
else
echo "Could not refresh apt (offline?); not installing the torrent and VPN tools, continuing..."
fi
fi
# qBittorrent faces the Internet (the VPN forwards a port to it): keep it, and libtorrent, as patched as Debian makes
# them, on every upgrade.
if command -v qbittorrent-nox &>/dev/null; then
echo "Upgrading qbittorrent-nox and libtorrent..."
# Often offline: a failed refresh skips this (a later, online upgrade patches it) rather than ending the upgrade.
if apt-get update; then
# shellcheck disable=SC2046
DEBIAN_FRONTEND=noninteractive apt-get install -y --only-upgrade \
-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold qbittorrent-nox \
$(dpkg-query -W -f='${binary:Package}\n' 'libtorrent-rasterbar*' 2>/dev/null) || \
echo "Upgrading qbittorrent-nox failed, continuing..."
else
echo "Could not refresh apt (offline?); not upgrading qbittorrent-nox, continuing..."
fi
fi
# Install Mesa's EGL and GL drivers if missing (the map tile service draws with them).
if ! ldconfig -p | grep -q 'libEGL.so.1 ' || ! ldconfig -p | grep -q libEGL_mesa \
|| ! ldconfig -p | grep -q 'libGLESv2.so.2 '; then

View file

@ -33,7 +33,6 @@ wrolpi/files/test/test_worker_move.py: unused import 'worker_module'
wrolpi/flags.py: unused variable 'exc_tb'
wrolpi/flags.py: unused variable 'exc_type'
wrolpi/flags.py: unused variable 'exc_val'
wrolpi/jobs.py: unused method 'cancel_requested'
wrolpi/logging_extra.py: unused class 'EmptyMessageFilter'
wrolpi/media_path.py: unused method 'process_result_value'
wrolpi/media_path.py: unused variable 'PATH_TYPE'