From 64d899d971e5518a861b630831162aea37bcf182 Mon Sep 17 00:00:00 2001 From: benya Date: Sun, 8 Feb 2026 03:07:15 +0300 Subject: [PATCH] Increase OpenWrt SSH timeouts --- services/openwrt.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/services/openwrt.py b/services/openwrt.py index d2862e9..b6d366d 100644 --- a/services/openwrt.py +++ b/services/openwrt.py @@ -207,10 +207,12 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: async def _ssh_cmd(cmd: str) -> tuple[int, str]: run = ssh_cmd + ["sh", "-c", cmd] - return await run_cmd(run, timeout=timeout_sec + 5) + return await run_cmd(run, timeout=timeout_sec + 15) sys_info = None rc, out = await _ssh_cmd("ubus call system info 2>/dev/null") + if rc == 124: + return "⚠️ OpenWrt SSH error (system info): timeout" if rc == 0 and out.strip(): try: sys_info = json.loads(out) @@ -218,6 +220,8 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: sys_info = None if sys_info is None: rc_u, out_u = await _ssh_cmd("cat /proc/uptime; echo; cat /proc/loadavg") + if rc_u == 124: + return "⚠️ OpenWrt SSH error (uptime/load): timeout" if rc_u != 0: return f"⚠️ OpenWrt SSH error: {out_u.strip() or 'unknown error'}" fallback_raw = out_u @@ -225,6 +229,8 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: fallback_raw = "" rc, out = await _ssh_cmd("ubus call network.interface.wan status 2>/dev/null") + if rc == 124: + return "⚠️ OpenWrt SSH error (wan status): timeout" if rc == 0 and out.strip(): try: wan_status = json.loads(out) @@ -234,6 +240,8 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: wan_status = {} rc, out = await _ssh_cmd("ubus call network.wireless status 2>/dev/null") + if rc == 124: + return "⚠️ OpenWrt SSH error (wireless status): timeout" if rc == 0 and out.strip(): try: wireless = json.loads(out) @@ -243,6 +251,8 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: wireless = {} rc, out = await _ssh_cmd("ubus call luci-rpc getDHCPLeases '{\"family\":4}' 2>/dev/null") + if rc == 124: + return "⚠️ OpenWrt SSH error (dhcp leases): timeout" if rc == 0 and out.strip(): try: leases = json.loads(out) @@ -251,6 +261,8 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: else: leases = None rc_l, out_l = await _ssh_cmd("cat /tmp/dhcp.leases 2>/dev/null || true") + if rc_l == 124: + return "⚠️ OpenWrt SSH error (leases fallback): timeout" if rc_l == 0: leases_fallback = out_l else: @@ -276,7 +288,9 @@ async def get_openwrt_status(cfg: dict[str, Any]) -> str: "-c", f"ubus call hostapd.{ifname} get_clients 2>/dev/null || echo '{{}}'", ] - rc2, out2 = await run_cmd(cmd_clients, timeout=timeout_sec + 5) + rc2, out2 = await run_cmd(cmd_clients, timeout=timeout_sec + 15) + if rc2 == 124: + return f"⚠️ OpenWrt SSH error (wifi clients {ifname}): timeout" if rc2 == 0 and out2.strip(): wifi_clients.extend(_parse_hostapd_clients(out2.strip(), ifname))