123456789101112131415161718192021222324 |
- #!/usr/bin/lua
- util = require 'luci.util'
- json = require 'luci.jsonc'
- fs = require 'nixio.fs'
- io.write("Access-Control-Allow-Origin: *\n")
- io.write("Content-type: application/json\n\n")
- list = util.exec('batctl if')
- interfaces = {}
- for _, line in ipairs(util.split(list)) do
- ifname = line:match('^(.-):')
- if ifname ~= nil then
- pcall(function()
- local address = util.trim(fs.readfile('/sys/class/net/' .. ifname .. '/address'))
- interfaces[ifname] = { address = address }
- end)
- end
- end
- io.write(json.stringify(interfaces))
|