libs/sys: protect iwinfo loading and return stub if module is not present
This commit is contained in:
parent
37ac71b816
commit
e291678012
1 changed files with 11 additions and 13 deletions
|
@ -624,7 +624,7 @@ wifi = {}
|
||||||
-- @param ifname String containing the interface name
|
-- @param ifname String containing the interface name
|
||||||
-- @return A wrapped iwinfo object instance
|
-- @return A wrapped iwinfo object instance
|
||||||
function wifi.getiwinfo(ifname)
|
function wifi.getiwinfo(ifname)
|
||||||
local iwinfo = require "iwinfo"
|
local stat, iwinfo = pcall(require, "iwinfo")
|
||||||
|
|
||||||
if ifname then
|
if ifname then
|
||||||
local c = 0
|
local c = 0
|
||||||
|
@ -652,9 +652,8 @@ function wifi.getiwinfo(ifname)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = iwinfo.type(ifname)
|
local t = stat and iwinfo.type(ifname)
|
||||||
if t then
|
local x = t and iwinfo[t] or { }
|
||||||
local x = iwinfo[t]
|
|
||||||
return setmetatable({}, {
|
return setmetatable({}, {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
if k == "ifname" then
|
if k == "ifname" then
|
||||||
|
@ -666,7 +665,6 @@ function wifi.getiwinfo(ifname)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--- Get iwconfig output for all wireless devices.
|
--- Get iwconfig output for all wireless devices.
|
||||||
-- @return Table of tables containing the iwconfing output for each wifi device
|
-- @return Table of tables containing the iwconfing output for each wifi device
|
||||||
|
|
Loading…
Reference in a new issue