Skip to content

Commit

Permalink
[BUGFIX] not crash if batman not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed May 3, 2019
1 parent d7d39fe commit ad244a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions respond/daemon/neighbours.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ func (d *Daemon) updateNeighbours(iface string, resp *data.ResponseData) {
_, nodeID := d.getAnswer(iface)
resp.Neighbours.NodeID = nodeID
resp.Neighbours.Batadv = make(map[string]data.BatadvNeighbours)

for _, bface := range d.Batman {

b := NewBatman(bface)
if b == nil {
continue
}

for bfaceAddr, n := range b.Neighbours() {
resp.Neighbours.Batadv[bfaceAddr] = n
}
Expand Down
8 changes: 8 additions & 0 deletions respond/daemon/nodeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ func (d *Daemon) updateNodeinfo(iface string, resp *data.ResponseData) {

resp.Nodeinfo.Network.Mesh = make(map[string]*data.NetworkInterface)
for _, bface := range d.Batman {

b := NewBatman(bface)

if b == nil {
continue
}

mesh := data.NetworkInterface{}

for _, bbface := range b.Interfaces {
addr := b.Address(bbface)
if addr != "" {
mesh.Interfaces.Tunnel = append(mesh.Interfaces.Tunnel, addr)
}
}

resp.Nodeinfo.Network.Mesh[bface] = &mesh
}
}
Expand Down

0 comments on commit ad244a5

Please sign in to comment.