modules/freifunk: Remove olsrd infos from status.json
This commit is contained in:
parent
c2f99c27aa
commit
6cd01c013a
1 changed files with 0 additions and 51 deletions
|
@ -105,55 +105,6 @@ function index()
|
||||||
entry({"admin", "freifunk", "profile_error"}, template("freifunk/profile_error"))
|
entry({"admin", "freifunk", "profile_error"}, template("freifunk/profile_error"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fetch_olsrd()
|
|
||||||
local sys = require "luci.sys"
|
|
||||||
local util = require "luci.util"
|
|
||||||
local table = require "table"
|
|
||||||
local rawdata = sys.httpget("http://127.0.0.1:2006/")
|
|
||||||
|
|
||||||
if #rawdata == 0 then
|
|
||||||
if nixio.fs.access("/proc/net/ipv6_route", "r") then
|
|
||||||
rawdata = sys.httpget("http://[::1]:2006/")
|
|
||||||
if #rawdata == 0 then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local data = {}
|
|
||||||
|
|
||||||
local tables = util.split(util.trim(rawdata), "\r?\n\r?\n", nil, true)
|
|
||||||
|
|
||||||
|
|
||||||
for i, tbl in ipairs(tables) do
|
|
||||||
local lines = util.split(tbl, "\r?\n", nil, true)
|
|
||||||
local name = table.remove(lines, 1):sub(8)
|
|
||||||
local keys = util.split(table.remove(lines, 1), "\t")
|
|
||||||
local split = #keys - 1
|
|
||||||
|
|
||||||
data[name] = {}
|
|
||||||
|
|
||||||
for j, line in ipairs(lines) do
|
|
||||||
local fields = util.split(line, "\t", split)
|
|
||||||
data[name][j] = {}
|
|
||||||
for k, key in pairs(keys) do
|
|
||||||
data[name][j][key] = fields[k]
|
|
||||||
end
|
|
||||||
|
|
||||||
if data[name][j].Linkcost then
|
|
||||||
data[name][j].LinkQuality,
|
|
||||||
data[name][j].NLQ,
|
|
||||||
data[name][j].ETX =
|
|
||||||
data[name][j].Linkcost:match("([%w.]+)/([%w.]+)[%s]+([%w.]+)")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return data
|
|
||||||
end
|
|
||||||
|
|
||||||
function zeroes()
|
function zeroes()
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
local http = require "luci.http"
|
local http = require "luci.http"
|
||||||
|
@ -244,8 +195,6 @@ function jsonstatus()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
root.olsrd = fetch_olsrd()
|
|
||||||
|
|
||||||
http.prepare_content("application/json")
|
http.prepare_content("application/json")
|
||||||
ltn12.pump.all(json.Encoder(root):source(), http.write)
|
ltn12.pump.all(json.Encoder(root):source(), http.write)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue