autocore: ethinfo: fix panic issue

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2022-10-25 17:58:41 +08:00
parent f6c4028e51
commit 08b6c139d5
No known key found for this signature in database
GPG Key ID: 6850B6345C862176

View File

@ -12,13 +12,13 @@ for ifname, stat in pairs(util.ubus("network.device", "status")) do
status = stat.carrier and "yes" or "no"
if stat.speed:sub(1, 1) == "-" then
if not stat.carrier or not stat.speed or stat.speed:sub(1, 1) == "-" then
speed = "-"
else
speed = stat.speed:sub(1, -2) .. "Mb/s"
end
if not stat.carrier then
if speed == '-' then
duplex = "-"
elseif stat.speed:sub(-1) == "F" then
duplex = "Full"