diff --git a/docs/index.md b/docs/index.md index 183d964..d06b923 100644 --- a/docs/index.md +++ b/docs/index.md @@ -50,6 +50,8 @@ Information about the parts of the WROLPi interface. * [ATAK and iTAK](modules/map/atak.md) * [Zim](modules/zim/index.md) * [Repos](modules/repos/index.md) +* [Torrents](modules/torrents/index.md) + * [The VPN for Torrents](modules/torrents/vpn.md) * [Bookmarks](modules/bookmarks/index.md) * [Inventory](modules/inventory/index.md) * [Summary](modules/inventory/summary.md) diff --git a/docs/modules/downloads/index.md b/docs/modules/downloads/index.md index 76f4f22..4c3dd41 100644 --- a/docs/modules/downloads/index.md +++ b/docs/modules/downloads/index.md @@ -21,6 +21,8 @@ The Download menu offers a form for each kind of download: * **RSS Feed** — watch an RSS feed and automatically download new entries with either the Video or Archive downloader. Options include the frequency and title/URL filters. * **Files** — download any file from a URL into a directory of your choosing. +* **Torrent** — download torrents (magnet links, `.torrent` URLs or files), only through a VPN. See + [Torrents](../torrents/index.md). * **Scrape** — crawl a web page (up to a chosen depth and page limit) collecting every linked file that matches your list of file suffixes (for example `.pdf,.mp4`), then download those files to a destination. diff --git a/docs/modules/torrents/index.md b/docs/modules/torrents/index.md new file mode 100644 index 0000000..c5e4c7f --- /dev/null +++ b/docs/modules/torrents/index.md @@ -0,0 +1,115 @@ +# Torrents + +WROLPi can download torrents, and share files from your library as torrents, so that others can download large open +data (maps, Zims, datasets) from you. Torrents only ever use a [VPN](vpn.md): peers see the VPN's address, never your +WROLPi's own. While the VPN is not connected, torrents are stopped. + +![Torrents Page](torrents-page.png) + +Before adding a torrent, [set up the VPN](vpn.md#setting-up-the-vpn). + +## Downloading a Torrent + +> To download a torrent, open the Download menu and click **Torrent**. + +![Torrent Download Form](torrent-download-form.png) + +Enter one or more magnet links or `.torrent` URLs (one per line), or choose a `.torrent` file, or both. The torrent is +saved in the `torrents` directory of your media directory unless you choose another destination. A destination can be +any directory in your library, but not WROLPi's `config` directory. + +The form shows whether the VPN is connected. You can add a torrent while it is not; the torrent starts once the VPN +connects. + +The Download is complete on the Downloads page once the torrent has been added. Its progress then shows on the +Downloads page and the Torrents page. When a torrent finishes downloading, its files are indexed like any other +download, and it keeps seeding. + +## The Torrents Page + +> To see your torrents, click **Admin**, then **Torrents**. + +The top of the page shows: + +* **VPN**: whether it is connected, the address peers see, and the port forwarded to this WROLPi (if any). The **VPN + settings** link opens the [VPN settings](vpn.md#setting-up-the-vpn). +* **Connectability**, while the VPN is connected: + +| Shown | Meaning | +|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Peers can connect to this WROLPi | A peer has connected in through the forwarded port. Anyone can download from you. | +| Firewalled | No peer has connected in. You can still download, and upload to peers who accept connections, but peers behind their own firewalls cannot reach you. See [Port Forwarding](vpn.md#port-forwarding). | + +* The total upload and download speeds, and the **Speed Limits**. + +Each torrent's row shows its size, progress, ratio (uploaded ÷ size), seeds and peers, and state. Its buttons: + +| Button | Action | +|------------------------|------------------------------------------------------------------------------------------------| +| Pause / Resume | Stop or start downloading and seeding this torrent. | +| Copy magnet link | Copy the torrent's magnet link, to give to others. | +| Download .torrent file | Download the torrent's `.torrent` file, to give to others. | +| Seeding limits | Stop seeding once a ratio is reached, or after a number of hours seeding. Empty seeds forever. | +| Remove | Stop the torrent. Its files stay in your library unless you choose **Also delete its files**. | + +### Speed Limits + +**Speed Limits** caps the total upload and download speed of all torrents, in KiB/s (0 is unlimited). Seeding can use +all of your upload bandwidth; limit uploads to keep the rest of your network usable. + +## Sharing Files as a Torrent + +You can make a torrent of a file or directory that is already in your library, and seed it from where it is. + +> To share a file or directory, select it in **Files**, then click **Share**. + +![Share as Torrent](share-as-torrent.png) + +| Field | Purpose | +|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Trackers | One per line. Trackers help peers find each other; peers also find each other without them (DHT). Two public trackers are offered by default. | +| Use these trackers next time | Offer these trackers the next time you share. | +| Web seeds | Optional, one per line. URLs where the same file can also be downloaded (for example, a copy on a website), so downloads never depend on peers alone. | + +Click **Make Torrent**. The torrent client reads every file to make the torrent, which takes a while for large files: +about an hour for hundreds of gigabytes on a Raspberry Pi. The progress is shown, and you can cancel it. When it is +done, copy its magnet link and give it to others, or download its `.torrent` file from the Torrents page. + +The torrent is made in both torrent formats (v1 and v2), so every torrent client can download it. + +A torrent cannot include: + +* WROLPi's `config` directory, or your whole media directory (which holds it). +* Links to folders, or links to files outside your library. + +**Warning!** Anything you share can be downloaded by anyone who has its magnet link. Only share files you have the +right to share. + +## The qBittorrent WebUI + +WROLPi uses [qBittorrent](https://www.qbittorrent.org/) to download and seed torrents. Its own interface (the WebUI) +offers more detail, such as each torrent's peers and files. + +> To open the WebUI, click **qBittorrent WebUI** on the Torrents page. + +The WebUI is served on port 8091 of your WROLPi (e.g. `https://wrolpi.local:8091`), to anyone on your network, without a +password. WROLPi manages qBittorrent's settings, so the WebUI cannot change them. Torrents added or removed in the +WebUI are added to or removed from WROLPi. + +## WROL Mode + +WROL Mode stops all torrents, and turns the VPN off, so nothing reaches the Internet and +nothing from it reaches your WROLPi. Torrents start again when WROL Mode is turned off. + +## Where Torrents are Kept + +Each torrent is kept in WROLPi's config directory, as `config/torrents/.yaml` (its name, destination, and +limits) with its `.torrent` file beside it. These configs are the source of truth: if qBittorrent's own state is +lost, WROLPi adds every torrent back from them, and checks the files already downloaded rather than downloading them +again. + +A [secondary WROLPi](../../system/sync.md) does not copy the primary's torrents. + +## Docker + +In Docker, qBittorrent runs in the `vpn` container with the VPN. The host must provide `/dev/net/tun`. diff --git a/docs/modules/torrents/share-as-torrent.png b/docs/modules/torrents/share-as-torrent.png new file mode 100644 index 0000000..6d5e383 Binary files /dev/null and b/docs/modules/torrents/share-as-torrent.png differ diff --git a/docs/modules/torrents/torrent-download-form.png b/docs/modules/torrents/torrent-download-form.png new file mode 100644 index 0000000..0c0a424 Binary files /dev/null and b/docs/modules/torrents/torrent-download-form.png differ diff --git a/docs/modules/torrents/torrents-page.png b/docs/modules/torrents/torrents-page.png new file mode 100644 index 0000000..bc8f667 Binary files /dev/null and b/docs/modules/torrents/torrents-page.png differ diff --git a/docs/modules/torrents/vpn-settings.png b/docs/modules/torrents/vpn-settings.png new file mode 100644 index 0000000..eaad437 Binary files /dev/null and b/docs/modules/torrents/vpn-settings.png differ diff --git a/docs/modules/torrents/vpn.md b/docs/modules/torrents/vpn.md new file mode 100644 index 0000000..8d1a540 --- /dev/null +++ b/docs/modules/torrents/vpn.md @@ -0,0 +1,91 @@ +# The VPN for Torrents + +[Torrents](index.md) only reach the Internet through a VPN. Torrent peers see each other's addresses, so without a VPN +anyone sharing the same torrent sees your home's address. With the VPN, they see your VPN provider's address instead. + +The VPN only carries torrents. The rest of WROLPi (downloads, upgrades, the Controller) uses your normal Internet +connection. + +## Setting Up the VPN + +You need an account with a VPN provider, and a WireGuard (`.conf`) or OpenVPN (`.ovpn`) config file from it. Most +providers offer these on their website, for use on routers or Linux. + +> To set up the VPN, click **Admin**, then **Control**, and find the **VPN** section. The **VPN settings** link on the +> Torrents page opens it. + +![VPN Settings](vpn-settings.png) + +1. Click **Upload VPN Config**, and choose the file from your VPN provider. +2. If it is an OpenVPN config which needs a login, enter your provider's VPN username and password, and click + **Save Login**. (These are usually not your account's login; providers list them with their OpenVPN configs.) +3. Choose the [Port forwarding](#port-forwarding) your provider offers, and click **Save**. +4. Check **Turn on the VPN**. + +The status shows **Connected**, and the address peers see, once the VPN is up. The same settings are on the +[Controller](../../controller/index.md)'s own page. + +**Replace VPN Config** uploads a new file in place of the old one (for example, to use another server). **Remove** +deletes the config and the login, and turns the VPN off. + +### What Configs Work + +* **WireGuard**: any config with an `[Interface]` (PrivateKey and Address) and at least one `[Peer]` (PublicKey and + Endpoint). Commands in the config (`PostUp`, `PreDown`, etc.) are ignored. +* **OpenVPN**: TUN configs whose certificates and keys are inside the file (``, ``, `` blocks), as + providers' downloadable configs usually are. Configs which run scripts, use a proxy, or use TAP are refused, and + WROLPi says why. + +## Port Forwarding + +Torrent peers connect to each other. Without port forwarding, your WROLPi can only connect *out* to peers: you can +download, and upload to peers who accept connections, but peers behind their own firewalls (many home users) cannot +connect to you. The Torrents page shows this as **Firewalled**. + +To seed to everyone, your VPN provider must forward a port to your WROLPi. Choose the mode your provider offers: + +| Mode | When to use it | +|----------|----------------------------------------------------------------------------------------------------------------------| +| None | Your provider does not forward ports. Torrents work, but are firewalled. | +| Fixed | Your provider forwards a port you chose on their website. Enter that port. | +| NAT-PMP | Your provider gives a port to whoever asks (NAT-PMP). WROLPi asks for one, keeps it, and shows it in the status. | + +Providers change what they offer; check your provider's website. At the time of writing: + +| Provider | Port forwarding | How | +|--------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Proton VPN | NAT-PMP | Use a P2P server. For WireGuard, turn on NAT-PMP (port forwarding) when making the config. For OpenVPN, add `+pmp` to your OpenVPN username (e.g. `name+pmp`). | +| AirVPN | Fixed | Choose a port in AirVPN's Client Area, and enter it in WROLPi. | +| Mullvad, IVPN | None | Both stopped offering port forwarding in 2023. | +| Others | Varies | A provider which forwards a port through its own app, or changes the port every session, works with **None** only. | + +## Fail-Closed + +The VPN is fail-closed: torrents can only reach the Internet through it. If the VPN disconnects, cannot connect, is +turned off, or its config is removed, torrents stop; they never fall back to your WROLPi's own Internet connection. +Through the VPN, nothing from the Internet reaches your WROLPi except the forwarded port, and only the torrent client +listens on it. + +When you have torrents and the VPN is not connected, a warning icon appears in the navigation bar. It opens the VPN +settings. + +WROL Mode turns the VPN off. + +## What the VPN Does Not Protect + +The VPN hides your address from torrent peers and trackers. It does not: + +* Hide what you share. Anyone with a torrent's magnet link can see what it contains, and download it. +* Make you anonymous to your VPN provider, which can see your traffic's destinations. Choose a provider you trust. +* Protect the rest of your network. Only torrents use the VPN. +* Keep a forwarded port private. Anyone on the Internet can connect to the torrent client through it. The torrent client + runs without privileges and cannot change WROLPi's config, but it can read and write your library. Keep your WROLPi + upgraded so it has the torrent client's latest security fixes. + +## Where the VPN is Kept + +The VPN config and login are kept in `config/vpn/`, and its settings in the `vpn` section of `controller.yaml`. WROLPi +never serves `config/vpn/` on your network, and a [secondary WROLPi](../../system/sync.md) does not copy it. + +On a Raspberry Pi or Debian, the VPN is the `wrolpi-vpn` service and the torrent client is the `wrolpi-torrent` +service; see [Services](../../system/systemd.md). In Docker, both are in the `vpn` container. diff --git a/docs/system/configs.md b/docs/system/configs.md index 6471c93..f3ed0c2 100644 --- a/docs/system/configs.md +++ b/docs/system/configs.md @@ -33,7 +33,9 @@ All configs are stored in the `config` directory of your media directory: `/medi | `recently_viewed.yaml` | Your 1,000 most recently viewed files, and [where you left off](viewing-progress.md) in each. | | `inventory/*.yaml` | One file per [Inventory](../modules/inventory/index.md), plus the food catalog. | | `cookies.txt.enc` | Your [encrypted cookies](../modules/videos/cookies.md). | -| `controller.yaml` | [Controller](../controller/index.md) settings: drives, Samba shares, hotspot. | +| `controller.yaml` | [Controller](../controller/index.md) settings: drives, Samba shares, hotspot, the [VPN](../modules/torrents/vpn.md). | +| `torrents/` | One `.yaml` per [Torrent](../modules/torrents/index.md), with its `.torrent` file. | +| `vpn/` | The [VPN](../modules/torrents/vpn.md)'s config file and login. Never served on your network, nor copied to a secondary. | | `fstab.yaml` | The WROLPi-managed mount table for your drives. | | `backup/` | Automatic dated backups of your configs (see below). | | `ssl/` | Your generated [HTTPS certificates](certificates.md). | diff --git a/docs/system/systemd.md b/docs/system/systemd.md index 75b72b5..29b3203 100644 --- a/docs/system/systemd.md +++ b/docs/system/systemd.md @@ -20,6 +20,8 @@ For advanced users or scripting, services can be controlled directly with these | Zim | `systemctl status wrolpi-kiwix` | `journalctl -u wrolpi-kiwix` | `systemctl restart wrolpi-kiwix` | `systemctl stop wrolpi-kiwix` | `systemctl start wrolpi-kiwix` | | Caddy | `systemctl status caddy` | `journalctl -u caddy` | `systemctl restart caddy` | `systemctl stop caddy` | `systemctl start caddy` | | Help | `systemctl status wrolpi-help` | `journalctl -u wrolpi-help` | `systemctl restart wrolpi-help` | `systemctl stop wrolpi-help` | `systemctl start wrolpi-help` | +| [VPN](../modules/torrents/vpn.md) | `systemctl status wrolpi-vpn` | `journalctl -u wrolpi-vpn` | `systemctl restart wrolpi-vpn` | `systemctl stop wrolpi-vpn` | `systemctl start wrolpi-vpn` | +| [Torrents](../modules/torrents/index.md) | `systemctl status wrolpi-torrent` | `journalctl -u wrolpi-torrent` | `systemctl restart wrolpi-torrent` | `systemctl stop wrolpi-torrent` | `systemctl start wrolpi-torrent` | The SQLite database is a file under `/media/wrolpi/config/` — there is no database systemd service. Maps are served by Caddy from PMTiles files (no map rendering service).