diff --git a/output/meshviewer-ffrgb/struct.go b/output/meshviewer-ffrgb/struct.go index 14639b9..5ca1946 100644 --- a/output/meshviewer-ffrgb/struct.go +++ b/output/meshviewer-ffrgb/struct.go @@ -78,15 +78,18 @@ func NewNode(nodes *runtime.Nodes, n *runtime.Node) *Node { Lastseen: n.Lastseen, IsOnline: n.Online, IsGateway: n.IsGateway(), + Addresses: []string{}, } if nodeinfo := n.Nodeinfo; nodeinfo != nil { node.NodeID = nodeinfo.NodeID node.MAC = nodeinfo.Network.Mac - node.Addresses = nodeinfo.Network.Addresses node.SiteCode = nodeinfo.System.SiteCode node.DomainCode = nodeinfo.System.DomainCode node.Hostname = nodeinfo.Hostname + if addresses := nodeinfo.Network.Addresses; addresses != nil { + node.Addresses = nodeinfo.Network.Addresses + } if owner := nodeinfo.Owner; owner != nil { node.Owner = owner.Contact } diff --git a/output/meshviewer-ffrgb/struct_test.go b/output/meshviewer-ffrgb/struct_test.go index 51960cf..61c9e61 100644 --- a/output/meshviewer-ffrgb/struct_test.go +++ b/output/meshviewer-ffrgb/struct_test.go @@ -12,6 +12,20 @@ func TestRegister(t *testing.T) { assert := assert.New(t) nodes := runtime.NewNodes(&runtime.NodesConfig{}) node := NewNode(nodes, &runtime.Node{ + Nodeinfo: &data.NodeInfo{ + Owner: &data.Owner{ + Contact: "whoami", + }, + Network: data.Network{ + Mac: "blub", + Addresses: []string{"fe80::1"}, + }, + }, + }) + assert.NotNil(node) + assert.Len(node.Addresses, 1) + + node = NewNode(nodes, &runtime.Node{ Nodeinfo: &data.NodeInfo{ Owner: &data.Owner{ Contact: "whoami", @@ -46,6 +60,7 @@ func TestRegister(t *testing.T) { }, }) assert.NotNil(node) + assert.NotNil(node.Addresses) assert.Equal("whoami", node.Owner) assert.Equal("blub", node.MAC) assert.Equal(13.3, node.Location.Longitude)