Merge dcb32b460b
into d0831aa83a
This commit is contained in:
commit
cf66c3a293
@ -1,13 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/lua
|
||||||
|
local mesh = require 'gluon.mesh'
|
||||||
|
local querystring = os.getenv("QUERY_STRING")
|
||||||
|
|
||||||
badrequest() {
|
print('Access-Control-Allow-Origin: *\n')
|
||||||
echo 'Status: 400 Bad Request'
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo 'Access-Control-Allow-Origin: *'
|
for interface, _ in pairs(mesh.interfaces()) do
|
||||||
|
if querystring
|
||||||
|
then
|
||||||
|
if string.find(interface, querystring)
|
||||||
|
then
|
||||||
|
os.execute("/usr/bin/gluon-neighbour-info -s neighbour -i " .. querystring .. " -d ff02::2:1001 -p 1001 -r nodeinfo");
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest
|
print("Status: 400 Bad Request\n")
|
||||||
|
os.exit(1)
|
||||||
exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo
|
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/lua
|
||||||
|
local mesh = require 'gluon.mesh'
|
||||||
|
local querystring = os.getenv("QUERY_STRING")
|
||||||
|
|
||||||
badrequest() {
|
print('Access-Control-Allow-Origin: *\n')
|
||||||
echo 'Status: 400 Bad Request'
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo 'Access-Control-Allow-Origin: *'
|
for interface, _ in pairs(mesh.interfaces()) do
|
||||||
|
if querystring
|
||||||
|
then
|
||||||
|
if string.find(interface, querystring)
|
||||||
|
then
|
||||||
|
os.execute("/usr/sbin/sse-multiplex /lib/gluon/status-page/providers/stations " .. querystring );
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest
|
|
||||||
|
|
||||||
CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'"
|
print("Status: 400 Bad Request\n")
|
||||||
|
os.exit(1)
|
||||||
exec /usr/sbin/sse-multiplex "$CMD"
|
|
||||||
|
@ -3,16 +3,14 @@
|
|||||||
util = require 'luci.util'
|
util = require 'luci.util'
|
||||||
json = require 'luci.jsonc'
|
json = require 'luci.jsonc'
|
||||||
fs = require 'nixio.fs'
|
fs = require 'nixio.fs'
|
||||||
|
mesh = require 'gluon.mesh'
|
||||||
|
|
||||||
io.write("Access-Control-Allow-Origin: *\n")
|
io.write("Access-Control-Allow-Origin: *\n")
|
||||||
io.write("Content-type: application/json\n\n")
|
io.write("Content-type: application/json\n\n")
|
||||||
|
|
||||||
list = util.exec('batctl if')
|
|
||||||
|
|
||||||
interfaces = {}
|
interfaces = {}
|
||||||
|
|
||||||
for _, line in ipairs(util.split(list)) do
|
for interface, _ in ipairs(mesh.interfaces()) do
|
||||||
ifname = line:match('^(.-):')
|
|
||||||
if ifname ~= nil then
|
if ifname ~= nil then
|
||||||
pcall(function()
|
pcall(function()
|
||||||
local address = util.trim(fs.readfile('/sys/class/net/' .. ifname .. '/address'))
|
local address = util.trim(fs.readfile('/sys/class/net/' .. ifname .. '/address'))
|
||||||
|
Loading…
Reference in New Issue
Block a user