captive portal: address review

* React: re-read the hotspot address whenever the HotspotToggle starts or
  stops the hotspot, matching the fallback UI's refresh-on-status.
* A WPA3 start that reverts to WPA2 leaves the hotspot up, so it now gets
  the captive portal address correction too.
* The corrective `nmcli connection up` logs a warning on a non-zero exit;
  dnsmasq would otherwise keep the old address silently.
* HotspotStatusResponse.captive_portal defaults to true like everywhere else.
* Trim design narrative from the module docstring and React comments.
* The include-before-activate test now observes the include at the moment
  of the `nmcli ... hotspot` call instead of inferring from call order.

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

View file

@ -530,6 +530,8 @@ def start_hotspot() -> dict:
capture_output=True, text=True, timeout=30,
)
if revert_modify.returncode == 0 and revert_up.returncode == 0:
# The hotspot is up (as WPA2), so it still needs its captive portal address.
_fix_captive_portal_ip(device)
return {"success": False,
"error": f"WPA3 is not supported by {device}; hotspot reverted to WPA2: {error}"}
revert_error = (revert_modify.stderr if revert_modify.returncode != 0 else revert_up.stderr).strip()
@ -572,7 +574,10 @@ def _fix_captive_portal_ip(device: str):
if not captive_portal_lib.apply_dnsmasq_config(ip):
return
try:
subprocess.run(["nmcli", "connection", "up", "Hotspot"], capture_output=True, text=True, timeout=30)
up = subprocess.run(["nmcli", "connection", "up", "Hotspot"], capture_output=True, text=True, timeout=30)
if up.returncode != 0:
logger.warning("Could not re-activate hotspot for captive portal; dnsmasq still serves the old"
" address: %s", up.stderr.strip())
except (subprocess.SubprocessError, FileNotFoundError) as e:
logger.warning("Could not re-activate hotspot for captive portal: %s", e)