Hotspot captive portal: welcome page with the WROLPi's address

Devices that join the hotspot probe a fixed plain-HTTP URL to check for
Internet access.  NetworkManager's shared-mode dnsmasq now resolves those
probe hostnames (and `wrolpi`) to the hotspot address via an include the
Controller writes when the hotspot starts, the probes land on the Controller
(port 80), and are redirected to /portal: "This is your WROLPi, its address is
10.42.0.1, open WROLPi / open the Controller".

Only the probe hostnames are hijacked so the hotspot keeps forwarding
everything else when the WROLPi has an uplink.  The include is corrected and
the connection re-activated once if NetworkManager picked a non-default
subnet.  Writing the include is best-effort; the hotspot starts regardless.

`hotspot.captive_portal` (controller.yaml, default true) toggles the probe
redirects and the include; like the other hotspot settings it applies on the
next hotspot start, so saving while the hotspot is up reports
restart_required and both Controller UIs say so.  The status endpoint gains
the hotspot address and portal URL, shown in both UIs.  repair.sh only
creates the include directory so a disabled setting survives upgrades.
Native only: Docker has no hotspot.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-09-13 19:09:12 -06:00
parent 91f92683ba
commit 6bea09600e
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
17 changed files with 772 additions and 15 deletions

View file

@ -57,6 +57,14 @@ def _isolate_media_directory(tmp_path_factory, monkeypatch):
monkeypatch.setenv("MEDIA_DIRECTORY", str(media_dir))
@pytest.fixture(autouse=True)
def _isolate_dnsmasq_include(tmp_path_factory, monkeypatch):
"""Point the captive-portal dnsmasq include at a temp file so tests never write /etc."""
import controller.lib.captive_portal as captive_portal
include = tmp_path_factory.mktemp("dnsmasq") / "50-wrolpi-captive-portal.conf"
monkeypatch.setattr(captive_portal, "INCLUDE_FILE", include)
@pytest.fixture(autouse=True)
def _patch_status_worker():
"""Replace the real status worker with a no-op for every test.