gluon-status-page: rework package to not depend on batman, introduce babel mesh protocol, move neighbors-batadv from statuspage-api to gluon-mesh-batmand-adv
This commit is contained in:
parent
4911da56e1
commit
f213485917
@ -13,7 +13,7 @@ define Package/gluon-mesh-batman-adv/common
|
|||||||
SECTION:=gluon
|
SECTION:=gluon
|
||||||
CATEGORY:=Gluon
|
CATEGORY:=Gluon
|
||||||
PROVIDES:=gluon-mesh-batman-adv
|
PROVIDES:=gluon-mesh-batman-adv
|
||||||
DEPENDS:=+gluon-core +libgluonutil +gluon-client-bridge +gluon-ebtables +firewall +libiwinfo +kmod-dummy +libnl-tiny +libbatadv
|
DEPENDS:=+gluon-core +libgluonutil +gluon-client-bridge +gluon-ebtables +firewall +libiwinfo +kmod-dummy +libnl-tiny +libbatadv +libjson-c
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/gluon-mesh-batman-adv-14
|
define Package/gluon-mesh-batman-adv-14
|
||||||
@ -43,6 +43,8 @@ define Package/gluon-mesh-batman-adv/common/install
|
|||||||
$(CP) ./files/* $(1)/
|
$(CP) ./files/* $(1)/
|
||||||
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
|
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
|
||||||
$(INSTALL_DIR) $(1)/lib/gluon/respondd
|
$(INSTALL_DIR) $(1)/lib/gluon/respondd
|
||||||
|
$(INSTALL_DIR) $(1)/lib/gluon/status-page/providers
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/neighbours-batadv $(1)/lib/gluon/status-page/providers/
|
||||||
$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/mesh-batman-adv.so
|
$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/mesh-batman-adv.so
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv
|
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
all: respondd.so
|
all: neighbours-batadv respondd.so
|
||||||
|
|
||||||
CFLAGS += -Wall
|
CFLAGS += -Wall
|
||||||
|
|
||||||
@ -9,6 +9,17 @@ ifeq ($(origin PKG_CONFIG), undefined)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(origin LIBJSONC_CFLAGS) $(origin LIBJSONC_LDLIBS), undefined undefined)
|
||||||
|
LIBJSONC_NAME ?= json-c
|
||||||
|
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBJSONC_NAME) 2>/dev/null),)
|
||||||
|
$(error No $(LIBJSONC_NAME) development libraries found!)
|
||||||
|
endif
|
||||||
|
LIBJSONC_CFLAGS += $(shell $(PkG_CONFIG) --cflags $(LIBJSONC_NAME))
|
||||||
|
LIBJSONC_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBJSONC_NAME))
|
||||||
|
endif
|
||||||
|
CFLAGS += $(LIBJSONC_CFLAGS)
|
||||||
|
LDLIBS += $(LIBJSONC_LDLIBS)
|
||||||
|
|
||||||
ifeq ($(origin LIBNL_CFLAGS) $(origin LIBNL_LDLIBS), undefined undefined)
|
ifeq ($(origin LIBNL_CFLAGS) $(origin LIBNL_LDLIBS), undefined undefined)
|
||||||
LIBNL_NAME ?= libnl-tiny
|
LIBNL_NAME ?= libnl-tiny
|
||||||
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBNL_NAME) 2>/dev/null),)
|
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBNL_NAME) 2>/dev/null),)
|
||||||
@ -33,3 +44,7 @@ LDLIBS += $(LIBBATADV_LDLIBS)
|
|||||||
|
|
||||||
respondd.so: respondd.c
|
respondd.so: respondd.c
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -liwinfo -luci
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -liwinfo -luci
|
||||||
|
|
||||||
|
neighbours-batadv: neighbours-batadv.c
|
||||||
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -D_GNU_SOURCE -o $@ $^ $(LDLIBS)
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ endef
|
|||||||
|
|
||||||
define Package/gluon-status-page-api/install
|
define Package/gluon-status-page-api/install
|
||||||
$(INSTALL_DIR) $(1)/lib/gluon/status-page/providers
|
$(INSTALL_DIR) $(1)/lib/gluon/status-page/providers
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/neighbours-batadv $(1)/lib/gluon/status-page/providers/
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/stations $(1)/lib/gluon/status-page/providers/
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/stations $(1)/lib/gluon/status-page/providers/
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/lib/gluon/respondd
|
$(INSTALL_DIR) $(1)/lib/gluon/respondd
|
||||||
|
0
package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv
Executable file → Normal file
0
package/gluon-status-page-api/files/lib/gluon/status-page/www/cgi-bin/dyn/neighbours-batadv
Executable file → Normal file
@ -8,6 +8,6 @@ badrequest() {
|
|||||||
|
|
||||||
echo 'Access-Control-Allow-Origin: *'
|
echo 'Access-Control-Allow-Origin: *'
|
||||||
|
|
||||||
batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest
|
ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" || badrequest
|
||||||
|
|
||||||
exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo
|
exec /usr/bin/gluon-neighbour-info -s neighbour -i "$QUERY_STRING" -d ff02::2:1001 -p 1001 -r nodeinfo
|
||||||
|
@ -8,7 +8,7 @@ badrequest() {
|
|||||||
|
|
||||||
echo 'Access-Control-Allow-Origin: *'
|
echo 'Access-Control-Allow-Origin: *'
|
||||||
|
|
||||||
batctl if | cut -d: -f1 | grep -qxF "$QUERY_STRING" || badrequest
|
ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"| grep -qxF "$QUERY_STRING" || badrequest
|
||||||
|
|
||||||
CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'"
|
CMD="exec /lib/gluon/status-page/providers/stations '$QUERY_STRING'"
|
||||||
|
|
||||||
|
@ -29,10 +29,7 @@ ifeq ($(origin LIBBATADV_CFLAGS) $(origin LIBBATADV_LDLIBS), undefined undefined
|
|||||||
LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME))
|
LIBBATADV_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBBATADV_NAME))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: neighbours-batadv stations respondd.so
|
all: stations respondd.so
|
||||||
|
|
||||||
neighbours-batadv: neighbours-batadv.c
|
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LIBNL_CFLAGS) $(LIBBATADV_CFLAGS) $(LDFLAGS) $(LDFLAGS_JSONC) $(LIBNL_LDLIBS) $(LIBBATADV_LDLIBS) -Wall -o $@ $^ $(LDLIBS)
|
|
||||||
|
|
||||||
stations: stations.c
|
stations: stations.c
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -Wall -o $@ $^ $(LDLIBS) -liwinfo
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDFLAGS_JSONC) -Wall -o $@ $^ $(LDLIBS) -liwinfo
|
||||||
|
@ -77,13 +77,17 @@ function (Helper, SignalGraph, Signal) {
|
|||||||
tdSignal.textContent = signal
|
tdSignal.textContent = signal
|
||||||
tdInactive.textContent = Math.round(inactive / 1000) + " s"
|
tdInactive.textContent = Math.round(inactive / 1000) + " s"
|
||||||
}
|
}
|
||||||
|
if (d.routingMetrics.protocol == "batadv") {
|
||||||
|
tdTQ.textContent = "TQ: " + Math.round(d.routingMetrics.tq / 2.55) + " %"
|
||||||
|
}
|
||||||
|
else if (d.routingMetrics.protocol == "babel") {
|
||||||
|
tdTQ.textContent = "Cost: " + Math.round(d.routingMetrics.cost / 653.53) + " %"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tdTQ.textContent = "?PROTO? (" + d.routingMetrics.protocol + ")"
|
||||||
|
}
|
||||||
|
|
||||||
if ("batadv" in d)
|
if (infoSet)
|
||||||
tdTQ.textContent = Math.round(d.batadv.tq / 2.55) + " %"
|
|
||||||
else
|
|
||||||
tdTQ.textContent = "‒"
|
|
||||||
|
|
||||||
if (infoSet)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if ("nodeInfo" in d) {
|
if ("nodeInfo" in d) {
|
||||||
@ -111,8 +115,9 @@ function (Helper, SignalGraph, Signal) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
tdDistance.textContent = "‒"
|
tdDistance.textContent = "‒"
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
hostname.textContent = d.id
|
hostname.textContent = d.id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +141,7 @@ function (Helper, SignalGraph, Signal) {
|
|||||||
tr.appendChild(th)
|
tr.appendChild(th)
|
||||||
|
|
||||||
th = document.createElement("th")
|
th = document.createElement("th")
|
||||||
th.textContent = "TQ"
|
th.textContent = "Metrik"
|
||||||
tr.appendChild(th)
|
tr.appendChild(th)
|
||||||
|
|
||||||
th = document.createElement("th")
|
th = document.createElement("th")
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
"use strict"
|
"use strict"
|
||||||
define([ "bacon"
|
define([ "bacon"
|
||||||
, "lib/helper"
|
, "lib/helper"
|
||||||
, "lib/streams"
|
, "lib/streams"
|
||||||
], function(Bacon, Helper, Streams) {
|
], function(Bacon, Helper, Streams) {
|
||||||
|
|
||||||
return function (mgmtBus, nodesBus, ip) {
|
return function (mgmtBus, nodesBus, ip) {
|
||||||
function nodeQuerier() {
|
function nodeQuerier() {
|
||||||
var asked = {}
|
var asked = {}
|
||||||
var timeout = 6000
|
var timeout = 6000
|
||||||
|
|
||||||
return function (ifname) {
|
return function (ifname) {
|
||||||
var now = new Date().getTime()
|
var now = new Date().getTime()
|
||||||
|
|
||||||
if (ifname in asked && now - asked[ifname] < timeout)
|
if (ifname in asked && now - asked[ifname] < timeout)
|
||||||
return Bacon.never()
|
return Bacon.never()
|
||||||
|
|
||||||
asked[ifname] = now
|
asked[ifname] = now
|
||||||
return Streams.nodeInfo(ip, ifname).map(function (d) {
|
return Streams.nodeInfo(ip, ifname).map(function (d) {
|
||||||
return { "ifname": ifname
|
return { "ifname": ifname
|
||||||
, "nodeInfo": d
|
, "nodeInfo": d
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var querierAsk = new Bacon.Bus()
|
var querierAsk = new Bacon.Bus()
|
||||||
var querier = querierAsk.flatMap(nodeQuerier())
|
var querier = querierAsk.flatMap(nodeQuerier())
|
||||||
querier.map(".nodeInfo").onValue(mgmtBus, "pushEvent", "nodeinfo")
|
querier.map(".nodeInfo").onValue(mgmtBus, "pushEvent", "nodeinfo")
|
||||||
|
|
||||||
function wrapIfname(ifname, d) {
|
function wrapIfname(ifname, d) {
|
||||||
return [ifname, d]
|
return [ifname, d]
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractIfname(d) {
|
function extractIfname(d) {
|
||||||
var r = {}
|
var r = {}
|
||||||
|
|
||||||
for (var station in d) {
|
for (var station in d) {
|
||||||
var ifname = d[station].ifname
|
var ifname = d[station].ifname
|
||||||
delete d[station].ifname
|
delete d[station].ifname
|
||||||
|
|
||||||
if (!(ifname in r))
|
if (!(ifname in r))
|
||||||
r[ifname] = {}
|
r[ifname] = {}
|
||||||
|
|
||||||
r[ifname][station] = d[station]
|
r[ifname][station] = d[station]
|
||||||
}
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
@ -54,74 +54,75 @@ define([ "bacon"
|
|||||||
|
|
||||||
function magic(interfaces) {
|
function magic(interfaces) {
|
||||||
var ifnames = Object.keys(interfaces)
|
var ifnames = Object.keys(interfaces)
|
||||||
ifnames.forEach(querierAsk.push)
|
ifnames.forEach(querierAsk.push)
|
||||||
|
|
||||||
var wifiStream = Bacon.fromArray(ifnames)
|
var wifiStream = Bacon.fromArray(ifnames)
|
||||||
.flatMap(stationsStream)
|
.flatMap(stationsStream)
|
||||||
.scan({}, function (a, b) {
|
.scan({}, function (a, b) {
|
||||||
a[b[0]] = b[1]
|
a[b[0]] = b[1]
|
||||||
return a
|
return a
|
||||||
})
|
})
|
||||||
|
|
||||||
var batadvStream = new Streams.Batadv(ip).toProperty({})
|
var batadvStream = new Streams.Batadv(ip).toProperty({})
|
||||||
|
var babelStream = new Streams.Babel(ip).toProperty({})
|
||||||
|
|
||||||
return Bacon.combineWith(combine, wifiStream
|
return Bacon.combineWith(combine, wifiStream
|
||||||
, batadvStream.map(extractIfname)
|
, Bacon.combineWith(Object.assign, batadvStream, babelStream).map(extractIfname)
|
||||||
, nodesBus.map(".macs")
|
, nodesBus.map(".macs")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function combine(wifi, batadv, macs) {
|
function combine(wifi, routingMetrics, macs) {
|
||||||
var interfaces = combineWithIfnames(wifi, batadv)
|
var interfaces = combineWithIfnames(wifi, routingMetrics)
|
||||||
|
|
||||||
for (var ifname in interfaces) {
|
for (var ifname in interfaces) {
|
||||||
var stations = interfaces[ifname]
|
var stations = interfaces[ifname]
|
||||||
for (var station in stations) {
|
for (var station in stations) {
|
||||||
stations[station].id = station
|
stations[station].id = station
|
||||||
|
|
||||||
if (station in macs)
|
if (station in macs)
|
||||||
stations[station].nodeInfo = macs[station]
|
stations[station].nodeInfo = macs[station]
|
||||||
else
|
else
|
||||||
querierAsk.push(ifname)
|
querierAsk.push(ifname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return interfaces
|
return interfaces
|
||||||
}
|
}
|
||||||
|
|
||||||
function combineWithIfnames(wifi, batadv) {
|
function combineWithIfnames(wifi, routingMetrics) {
|
||||||
var ifnames = Object.keys(wifi).concat(Object.keys(batadv))
|
var ifnames = Object.keys(wifi).concat(Object.keys(routingMetrics))
|
||||||
|
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
ifnames.filter(function(e, i) {
|
ifnames.filter(function(e, i) {
|
||||||
return ifnames.indexOf(e) === i
|
return ifnames.indexOf(e) === i
|
||||||
})
|
})
|
||||||
|
|
||||||
var out = {}
|
var out = {}
|
||||||
|
|
||||||
ifnames.forEach(function (ifname) {
|
ifnames.forEach(function (ifname) {
|
||||||
out[ifname] = combineWifiBatadv(wifi[ifname], batadv[ifname])
|
out[ifname] = combineWifiRoutingMetrics(wifi[ifname], routingMetrics[ifname])
|
||||||
})
|
})
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
function combineWifiBatadv(wifi, batadv) {
|
function combineWifiRoutingMetrics(wifi, routingMetrics) {
|
||||||
var station
|
var station
|
||||||
var out = {}
|
var out = {}
|
||||||
|
|
||||||
for (station in batadv) {
|
for (station in routingMetrics) {
|
||||||
if (!(station in out))
|
if (!(station in out))
|
||||||
out[station] = {}
|
out[station] = {}
|
||||||
|
|
||||||
out[station].batadv = batadv[station]
|
out[station].routingMetrics = routingMetrics[station]
|
||||||
}
|
}
|
||||||
|
|
||||||
for (station in wifi) {
|
for (station in wifi) {
|
||||||
if (!(station in out))
|
if (!(station in out))
|
||||||
out[station] = {}
|
out[station] = {}
|
||||||
|
|
||||||
out[station].wifi = wifi[station]
|
out[station].wifi = wifi[station]
|
||||||
}
|
}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
define(["bacon", "lib/helper"], function(Bacon, Helper) {
|
define(["bacon", "lib/helper"], function(Bacon, Helper) {
|
||||||
function nodeInfo(ip, ifname) {
|
function nodeInfo(ip, ifname) {
|
||||||
return Bacon.fromBinder(function (sink) {
|
return Bacon.fromBinder(function (sink) {
|
||||||
@ -43,6 +46,11 @@ define(["bacon", "lib/helper"], function(Bacon, Helper) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function babel(ip) {
|
||||||
|
var url = Helper.buildUrl(ip, "dyn/neighbours-babel")
|
||||||
|
return simpleStream(url)
|
||||||
|
}
|
||||||
|
|
||||||
function batadv(ip) {
|
function batadv(ip) {
|
||||||
var url = Helper.buildUrl(ip, "dyn/neighbours-batadv")
|
var url = Helper.buildUrl(ip, "dyn/neighbours-batadv")
|
||||||
return simpleStream(url)
|
return simpleStream(url)
|
||||||
@ -59,8 +67,9 @@ define(["bacon", "lib/helper"], function(Bacon, Helper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { nodeInfo: nodeInfo
|
return { nodeInfo: nodeInfo
|
||||||
, Batadv: batadv
|
|
||||||
, Stations: stations
|
, Stations: stations
|
||||||
|
, Batadv: batadv
|
||||||
|
, Babel: babel
|
||||||
, Statistics: statistics
|
, Statistics: statistics
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user