[BUGFIX] not crash if batman not exists
This commit is contained in:
parent
95ae82fa06
commit
4796c95933
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue