libs/core: fix nil access, implement luci.model.network.network.uptime()
This commit is contained in:
parent
de3ea4e956
commit
9d83aafb78
1 changed files with 10 additions and 0 deletions
|
@ -481,6 +481,7 @@ function network.ifname(self)
|
|||
elseif self:is_virtual() then
|
||||
return p .. "-" .. self.sid
|
||||
else
|
||||
local num = { }
|
||||
local dev = self:_get("ifname") or
|
||||
uci_r:get("network", self.sid, "ifname")
|
||||
|
||||
|
@ -525,6 +526,15 @@ function network.name(self)
|
|||
return self.sid
|
||||
end
|
||||
|
||||
function network.uptime(self)
|
||||
local cnt = tonumber(uci_s:get("network", self.sid, "connect_time"))
|
||||
if cnt ~= nil then
|
||||
return nxo.sysinfo().uptime - cnt
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
function network.is_bridge(self)
|
||||
return (self:type() == "bridge")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue