babel nodeinfo

This commit is contained in:
Martin/Geno 2019-05-19 00:34:21 +02:00 committed by genofire
parent 10e23b5642
commit f1e9d7e231
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"runtime" "runtime"
"strings" "strings"
babelParser "github.com/Vivena/babelweb2/parser"
"github.com/bdlm/log" "github.com/bdlm/log"
"github.com/FreifunkBremen/yanic/data" "github.com/FreifunkBremen/yanic/data"
@ -84,6 +85,27 @@ func (d *Daemon) updateNodeinfo(iface string, resp *data.ResponseData) {
resp.Nodeinfo.Network.Mesh[bface] = &mesh resp.Nodeinfo.Network.Mesh[bface] = &mesh
} }
if d.babelData == nil {
return
}
meshBabel := data.NetworkInterface{}
resp.Nodeinfo.Network.Mesh["babel"] = &meshBabel
d.babelData.Iter(func(bu babelParser.BabelUpdate) error {
sbu := bu.ToSUpdate()
if sbu.TableId != "interface" {
return nil
}
if sbu.EntryData["up"].(bool) {
addr := sbu.EntryData["ipv6"].(string)
resp.Nodeinfo.Network.Addresses = append(resp.Nodeinfo.Network.Addresses, addr)
meshBabel.Interfaces.Tunnel = append(meshBabel.Interfaces.Tunnel, addr)
}
return nil
})
} }
func getAddresses(iface string) (addrs []string) { func getAddresses(iface string) (addrs []string) {