libs/sys: fix parsing of model and cpu info, consider 2000::/3 as IPv6 default route if no ::/0 route exists (#200)
This commit is contained in:
parent
f04acc4b94
commit
68b51e1527
1 changed files with 22 additions and 11 deletions
|
@ -171,23 +171,23 @@ function sysinfo()
|
||||||
local cpuinfo = fs.readfile("/proc/cpuinfo")
|
local cpuinfo = fs.readfile("/proc/cpuinfo")
|
||||||
local meminfo = fs.readfile("/proc/meminfo")
|
local meminfo = fs.readfile("/proc/meminfo")
|
||||||
|
|
||||||
local system = cpuinfo:match("system typ.-:%s*([^\n]+)")
|
|
||||||
local model = ""
|
|
||||||
local memtotal = tonumber(meminfo:match("MemTotal:%s*(%d+)"))
|
local memtotal = tonumber(meminfo:match("MemTotal:%s*(%d+)"))
|
||||||
local memcached = tonumber(meminfo:match("\nCached:%s*(%d+)"))
|
local memcached = tonumber(meminfo:match("\nCached:%s*(%d+)"))
|
||||||
local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)"))
|
local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)"))
|
||||||
local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)"))
|
local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)"))
|
||||||
local bogomips = tonumber(cpuinfo:match("BogoMIPS.-:%s*([^\n]+)"))
|
local bogomips = tonumber(cpuinfo:match("BogoMIPS.-:%s*([^\n]+)"))
|
||||||
|
|
||||||
if not system then
|
local system =
|
||||||
system = nixio.uname().machine
|
cpuinfo:match("system type\t+: ([^\n]+)") or
|
||||||
model = cpuinfo:match("model name.-:%s*([^\n]+)")
|
cpuinfo:match("Processor\t+: ([^\n]+)") or
|
||||||
if not model then
|
cpuinfo:match("model name\t+: ([^\n]+)")
|
||||||
model = cpuinfo:match("Processor.-:%s*([^\n]+)")
|
|
||||||
end
|
local model =
|
||||||
else
|
cpuinfo:match("machine\t+: ([^\n]+)") or
|
||||||
model = cpuinfo:match("cpu model.-:%s*([^\n]+)")
|
cpuinfo:match("Hardware\t+: ([^\n]+)") or
|
||||||
end
|
fs.readfile("/proc/diag/model") or
|
||||||
|
nixio.uname().machine() or
|
||||||
|
system
|
||||||
|
|
||||||
return system, model, memtotal, memcached, membuffers, memfree, bogomips
|
return system, model, memtotal, memcached, membuffers, memfree, bogomips
|
||||||
end
|
end
|
||||||
|
@ -307,6 +307,17 @@ function net.defaultroute6()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if not route then
|
||||||
|
local global_unicast = luci.ip.IPv6("2000::/3")
|
||||||
|
net.routes6(function(rt)
|
||||||
|
if rt.dest:equal(global_unicast) and
|
||||||
|
(not route or route.metric > rt.metric)
|
||||||
|
then
|
||||||
|
route = rt
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
return route
|
return route
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue