* Map tiles for ATAK and iTAK
A new service, wrolpi-tiles (tiles/), draws WROLPi's map as 256 px raster
tiles from the map's PMTiles with MapLibre Native (mapli), so ATAK and iTAK
can use the map as a map source, and ATAK can download an area of it.
- Tiles are drawn in blocks of 4x4 (ATAK asks for tiles in quadtree order),
each block once however many requests wait on it, in render processes of
their own. Phones are served in turn.
- A tile is always a 200: blank where there is no map, or when it was not
drawn before ATAK's 5 second timeout. Five failed tiles in a row stop an
ATAK download, and a 401/403 stops the map source.
- Drawn tiles are kept in /var/cache/wrolpi-tiles, with a size cap and a
free-space floor; JPEG, about a seventh of a PNG.
- The basemap is the web map's (protomaps-themes-base, light), kept equal
to it by a Jest test. Unreadable map files and missing map fonts are
left out rather than failing every tile.
- Caddy serves it at /tiles/ over HTTPS and on port 8088 over plain HTTP
(a phone must trust WROLPi's CA for HTTPS). /tiles/wrolpi.xml is the
MOBAC map source to import.
- A separate service with lower CPU priority and a memory cap, so a phone
downloading an area cannot slow the API. Docker runs it from the api
image.
- The map page has an ATAK tab: the map source links, how to use them, and
what the tile service is doing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: bound PMTiles decompression before it happens
A few bytes of a downloaded map file could decompress to far more than the
cap, which was applied only afterwards. Decompress at most MAX_METADATA_SIZE,
as modules.map.pmtiles does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: never send a blank for a late tile; start render processes with the service
QA on a Pi 4 found the first tile after a start sent blank: starting the
render processes and the first draw took 4.5 s, past the deadline. A
downloader (ATAK's, iTAK's) keeps whatever a tile request returns, so a
blank sent for a late or failed tile is a hole in its offline map for
good. Such a tile is now a 503 (ATAK tries each tile twice; only 401 and
403 stop a map source), and the render processes start with the service.
Also:
- OOMScoreAdjust=500: Raspberry Pi OS disables the memory cgroup, so
MemoryMax does nothing there; the tile service is killed before the API.
- sanic-ext's auto extensions are off in the tile service.
- The map's ATAK tab is before Manage: Manage is the last tab.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: put backgroundColor back in the map source; iTAK requires it
iTAK refuses a MOBAC map source without <backgroundColor> ("The data couldn't
be read because it is missing"). ATAK ignores it. It is the map's own
background color.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: leave out the map files hidden on the Manage tab, as the web map does
maps.yaml's ignored_files names the map files the user hid; the web map
does not draw them, and the tiles drew them anyway.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: bound the render processes' memory and the tiles-per-second times
QA on a Pi 4, a phone taking 123,000 tiles offline: each render process
grew from about 270 MB to 370 MB (MapLibre keeps what it has read and
drawn) and did not shrink when idle. A render process is now replaced
after 2,000 blocks. The serve times behind tiles-per-second were only
forgotten when the status was asked for; they are forgotten as tiles are
served.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Map ATAK tab: iTAK takes an area offline too
An iPhone downloaded 123,000 tiles with iTAK and showed them offline with
none missing; the tab said only ATAK could.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Map ATAK tab: a button to clear the tiles the tile service keeps
POST /tiles/cache/clear on the tile service (which keeps the cache's size)
removes the kept tiles; they are drawn again when next asked for. The
button asks first, and says that maps already downloaded to phones are not
changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: measure the cache as the disk does; clear it at once, delete in the background
QA on a Pi 4 after a 123,000-tile download: the cache counted 375 MB of tile
bytes while its files took 660 MB of the SD card (each small file takes a
whole 4 KiB block), so the 1 GB cap allowed about 1.7 GB. The cache is now
measured in disk blocks.
Clearing deleted 128,000 files in the request: about 40 seconds, with the
Pi's load warning on. A clear (or a new style) now renames the tiles out of
the way at once and deletes them in a lowest-priority thread, pausing every
500 files; a deletion cut short is finished at the next start. A tile drawn
again no longer counts twice.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Help: ATAK and iTAK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: a page on port 8088 saying what it is
A person who finds port 8088 got a 404. / (and /tiles/) is now a short page:
WROLPi's map tile service for ATAK and iTAK, the map source to open on a
phone, and links to the WROLPi app and the map's ATAK tab, made from the
address the page was reached by (Docker publishes the app on
TILES_HTTPS_PORT). Port 8088 serves WROLPi's icon.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tiles: review fixes
- Caddy: a tile request is never redirected to the fallback page when the
tile service is down or restarting (handle_errors on 443). ATAK keeps
whatever a tile request ends with, so the page was stored as the tile;
it is now a 503 with Retry-After, which ATAK tries again.
- The cache's oldest tiles are found and deleted in a lowest-priority
thread, pausing as it goes, not in the tile request which filled it.
- ATAK tab: only the newest status request writes the status, so a slow
answer can not undo a newer one (or a clear). It says when the page was
opened on localhost and the addresses work only there, and names each
map source as the app lists it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* A secondary WROLPi copies its primary's library over HTTP
A WROLPi with role "secondary" pulls from its primary: a manifest of every
FileGroup's files (/api/sync/manifest), then each missing or changed file
from the primary's Caddy /media/ (resumable, written to a hidden partial and
renamed with the primary's mtime), a refresh, then the library configs,
imported as the primary wrote them. wrolpi.yaml contributes only its library
settings. Files deleted on the primary are kept.
A secondary never saves the synced configs and never downloads. Its API
answers 503 SYNCING while a sync runs, and every page warns that it is a
copy. It syncs in a daily window or on "Sync now"; WROL Mode stops it.
On a Pi 4 (no AES instructions) the client uses TLS 1.2 ChaCha20, which
pulls ~110 MB/s from Caddy versus ~41 MB/s for rsync over ssh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Sync has its own /admin tab; a sync's reads from the primary are bounded
The sync settings and progress move from Settings (and the component
gallery, which is for library components) to /admin/sync.
A download never writes past the size in the primary's manifest, and configs,
listings, and manifest pages are capped. A primary address may not carry a
user name or password (it is logged and shown). While a sync runs, the API
answers only the exact requests that show its progress or stop it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A sync keeps the secondary's replaced configs in today's config backup
The first copy of the day is kept, like a save, so a config backup import
undoes a sync's config changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Docker's Caddy logs every request
`docker compose logs -f web` shows each request with its status, size and
duration, e.g. a secondary's /media/ downloads during a sync.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A sync reports its progress as it downloads, and refuses quietly
The status updated only when a page of 500 FileGroups finished, so a page of
large files looked stuck; it now updates every 2 seconds. Requests refused
while syncing are answered by the middleware instead of raised, so the UI's
polling no longer logs an error each time. The primary's version is stored
without its trailing newline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A WROLPi can back up to a second drive; sync settings live in sync.yaml
The Sync tab's Backup Drive copies the media directory to a second mounted
drive with rsync during the sync window (hourly), or on "Back Up Now".
Nothing on the backup drive is deleted. The Tags and playlists directories
are left out (WROLPi rebuilds them from the configs), and the database is
written as an SQLite snapshot rather than copied as files, so the drive can be
mounted as the media directory and start. A backup is written only while the
chosen drive (by UUID) is mounted where it was chosen, and is not the media or
system drive; rsync is stopped if the drive disappears. Not in Docker, which
cannot reach other drives.
Role, primary, window and backup drive move from wrolpi.yaml to sync.yaml:
they belong to this machine, and are never copied from a primary.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The Sync tab shows the configured backup drive
getSettings copies each setting by name and did not list the backup drive,
so the Sync tab showed "None" while one was configured. It also dropped
`version`. A test now fails for any setting the API sends that getSettings
drops.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A backup can go to a folder on its drive, and remembers its last success
The Backup Drive panel takes a folder on the chosen drive. The drive is
checked through the folder's mount point: the folder is written only when the
drive with the saved UUID is mounted there, so a folder left on the system
drive by an unplugged drive, or on another drive mounted inside the chosen
one, is refused. A missing folder is created once the drive is checked.
When the last backup succeeded is saved in sync.yaml, so it is known after a
restart. "Stop Backup" is disabled while the database snapshot is written (it
runs to the end), and a finished backup clears the request to stop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The backup drive has its own window
The sync window was shown in the Sync panel but also scheduled the backup
drive. The Backup Drive panel now has its own window (sync.yaml
backup_window_start/end), saved with the drive; the sync window is shown,
and used, only for a secondary's sync.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Sync and the backup drive can each exclude folders
A secondary or a backup drive may be smaller than the primary's library.
Each Sync tab panel has its own excluded folders in sync.yaml, chosen in
a folder browser: a secondary browses its primary's folders (through
Caddy), the backup drive browses this WROLPi's media directory. Excluded
folders are never copied; what was copied before is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The folder browser does not offer lost+found
Every ext4 drive has a root-only lost+found folder; a sync and a backup
never copy it, so it is not offered for exclusion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A sync never writes into config or tags, whatever their case
On a media drive that ignores case (exFAT, NTFS, macOS), a manifest path
like Config/wrolpi.db is the real config folder. The protected and
unlisted top-level folders are now compared case-insensitively in the
manifest, in resolve_destination, in excluded-folder validation, and in
both folder listings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A backup writes the database snapshot only when the database changed
Every backup rewrote the whole database snapshot (2.5 GB on a busy
WROLPi), even on the window's idle hourly runs. The snapshot is now
skipped when the live database (its size and mtime, and those of a
non-empty WAL) and the drive's copy are both unchanged since the last
snapshot. The record is in memory, so the first backup after a restart
writes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Remove the unused save_sync_config switch
Nothing activated it; SyncConfig saves directly. The test server's
log_message override is called by http.server, so it goes in the
vulture baseline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Speed Test calculator: ping, download, and upload against the API
Users asking whether the hotspot is fast enough, or how many people can
stream video at once, had no objective tool that works offline. This
adds one under Calculators > Tools & Reference.
Backend (wrolpi/speedtest.py, /api/speedtest):
* ping: tiny no-store JSON the browser times for round trip latency.
* download: streams slices of a pre-built random buffer for a clamped
number of seconds (0.1-15). Random so no proxy or compression can
flatter the result; slices so no bytes are generated per request.
* upload: streaming-body handler that reads and discards the body and
reports bytes and elapsed time. Requests over 8 MiB are refused.
* info: the client address Caddy forwarded plus how many tests are in
flight. Sanic now trusts one proxy hop (PROXIES_COUNT = 1) so
request.remote_addr is the browser, not Caddy. Nothing else read
that field before.
There is deliberately no one-test-at-a-time lock. Several people
testing at once is how a user learns how the link shares between
streamers, so the server only counts in-flight tests (a shared_ctx
Value created pre-fork so every worker sees the same number) and the
UI reports how many others ran alongside.
Both Caddyfiles route /api/speedtest/* unbuffered, as the SSE chat
route already is, so throughput is measured live rather than in bursts.
Frontend:
* speedtest.js holds the logic with no React in it (bucketed
throughput, steady-state average that drops the first second, ping
stats, stream-capacity tiers, hotspot address check) so Jest drives
it with fake fetch and streams.
* SpeedTestCalculator runs 20 pings, a 10 s download, and a 10 s upload
with a live figure and rolling trace, then shows Mbps and MB/s, ping
verdict, the client address with a hotspot badge, and a table of how
many 480p..4K streams the download speed supports. Upload is
sequential POSTs of one 4 MiB Blob because Safari cannot stream a
request body. Nothing is saved.
* Sparkline is a new inline-SVG ui component (no chart dependency),
added to /theme-sample and checked in all four themes. A missing
sample is a gap, not a plunge to zero.
The page states that it measures the network path, not the drive that
actually serves video files.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* speedtest: bound uploads in time, close the Start race, address review
Review on #708 found three bugs and some polish:
* Start could be clicked again while the first fetchInfo() was still
pending, because the phase only left `idle` after that await. A
second click made a second AbortController and a second concurrent
run, and Cancel only reached the later one. start() now refuses when
a controller already exists and enters a `starting` phase
synchronously, so the button is Cancel before the first await.
* The upload phase could overrun the advertised 10 s by however long
the in-flight 4 MiB POST took: on a slow hotspot, the very link this
tool exists for, that is tens of seconds. runUpload() now aborts the
in-flight request at the phase deadline (counting only completed
requests) and uses 1 MiB bodies so a few-Mbps link still completes
several inside the phase.
* The server upload sink was capped by size only, so a slow or paused
body could hold a worker until 8 MiB eventually arrived. It now also
enforces MAX_UPLOAD_SECONDS (15 s, matching download) and answers
408 when exceeded. Both caps together are what "cannot hold a
worker" actually requires.
Also: a NaN `seconds` now gets a NaN message instead of "must not be
negative"; the module, Sparkline, and gallery docstrings are trimmed
to purpose; and the upload counter is covered for the mid-stream 413,
the 408, and a broken body.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Create a new Docs module that consolidates PDF and eBook handling into a
unified system with subjects and authors support. This replaces the
separate PDF/eBook modelers with a single Doc model backed by an
alembic migration (rename ebook to doc).
Key changes:
- New modules/docs package with models, API, extractors, and lib
- Subject and author metadata extraction with case-insensitive
normalization for cleaner PDF metadata
- Frontend Docs pages with AuthorsPage, SubjectsPage using
CollectionTable, and doc card deletion
- Global search integration for subjects and authors
- Generic collection item count support
- Frontend file card metadata adjusted to match collection sort
- Bump yt-dlp version
- Replace nginx with Caddy as the web server for both Docker and native
(RPi/Debian) deployments. Caddy handles HTTPS termination, reverse
proxying to all services (API, React app, Controller, Kiwix, Help, Map),
and serves the media/download file browsers.
- Generate a Root CA and signed leaf certificates for HTTPS. The Root CA
uses Name Constraints to restrict signing to local addresses only
(.local, localhost, and RFC 1918 private IP ranges), mitigating MITM
risk if the CA key is compromised.
- Add an HTTP landing page that guides users through one-time CA
certificate installation on iOS, Android, macOS, Windows, Linux, and
Firefox, with auto-redirect when the cert is already trusted.
- Add trailing-slash redirects for /controller, /docs, /media, and
/download so bare paths don't fall through to the React catch-all.
- Add a Root CA download link on the Settings page under Configs.
- Update help.sh diagnostics for IPv6 listener detection and HTTP/2
status codes.
- Remove all nginx config files and the https_proxy Docker container.
- Bump wrolpi-help submodule with certificate documentation.