controller: selectable hotspot protocol (WPA2/WPA3) with device capability probing

Probe the selected WiFi device with iw to determine which hotspot
protocols it can host: WPA2 requires AP mode; WPA3 requires SAE in AP
mode (SAE_OFFLOAD_AP, or a mac80211 driver with the CMAC cipher for
software SAE).  The Raspberry Pi's brcmfmac supports neither, so Pis
correctly offer WPA2 only (verified against real Pi 4/Pi 5 iw output).

The protocol is saved as hotspot.protocol in controller.yaml.
enable_hotspot() now always sets the Hotspot connection's key-mgmt
explicitly (sae + required PMF for WPA3) so a reused profile cannot
keep a stale protocol, and reverts to WPA2 if the driver rejects SAE.

New GET /api/hotspot/protocols endpoint; protocol dropdowns added to
both the ControllerPage React UI and the fallback controller UI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-28 19:52:39 -06:00 • committed by lrnselfreliance
parent 2355095391
commit 8687816b84
10 changed files with 545 additions and 16 deletions

View file

@ -12,6 +12,7 @@ import {
getDisks,
getFstabEntries,
getHotspotDevices,
getHotspotProtocols,
getHotspotSettings,
getSambaStatus,
getServiceLogs,
@ -1410,10 +1411,17 @@ function SambaSection() {
}
// Human labels for the hotspot protocols reported by the Controller.
const hotspotProtocolLabels = {
wpa2: 'WPA2 (most compatible)',
wpa3: 'WPA3',
};
function HotspotSettingsForm() {
const dockerized = useDockerized();
const [devices, setDevices] = React.useState([]);
const [form, setForm] = React.useState({device: '', ssid: '', password: ''});
const [protocols, setProtocols] = React.useState([]);
const [form, setForm] = React.useState({device: '', ssid: '', password: '', protocol: ''});
const [loading, setLoading] = React.useState(true);
const [saving, setSaving] = React.useState(false);
const [qrOpen, setQrOpen] = React.useState(false);
@ -1422,7 +1430,12 @@ function HotspotSettingsForm() {
const fetchSettings = async () => {
try {
const [settings, devicesResponse] = await Promise.all([getHotspotSettings(), getHotspotDevices()]);
setForm({device: settings.device, ssid: settings.ssid, password: settings.password});
setForm({
device: settings.device,
ssid: settings.ssid,
password: settings.password,
protocol: settings.protocol,
});
setDevices(devicesResponse.devices || []);
} catch (e) {
console.error('Failed to fetch hotspot settings', e);
@ -1433,6 +1446,23 @@ function HotspotSettingsForm() {
fetchSettings();
}, []);
// The supported protocols depend on the selected device's hardware.
React.useEffect(() => {
if (!form.device) {
return;
}
const fetchProtocols = async () => {
try {
const response = await getHotspotProtocols(form.device);
setProtocols(response.protocols || []);
} catch (e) {
console.error('Failed to fetch hotspot protocols', e);
setProtocols([]);
}
};
fetchProtocols();
}, [form.device]);
const handleSave = async () => {
setSaving(true);
try {
@ -1461,6 +1491,10 @@ function HotspotSettingsForm() {
const deviceOptions = [...new Set([...devices, form.device].filter(Boolean))]
.map(device => ({key: device, value: device, text: device}));
// Keep the saved protocol selectable even if the device does not report it.
const protocolOptions = [...new Set([...protocols, form.protocol].filter(Boolean))]
.map(protocol => ({key: protocol, value: protocol, text: hotspotProtocolLabels[protocol] || protocol}));
// Special string which allows a mobile device to connect to a specific Wi-Fi.
// The WPA QR format requires backslash-escaping of \ ; , " in the SSID and password.
const escapeWifi = (s) => s.replace(/([\\;,"])/g, '\\$1');
@ -1494,6 +1528,15 @@ function HotspotSettingsForm() {
disabled={dockerized || saving}
onChange={(e, {value}) => setForm({...form, device: value})}
/>
<Form.Dropdown
selection
label='Hotspot Protocol'
placeholder='No protocols supported'
options={protocolOptions}
value={form.protocol}
disabled={dockerized || saving}
onChange={(e, {value}) => setForm({...form, protocol: value})}
/>
</Form.Group>
<Button
color='violet'