applications/luci-olsr: General code cleanup, thanks patrick at lunatiki dot de
This commit is contained in:
parent
8ee6d915ee
commit
50c69527e5
1 changed files with 74 additions and 63 deletions
|
@ -233,10 +233,20 @@ function fetch_txtinfo(otable)
|
|||
local data = {}
|
||||
local dataindex = 0
|
||||
local name = ""
|
||||
local defaultgw
|
||||
|
||||
if #rawdata ~= 0 then
|
||||
local tables = luci.util.split(luci.util.trim(rawdata), "\r?\n\r?\n", nil, true)
|
||||
|
||||
if otable == "links" then
|
||||
local route = {}
|
||||
for i, route in ipairs(luci.sys.net.routes()) do
|
||||
if route.dest:prefix() == 0 then
|
||||
defaultgw = route.gateway:string()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i, tbl in ipairs(tables) do
|
||||
local lines = luci.util.split(tbl, "\r?\n", nil, true)
|
||||
name = table.remove(lines, 1):sub(8)
|
||||
|
@ -253,12 +263,15 @@ function fetch_txtinfo(otable)
|
|||
data[name][di] = {}
|
||||
for k, key in pairs(keys) do
|
||||
if key == "Remote IP" or key == "Dest. IP" or key == "Gateway IP" or key == "Gateway" then
|
||||
data[name][di][key] = fields[k]
|
||||
hostname = nixio.getnameinfo(fields[k], "inet")
|
||||
if hostname then
|
||||
data[name][di][key] = fields[k]
|
||||
data[name][di]["Hostname"] = hostname
|
||||
else
|
||||
data[name][di][key] = fields[k]
|
||||
end
|
||||
if key == "Remote IP" and defaultgw then
|
||||
if defaultgw == fields[k] then
|
||||
data[name][di]["defaultgw"] = 1
|
||||
end
|
||||
end
|
||||
elseif key == "Local IP" then
|
||||
data[name][di][key] = fields[k]
|
||||
|
@ -310,12 +323,10 @@ function fetch_txtinfo(otable)
|
|||
data[name][di] = {}
|
||||
for k, key in pairs(keys) do
|
||||
if key == "Remote IP" then
|
||||
data[name][di][key] = "[" .. fields[k] .. "]"
|
||||
hostname = nixio.getnameinfo(fields[k], "inet6")
|
||||
if hostname then
|
||||
data[name][di][key] = "[" .. fields[k] .. "]"
|
||||
data[name][di]["Hostname"] = hostname
|
||||
else
|
||||
data[name][di][key] = "[" .. fields[k] .. "]"
|
||||
end
|
||||
elseif key == "Local IP" then
|
||||
data[name][di][key] = fields[k]
|
||||
|
|
Loading…
Reference in a new issue