diffrent interface names

This commit is contained in:
root 2016-04-29 08:25:45 +02:00
parent 948bfb291f
commit 756d9e3697
2 changed files with 17 additions and 16 deletions

View File

@ -11,19 +11,18 @@ type NodeInfo struct {
Hardware Hardware `json:"hardware"` Hardware Hardware `json:"hardware"`
VPN bool `json:"vpn"` 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 { type Network struct {
Mac string `json:"mac"` Mac string `json:"mac"`
Addresses []string `json:"addresses"` Addresses []string `json:"addresses"`
Mesh struct { Mesh map[string]*BatInterface `json:"mesh"`
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"`
MeshInterfaces []string `json:"mesh_interfaces"` MeshInterfaces []string `json:"mesh_interfaces"`
} }

View File

@ -44,15 +44,17 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) {
// Fill mac->id map // Fill mac->id map
for sourceId, node := range nodes { for sourceId, node := range nodes {
if nodeinfo := node.Nodeinfo; nodeinfo != nil { if nodeinfo := node.Nodeinfo; nodeinfo != nil {
interfaces := nodeinfo.Network.Mesh.Bat0.Interfaces for _,batinterface := range nodeinfo.Network.Mesh {
addresses := append(append(interfaces.Other, interfaces.Tunnel...), interfaces.Wireless...) interfaces := batinterface.Interfaces
addresses := append(append(interfaces.Other, interfaces.Tunnel...), interfaces.Wireless...)
for _, sourceAddress := range addresses { for _, sourceAddress := range addresses {
builder.macToID[sourceAddress] = sourceId builder.macToID[sourceAddress] = sourceId
// is VPN address? // is VPN address?
if _, found := builder.vpn[sourceAddress]; found { if _, found := builder.vpn[sourceAddress]; found {
builder.vpn[sourceId] = nil builder.vpn[sourceId] = nil
}
} }
} }
} }