Apart from replacing a patch for the former by two patches for latter, this involved minimal adaptations of the lua scripts in the following packages: * gluon-announce * gluon-announced * gluon-mesh-batman-adv-core * gluon-status-page
34 lines
685 B
Lua
34 lines
685 B
Lua
local announce = require 'gluon.announce'
|
|
local deflate = require 'deflate'
|
|
local json = require 'luci.jsonc'
|
|
|
|
|
|
local function collect(type)
|
|
return announce.collect_dir('/lib/gluon/announce/' .. type .. '.d')
|
|
end
|
|
|
|
|
|
module('gluon.announced', package.seeall)
|
|
|
|
function handle_request(query)
|
|
if query:match('^nodeinfo$') then
|
|
return json.stringify(collect('nodeinfo'))
|
|
end
|
|
|
|
local m = query:match('^GET ([a-z ]+)$')
|
|
if m then
|
|
local data = {}
|
|
|
|
for q in m:gmatch('([a-z]+)') do
|
|
local ok, val = pcall(collect, q)
|
|
if ok then
|
|
data[q] = val
|
|
end
|
|
end
|
|
|
|
if next(data) then
|
|
return deflate.compress(json.stringify(data))
|
|
end
|
|
end
|
|
end
|