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

@ -77,6 +77,13 @@ def _isolate_hotspot_boot_marker(tmp_path_factory, monkeypatch):
monkeypatch.setattr(admin, "HOTSPOT_BOOT_MARKER", marker)
@pytest.fixture(autouse=True)
def _isolate_vpn_run_dir(tmp_path_factory, monkeypatch):
"""Tests never read or write the real VPN status or server addresses in /run."""
import controller.vpn.tunnel as tunnel
monkeypatch.setattr(tunnel, "RUN_DIR", tmp_path_factory.mktemp("wrolpi-vpn"))
@pytest.fixture(autouse=True)
def _patch_status_worker():
"""Replace the real status worker with a no-op for every test.
@ -87,6 +94,18 @@ def _patch_status_worker():
yield
async def _noop_rsync_daemon_loop():
await asyncio.Event().wait()
@pytest.fixture(autouse=True)
def _patch_rsync_daemon_loop():
"""A Docker-mode app must not manage the real rsync helper container of whatever Docker runs these tests: a
branch whose rsyncd.conf differs would replace a developer's container, while other tests list containers."""
with mock.patch("controller.main.rsync_daemon_loop", _noop_rsync_daemon_loop):
yield
@pytest.fixture
def test_directory() -> Generator[Path, None, None]:
"""Create a temporary directory for testing."""