wrolpi/controller/defaults.py
lrnselfreliance 2c3300b8b0
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>
2026-11-28 14:26:24 -07:00

179 lines
5.4 KiB
Python

"""
Code-defined default configuration for the Controller.
Controller starts with these defaults and loads overrides from
/media/wrolpi/config/controller.yaml after the drive is mounted.
"""
from controller.vpn.tunnel import VPN_DEFAULTS
DEFAULT_CONFIG = {
"port": 80,
"media_directory": "/media/wrolpi",
"hide_cert_banner": False,
"drives": {
"supported_filesystems": ["ext4", "btrfs", "vfat", "exfat"],
"auto_mount": True,
"mounts": [], # Populated from controller.yaml after drive mount
# True when the user chose "Run repair without external drive"; the
# API then accepts an unmounted /media/wrolpi as the library.
"library_on_internal_disk": False,
},
"managed_services": [
# WROLPi services
{
"name": "wrolpi-controller",
"systemd_name": "wrolpi-controller",
"port": 80,
"viewable": True,
"use_https": False,
"description": "Controller API (FastAPI)",
},
{
"name": "wrolpi-api",
"systemd_name": "wrolpi-api",
"port": 8081,
"viewable": True,
"use_https": False,
"description": "Python API (Sanic)",
},
{
"name": "wrolpi-api-dev",
"systemd_name": "wrolpi-api-dev",
"port": 8081,
"viewable": True,
"use_https": False,
"description": "Python API (Development)",
"kind": "task",
"show_only_when_running": True,
},
{
"name": "wrolpi-app",
"systemd_name": "wrolpi-app",
"port": 3000,
"viewable": False,
"use_https": False,
"description": "React frontend",
},
{
"name": "wrolpi-app-dev",
"systemd_name": "wrolpi-app-dev",
"port": 3000,
"viewable": False,
"use_https": False,
"description": "React frontend (Development)",
"kind": "task",
"show_only_when_running": True,
},
{
"name": "wrolpi-help",
"systemd_name": "wrolpi-help",
"port": 8086,
"viewable": True,
"use_https": True,
"description": "Help documentation",
},
{
"name": "wrolpi-kiwix",
"systemd_name": "wrolpi-kiwix",
"port": 8085,
"viewable": True,
"use_https": True,
"description": "Kiwix/Zim server",
},
{
"name": "wrolpi-tiles",
"systemd_name": "wrolpi-tiles",
"port": 8088,
"viewable": False,
"use_https": False,
"description": "Map tiles for ATAK and iTAK",
},
{
"name": "wrolpi-vpn",
"systemd_name": "wrolpi-vpn",
"port": None,
"viewable": False,
"use_https": False,
"description": "VPN for torrents (fail-closed network namespace)",
},
{
"name": "wrolpi-torrent",
"systemd_name": "wrolpi-torrent",
"port": 8091,
"viewable": True,
"use_https": True,
"description": "Torrents (qBittorrent, inside the VPN)",
},
{
"name": "wrolpi-rsyncd",
"systemd_name": "wrolpi-rsyncd",
"port": 8873,
"viewable": False,
"use_https": False,
"description": "Library for secondary WROLPis (rsync)",
},
# System services
{
"name": "caddy",
"systemd_name": "caddy",
"port": 443,
"viewable": True,
"use_https": True,
"description": "Web proxy (HTTPS)",
},
# Samba file sharing services
{
"name": "smbd",
"systemd_name": "smbd",
"port": 445,
"viewable": False,
"use_https": False,
"description": "Samba file sharing",
},
{
"name": "nmbd",
"systemd_name": "nmbd",
"port": 137,
"viewable": False,
"use_https": False,
"description": "Samba NetBIOS name service",
},
# Upgrade service - only shown when running
{
"name": "wrolpi-upgrade",
"systemd_name": "wrolpi-upgrade",
"port": None,
"viewable": False,
"use_https": False,
"description": "WROLPi upgrade process",
"kind": "task",
"show_only_when_running": True,
},
],
"hotspot": {
"device": "wlan0",
"ssid": "WROLPi",
"password": "wrolpi hotspot",
"protocol": "wpa2", # wpa2 (wpa-psk) or wpa3 (sae); see get_device_hotspot_protocols
# Show a landing page (with this WROLPi's address) to devices that join the hotspot.
"captive_portal": True,
# Start the hotspot when WROLPi boots. Set false to never start it unless asked.
"on_startup": True,
},
# Torrents reach the Internet only through this VPN; see controller/vpn/tunnel.py.
"vpn": dict(VPN_DEFAULTS),
"throttle": {
"default_governor": "ondemand",
},
"samba": {
"shares": [],
# Each share: {"name": str, "path": str, "read_only": bool, "comment": str}
},
}