Fix OpenWrt Wi-Fi client discovery

This commit is contained in:
2026-02-08 03:23:35 +03:00
parent e36bf49f1c
commit 8cec8ae53e

View File

@@ -124,6 +124,16 @@ def _extract_ifnames(wireless: dict[str, Any]) -> list[str]:
return ifnames
def _extract_hostapd_ifnames(raw: str) -> list[str]:
ifnames: list[str] = []
for line in raw.splitlines():
name = line.strip()
if not name or name == "hostapd":
continue
ifnames.append(name)
return ifnames
def _safe_json_load(raw: str) -> Any | None:
if not raw:
return None
@@ -263,6 +273,13 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str:
wifi_clients = _extract_wifi_clients(wireless)
ifnames = _extract_ifnames(wireless)
rc_l, out_l = await run_cmd_full(
ssh_cmd + ["sh", "-c", "ubus -S list | awk -F. '/^hostapd\\.phy/{print $2}'"],
timeout=timeout_sec + 15,
)
if rc_l == 0 and out_l.strip():
ifnames.extend(_extract_hostapd_ifnames(out_l))
ifnames = sorted({name for name in ifnames if name})
if ifnames:
for ifname in ifnames:
cmd_clients = ssh_cmd + [