mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 07:56:18 -05:00
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:
parent
91f92683ba
commit
6bea09600e
17 changed files with 772 additions and 15 deletions
|
|
@ -92,7 +92,7 @@ class TestHotspotSettingsEndpoint:
|
|||
response = test_client.get("/api/hotspot/settings")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"device": "wlan0", "ssid": "WROLPi", "password": "wrolpi hotspot",
|
||||
"protocol": "wpa2"}
|
||||
"protocol": "wpa2", "captive_portal": True, "restart_required": False}
|
||||
|
||||
def test_post_settings(self, test_client, mock_config_path):
|
||||
"""Should update settings and persist them to controller.yaml."""
|
||||
|
|
@ -102,10 +102,18 @@ class TestHotspotSettingsEndpoint:
|
|||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"device": "wlp2s0", "ssid": "RafaelPi", "password": "password123",
|
||||
"protocol": "wpa3"}
|
||||
"protocol": "wpa3", "captive_portal": True, "restart_required": False}
|
||||
assert "wlp2s0" in mock_config_path.read_text()
|
||||
assert "wpa3" in mock_config_path.read_text()
|
||||
|
||||
def test_post_captive_portal(self, test_client, mock_config_path):
|
||||
"""The captive portal toggle round-trips and is persisted."""
|
||||
response = test_client.post("/api/hotspot/settings", json={"captive_portal": False})
|
||||
assert response.status_code == 200
|
||||
assert response.json()["captive_portal"] is False
|
||||
assert "captive_portal: false" in mock_config_path.read_text()
|
||||
assert test_client.get("/api/hotspot/settings").json()["captive_portal"] is False
|
||||
|
||||
def test_post_rejects_short_password(self, test_client, mock_config_path):
|
||||
"""Should reject a password shorter than 8 characters."""
|
||||
response = test_client.post("/api/hotspot/settings", json={"password": "short"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue