diff --git a/package/gluon-mesh-batman-adv-core/files/lib/gluon/announce/nodeinfo.d/network/mesh/bat0/interfaces b/package/gluon-mesh-batman-adv-core/files/lib/gluon/announce/nodeinfo.d/network/mesh/bat0/interfaces new file mode 100644 index 00000000..97180b81 --- /dev/null +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/announce/nodeinfo.d/network/mesh/bat0/interfaces @@ -0,0 +1,52 @@ +local list = util.exec('batctl if') + +local wireless = {} +local tunnel = {} +local other = {} + +local function get_address(t, ifname) + pcall( + function() + table.insert(t, util.trim(fs.readfile('/sys/class/net/' .. ifname .. '/address'))) + end + ) +end + +local function is_wireless(ifname) + local type = fs.stat('/sys/class/net/' .. ifname .. '/wireless', 'type') + + return type == 'directory' +end + +local function is_tuntap(ifname) + local type = fs.stat('/sys/class/net/' .. ifname .. '/tun_flags', 'type') + + return type == 'regular' +end + +local function nil_table(t) + if next(t) ~= nil then + return t + else + return nil + end +end + +for _, line in ipairs(util.split(list)) do + local ifname = line:match('^(.-):') + if ifname ~= nil then + if is_wireless(ifname) then + get_address(wireless, ifname) + elseif is_tuntap(ifname) then + get_address(tunnel, ifname) + else + get_address(other, ifname) + end + end +end + +return { + wireless = nil_table(wireless), + tunnel = nil_table(tunnel), + other = nil_table(other) +} diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status index 23e612d3..771bdaba 100755 --- a/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status +++ b/package/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status @@ -22,9 +22,23 @@ function neighbours(ifname) for _, line in ipairs(util.split(info)) do local data = json.decode(line) if data then - if data["network"] and data["network"]["mesh_interfaces"] then - for _, mac in ipairs(data["network"]["mesh_interfaces"]) do - macs[mac] = data + local function add_macs(list) + if list then + for _, mac in ipairs(list) do + macs[mac] = data + end + end + end + + if data["network"] then + add_macs(data["network"]["mesh_interfaces"]) + + if data["network"]["mesh"] and data["network"]["mesh"]["bat0"] and + data["network"]["mesh"]["bat0"]["interfaces"] then + local interfaces = data["network"]["mesh"]["bat0"]["interfaces"] + add_macs(interfaces["other"]) + add_macs(interfaces["wireless"]) + add_macs(interfaces["tunnel"]) end end end