diff --git a/data/nodeinfo.go b/data/nodeinfo.go index 7fdecf1..2dcaf4b 100644 --- a/data/nodeinfo.go +++ b/data/nodeinfo.go @@ -11,19 +11,18 @@ type NodeInfo struct { Hardware Hardware `json:"hardware"` VPN bool `json:"vpn"` } +type BatInterface struct { + Interfaces struct { + Wireless []string `json:"wireless,omitempty"` + Other []string `json:"other,omitempty"` + Tunnel []string `json:"tunnel,omitempty"` + } `json:"interfaces"` +} type Network struct { Mac string `json:"mac"` Addresses []string `json:"addresses"` - Mesh struct { - Bat0 struct { - Interfaces struct { - Wireless []string `json:"wireless,omitempty"` - Other []string `json:"other,omitempty"` - Tunnel []string `json:"tunnel,omitempty"` - } `json:"interfaces"` - } `json:"bat0"` - } `json:"mesh"` + Mesh map[string]*BatInterface `json:"mesh"` MeshInterfaces []string `json:"mesh_interfaces"` } diff --git a/models/graph.go b/models/graph.go index c033348..b33ad15 100644 --- a/models/graph.go +++ b/models/graph.go @@ -44,15 +44,17 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) { // Fill mac->id map for sourceId, node := range nodes { if nodeinfo := node.Nodeinfo; nodeinfo != nil { - interfaces := nodeinfo.Network.Mesh.Bat0.Interfaces - addresses := append(append(interfaces.Other, interfaces.Tunnel...), interfaces.Wireless...) + for _,batinterface := range nodeinfo.Network.Mesh { + interfaces := batinterface.Interfaces + addresses := append(append(interfaces.Other, interfaces.Tunnel...), interfaces.Wireless...) - for _, sourceAddress := range addresses { - builder.macToID[sourceAddress] = sourceId + for _, sourceAddress := range addresses { + builder.macToID[sourceAddress] = sourceId - // is VPN address? - if _, found := builder.vpn[sourceAddress]; found { - builder.vpn[sourceId] = nil + // is VPN address? + if _, found := builder.vpn[sourceAddress]; found { + builder.vpn[sourceId] = nil + } } } }