[BUGFIX] not crash if batman not exists

This commit is contained in:
Martin/Geno 2019-05-03 17:51:30 +02:00 committed by genofire
parent 95ae82fa06
commit 4796c95933
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
2 changed files with 14 additions and 0 deletions

View File

@ -8,8 +8,14 @@ func (d *Daemon) updateNeighbours(iface string, resp *data.ResponseData) {
_, nodeID := d.getAnswer(iface) _, nodeID := d.getAnswer(iface)
resp.Neighbours.NodeID = nodeID resp.Neighbours.NodeID = nodeID
resp.Neighbours.Batadv = make(map[string]data.BatadvNeighbours) resp.Neighbours.Batadv = make(map[string]data.BatadvNeighbours)
for _, bface := range d.Batman { for _, bface := range d.Batman {
b := NewBatman(bface) b := NewBatman(bface)
if b == nil {
continue
}
for bfaceAddr, n := range b.Neighbours() { for bfaceAddr, n := range b.Neighbours() {
resp.Neighbours.Batadv[bfaceAddr] = n resp.Neighbours.Batadv[bfaceAddr] = n
} }

View File

@ -66,14 +66,22 @@ func (d *Daemon) updateNodeinfo(iface string, resp *data.ResponseData) {
resp.Nodeinfo.Network.Mesh = make(map[string]*data.NetworkInterface) resp.Nodeinfo.Network.Mesh = make(map[string]*data.NetworkInterface)
for _, bface := range d.Batman { for _, bface := range d.Batman {
b := NewBatman(bface) b := NewBatman(bface)
if b == nil {
continue
}
mesh := data.NetworkInterface{} mesh := data.NetworkInterface{}
for _, bbface := range b.Interfaces { for _, bbface := range b.Interfaces {
addr := b.Address(bbface) addr := b.Address(bbface)
if addr != "" { if addr != "" {
mesh.Interfaces.Tunnel = append(mesh.Interfaces.Tunnel, addr) mesh.Interfaces.Tunnel = append(mesh.Interfaces.Tunnel, addr)
} }
} }
resp.Nodeinfo.Network.Mesh[bface] = &mesh resp.Nodeinfo.Network.Mesh[bface] = &mesh
} }
} }