From bd13b99378a3dedfd63ce423967328765313255a Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 24 Jan 2019 02:56:13 +0100 Subject: [PATCH] [TASK] rename NodeInfo to Nodeinfo (same naming overall) --- data/nodeinfo.go | 4 ++-- data/response.go | 2 +- database/influxdb/global_test.go | 6 +++--- database/influxdb/node_test.go | 6 +++--- database/respondd/main.go | 2 +- database/respondd/main_test.go | 2 +- output/filter/blacklist/blacklist_test.go | 6 +++--- output/filter/domainappendsite/domainappendsite.go | 2 +- .../domainappendsite/domainappendsite_test.go | 4 ++-- output/filter/domainassite/domainassite.go | 2 +- output/filter/domainassite/domainassite_test.go | 4 ++-- output/filter/filter_test.go | 4 ++-- output/filter/haslocation/haslocation_test.go | 8 ++++---- output/filter/inarea/inarea_test.go | 14 +++++++------- output/filter/noowner/noowner.go | 2 +- output/filter/noowner/noowner_test.go | 4 ++-- output/filter/site/site_test.go | 4 ++-- output/meshviewer-ffrgb/meshviewer_test.go | 8 ++++---- output/meshviewer-ffrgb/struct_test.go | 4 ++-- output/meshviewer/graph_test.go | 4 ++-- output/meshviewer/node.go | 2 +- output/meshviewer/nodes_test.go | 6 +++--- output/nodelist/nodelist_test.go | 6 +++--- respond/collector.go | 6 +++--- respond/collector_test.go | 2 +- runtime/node.go | 2 +- runtime/node_test.go | 2 +- runtime/nodes.go | 8 ++++---- runtime/nodes_test.go | 10 +++++----- runtime/stats_test.go | 6 +++--- 30 files changed, 71 insertions(+), 71 deletions(-) diff --git a/data/nodeinfo.go b/data/nodeinfo.go index 77cf40c..86cff15 100644 --- a/data/nodeinfo.go +++ b/data/nodeinfo.go @@ -1,7 +1,7 @@ package data -// NodeInfo struct -type NodeInfo struct { +// Nodeinfo struct +type Nodeinfo struct { NodeID string `json:"node_id"` Network Network `json:"network"` Owner *Owner `json:"owner"` diff --git a/data/response.go b/data/response.go index 502d7d2..b52874d 100644 --- a/data/response.go +++ b/data/response.go @@ -3,6 +3,6 @@ package data // ResponseData struct type ResponseData struct { Neighbours *Neighbours `json:"neighbours"` - NodeInfo *NodeInfo `json:"nodeinfo"` + Nodeinfo *Nodeinfo `json:"nodeinfo"` Statistics *Statistics `json:"statistics"` } diff --git a/database/influxdb/global_test.go b/database/influxdb/global_test.go index e5d54ea..7eadd7f 100644 --- a/database/influxdb/global_test.go +++ b/database/influxdb/global_test.go @@ -124,7 +124,7 @@ func createTestNodes() *runtime.Nodes { Total: 23, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "abcdef012345", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -146,7 +146,7 @@ func createTestNodes() *runtime.Nodes { Total: 2, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "112233445566", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -156,7 +156,7 @@ func createTestNodes() *runtime.Nodes { nodes.AddNode(&runtime.Node{ Online: true, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "0xdeadbeef0x", VPN: true, Hardware: data.Hardware{ diff --git a/database/influxdb/node_test.go b/database/influxdb/node_test.go index 0cf14de..f2286dd 100644 --- a/database/influxdb/node_test.go +++ b/database/influxdb/node_test.go @@ -52,7 +52,7 @@ func TestToInflux(t *testing.T) { }, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "deadbeef", Owner: &data.Owner{ Contact: "nobody", @@ -96,7 +96,7 @@ func TestToInflux(t *testing.T) { } neighbour := &runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "foobar", Network: data.Network{ Mac: "BAFF1E5", @@ -117,7 +117,7 @@ func TestToInflux(t *testing.T) { // do not add a empty statistics of a node droppednode := &runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "notfound", Network: data.Network{ Mac: "instats", diff --git a/database/respondd/main.go b/database/respondd/main.go index 76ca02a..1f38c2c 100644 --- a/database/respondd/main.go +++ b/database/respondd/main.go @@ -51,7 +51,7 @@ func Connect(configuration map[string]interface{}) (database.Connection, error) func (conn *Connection) InsertNode(node *runtime.Node) { res := &data.ResponseData{ - NodeInfo: node.Nodeinfo, + Nodeinfo: node.Nodeinfo, Statistics: node.Statistics, Neighbours: node.Neighbours, } diff --git a/database/respondd/main_test.go b/database/respondd/main_test.go index db73a13..ecdf05b 100644 --- a/database/respondd/main_test.go +++ b/database/respondd/main_test.go @@ -25,7 +25,7 @@ func TestStart(t *testing.T) { assert.NoError(err) conn.InsertNode(&runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "73deadbeaf13", Hostname: "inject-test", Network: data.Network{ diff --git a/output/filter/blacklist/blacklist_test.go b/output/filter/blacklist/blacklist_test.go index c40ec0b..f2e2855 100644 --- a/output/filter/blacklist/blacklist_test.go +++ b/output/filter/blacklist/blacklist_test.go @@ -23,7 +23,7 @@ func TestFilterBlacklist(t *testing.T) { assert.NoError(err) // keep node without nodeid - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}}) + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) assert.NotNil(n) // tests with blacklist @@ -31,11 +31,11 @@ func TestFilterBlacklist(t *testing.T) { assert.NoError(err) // blacklist contains node with nodeid -> drop it - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{NodeID: "a"}}) + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{NodeID: "a"}}) assert.Nil(n) // blacklist does not contains node without nodeid -> keep it - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}}) + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) assert.NotNil(n) n = filter.Apply(&runtime.Node{}) diff --git a/output/filter/domainappendsite/domainappendsite.go b/output/filter/domainappendsite/domainappendsite.go index 17d3e89..fa79957 100644 --- a/output/filter/domainappendsite/domainappendsite.go +++ b/output/filter/domainappendsite/domainappendsite.go @@ -29,7 +29,7 @@ func (config *domainAppendSite) Apply(node *runtime.Node) *runtime.Node { Lastseen: node.Lastseen, Online: node.Online, Statistics: node.Statistics, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: nodeinfo.NodeID, Network: nodeinfo.Network, System: data.System{ diff --git a/output/filter/domainappendsite/domainappendsite_test.go b/output/filter/domainappendsite/domainappendsite_test.go index 78ca86e..c99e8f7 100644 --- a/output/filter/domainappendsite/domainappendsite_test.go +++ b/output/filter/domainappendsite/domainappendsite_test.go @@ -17,7 +17,7 @@ func TestFilter(t *testing.T) { // delete owner by configuration filter, _ = build(true) - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ System: data.System{ SiteCode: "ffhb", DomainCode: "city", @@ -30,7 +30,7 @@ func TestFilter(t *testing.T) { // keep owner configuration filter, _ = build(false) - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ System: data.System{ SiteCode: "ffhb", DomainCode: "city", diff --git a/output/filter/domainassite/domainassite.go b/output/filter/domainassite/domainassite.go index 7146d19..4788d57 100644 --- a/output/filter/domainassite/domainassite.go +++ b/output/filter/domainassite/domainassite.go @@ -29,7 +29,7 @@ func (config *domainAsSite) Apply(node *runtime.Node) *runtime.Node { Lastseen: node.Lastseen, Online: node.Online, Statistics: node.Statistics, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: nodeinfo.NodeID, Network: nodeinfo.Network, System: data.System{ diff --git a/output/filter/domainassite/domainassite_test.go b/output/filter/domainassite/domainassite_test.go index 504500c..c17e8bf 100644 --- a/output/filter/domainassite/domainassite_test.go +++ b/output/filter/domainassite/domainassite_test.go @@ -17,7 +17,7 @@ func TestFilter(t *testing.T) { // delete owner by configuration filter, _ = build(true) - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ System: data.System{ SiteCode: "ffhb", DomainCode: "city", @@ -30,7 +30,7 @@ func TestFilter(t *testing.T) { // keep owner configuration filter, _ = build(false) - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ System: data.System{ SiteCode: "ffhb", DomainCode: "city", diff --git a/output/filter/filter_test.go b/output/filter/filter_test.go index c9f5ca0..6c85a2f 100644 --- a/output/filter/filter_test.go +++ b/output/filter/filter_test.go @@ -68,7 +68,7 @@ func TestFilter(t *testing.T) { nodes := &runtime.Nodes{ List: map[string]*runtime.Node{ "a": { - Nodeinfo: &data.NodeInfo{NodeID: "a"}, + Nodeinfo: &data.Nodeinfo{NodeID: "a"}, }, }, } @@ -83,7 +83,7 @@ func TestFilter(t *testing.T) { nodes = &runtime.Nodes{ List: map[string]*runtime.Node{ "a": { - Nodeinfo: &data.NodeInfo{NodeID: "a"}, + Nodeinfo: &data.Nodeinfo{NodeID: "a"}, }, }, } diff --git a/output/filter/haslocation/haslocation_test.go b/output/filter/haslocation/haslocation_test.go index 34a7bfd..2f37b28 100644 --- a/output/filter/haslocation/haslocation_test.go +++ b/output/filter/haslocation/haslocation_test.go @@ -20,13 +20,13 @@ func TestFilterHasLocation(t *testing.T) { assert.NoError(err) // node has location (with 0,0) -> keep it - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{}, }}) assert.NotNil(n) // node without location has no location -> drop it - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}}) + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) assert.Nil(n) // node without nodeinfo has no location -> drop it @@ -38,13 +38,13 @@ func TestFilterHasLocation(t *testing.T) { assert.NoError(err) // node has location (with 0,0) -> drop it - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{}, }}) assert.Nil(n) // node without location has no location -> keep it - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}}) + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) assert.NotNil(n) // node without nodeinfo has no location -> keep it diff --git a/output/filter/inarea/inarea_test.go b/output/filter/inarea/inarea_test.go index bcac400..89a3c79 100644 --- a/output/filter/inarea/inarea_test.go +++ b/output/filter/inarea/inarea_test.go @@ -18,7 +18,7 @@ func TestFilterInArea(t *testing.T) { "longitude_max": 12.0, }) - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{Latitude: 4.0, Longitude: 11.0}, }}) assert.NotNil(n) @@ -28,35 +28,35 @@ func TestFilterInArea(t *testing.T) { assert.NotNil(n) // keep without location -> use has_location for it - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}}) + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) assert.NotNil(n) // zeros not in area (0, 0) - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{}, }}) assert.Nil(n) // in area - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{Latitude: 4.0, Longitude: 11.0}, }}) assert.NotNil(n) // over max longitude -> dropped - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{Latitude: 4.0, Longitude: 13.0}, }}) assert.Nil(n) // over max latitude -> dropped - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{Latitude: 6.0, Longitude: 11.0}, }}) assert.Nil(n) // lower then mix latitde -> dropped - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Location: &data.Location{Latitude: 1.0, Longitude: 2.0}, }}) assert.Nil(n) diff --git a/output/filter/noowner/noowner.go b/output/filter/noowner/noowner.go index dbc3738..4116d62 100644 --- a/output/filter/noowner/noowner.go +++ b/output/filter/noowner/noowner.go @@ -29,7 +29,7 @@ func (no *noowner) Apply(node *runtime.Node) *runtime.Node { Lastseen: node.Lastseen, Online: node.Online, Statistics: node.Statistics, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: nodeinfo.NodeID, Network: nodeinfo.Network, System: nodeinfo.System, diff --git a/output/filter/noowner/noowner_test.go b/output/filter/noowner/noowner_test.go index 96be019..73a1f5f 100644 --- a/output/filter/noowner/noowner_test.go +++ b/output/filter/noowner/noowner_test.go @@ -17,7 +17,7 @@ func TestFilter(t *testing.T) { // delete owner by configuration filter, _ = build(true) - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Owner: &data.Owner{ Contact: "blub", }, @@ -28,7 +28,7 @@ func TestFilter(t *testing.T) { // keep owner configuration filter, _ = build(false) - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{ + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{ Owner: &data.Owner{ Contact: "blub", }, diff --git a/output/filter/site/site_test.go b/output/filter/site/site_test.go index 8209e81..51344ef 100644 --- a/output/filter/site/site_test.go +++ b/output/filter/site/site_test.go @@ -22,11 +22,11 @@ func TestFilterSite(t *testing.T) { assert.NoError(err) // wronge node - n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{System: data.System{SiteCode: "ffxx"}}}) + n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{System: data.System{SiteCode: "ffxx"}}}) assert.Nil(n) // right node - n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{System: data.System{SiteCode: "ffhb"}}}) + n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{System: data.System{SiteCode: "ffhb"}}}) assert.NotNil(n) // node without data -> wrong node diff --git a/output/meshviewer-ffrgb/meshviewer_test.go b/output/meshviewer-ffrgb/meshviewer_test.go index 5e6aa53..956bc75 100644 --- a/output/meshviewer-ffrgb/meshviewer_test.go +++ b/output/meshviewer-ffrgb/meshviewer_test.go @@ -14,7 +14,7 @@ func TestTransform(t *testing.T) { nodes := runtime.NewNodes(&runtime.NodesConfig{}) nodes.AddNode(&runtime.Node{ Online: true, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "node_a", Network: data.Network{ Mac: "node:a:mac", @@ -51,7 +51,7 @@ func TestTransform(t *testing.T) { }) nodes.AddNode(&runtime.Node{ Online: true, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "node_c", Network: data.Network{ Mac: "node:c:mac", @@ -81,7 +81,7 @@ func TestTransform(t *testing.T) { }) nodes.AddNode(&runtime.Node{ Online: true, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "node_b", Network: data.Network{ Mac: "node:b:mac", @@ -117,7 +117,7 @@ func TestTransform(t *testing.T) { }) nodes.AddNode(&runtime.Node{ Online: false, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "node_d", Network: data.Network{ Mac: "node:d:mac", diff --git a/output/meshviewer-ffrgb/struct_test.go b/output/meshviewer-ffrgb/struct_test.go index 61c9e61..66f0b4f 100644 --- a/output/meshviewer-ffrgb/struct_test.go +++ b/output/meshviewer-ffrgb/struct_test.go @@ -12,7 +12,7 @@ func TestRegister(t *testing.T) { assert := assert.New(t) nodes := runtime.NewNodes(&runtime.NodesConfig{}) node := NewNode(nodes, &runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ Owner: &data.Owner{ Contact: "whoami", }, @@ -26,7 +26,7 @@ func TestRegister(t *testing.T) { assert.Len(node.Addresses, 1) node = NewNode(nodes, &runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ Owner: &data.Owner{ Contact: "whoami", }, diff --git a/output/meshviewer/graph_test.go b/output/meshviewer/graph_test.go index 5d113eb..c3229de 100644 --- a/output/meshviewer/graph_test.go +++ b/output/meshviewer/graph_test.go @@ -12,7 +12,7 @@ import ( ) type TestNode struct { - Nodeinfo *data.NodeInfo `json:"nodeinfo"` + Nodeinfo *data.Nodeinfo `json:"nodeinfo"` Neighbours *data.Neighbours `json:"neighbours"` } @@ -38,7 +38,7 @@ func testGetNodesByFile(files ...string) *runtime.Nodes { for _, file := range files { node := testGetNodeByFile(file) nodes.Update(file, &data.ResponseData{ - NodeInfo: node.Nodeinfo, + Nodeinfo: node.Nodeinfo, Neighbours: node.Neighbours, }) } diff --git a/output/meshviewer/node.go b/output/meshviewer/node.go index bf479ef..bb3bb74 100644 --- a/output/meshviewer/node.go +++ b/output/meshviewer/node.go @@ -11,7 +11,7 @@ type Node struct { Lastseen jsontime.Time `json:"lastseen"` Flags Flags `json:"flags"` Statistics *Statistics `json:"statistics"` - Nodeinfo *data.NodeInfo `json:"nodeinfo"` + Nodeinfo *data.Nodeinfo `json:"nodeinfo"` Neighbours *data.Neighbours `json:"-"` } diff --git a/output/meshviewer/nodes_test.go b/output/meshviewer/nodes_test.go index caf59de..2a49dd0 100644 --- a/output/meshviewer/nodes_test.go +++ b/output/meshviewer/nodes_test.go @@ -31,7 +31,7 @@ func createTestNodes() *runtime.Nodes { Total: 23, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "abcdef012345", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -52,7 +52,7 @@ func createTestNodes() *runtime.Nodes { Free: 8, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "112233445566", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -61,7 +61,7 @@ func createTestNodes() *runtime.Nodes { }) nodes.AddNode(&runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "0xdeadbeef0x", VPN: true, Hardware: data.Hardware{ diff --git a/output/nodelist/nodelist_test.go b/output/nodelist/nodelist_test.go index efd1159..33e95ff 100644 --- a/output/nodelist/nodelist_test.go +++ b/output/nodelist/nodelist_test.go @@ -25,7 +25,7 @@ func createTestNodes() *runtime.Nodes { Total: 23, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "abcdef012345", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -41,7 +41,7 @@ func createTestNodes() *runtime.Nodes { Total: 2, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "112233445566", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -54,7 +54,7 @@ func createTestNodes() *runtime.Nodes { }) nodes.AddNode(&runtime.Node{ - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "0xdeadbeef0x", VPN: true, Hardware: data.Hardware{ diff --git a/respond/collector.go b/respond/collector.go index c5ff76f..929d58a 100644 --- a/respond/collector.go +++ b/respond/collector.go @@ -260,7 +260,7 @@ func (res *Response) parse() (*data.ResponseData, error) { func (coll *Collector) saveResponse(addr *net.UDPAddr, res *data.ResponseData) { // Search for NodeID var nodeID string - if val := res.NodeInfo; val != nil { + if val := res.Nodeinfo; val != nil { nodeID = val.NodeID } else if val := res.Neighbours; val != nil { nodeID = val.NodeID @@ -284,8 +284,8 @@ func (coll *Collector) saveResponse(addr *net.UDPAddr, res *data.ResponseData) { if res.Neighbours != nil && res.Neighbours.NodeID != nodeID { res.Neighbours = nil } - if res.NodeInfo != nil && res.NodeInfo.NodeID != nodeID { - res.NodeInfo = nil + if res.Nodeinfo != nil && res.Nodeinfo.NodeID != nodeID { + res.Nodeinfo = nil } // Process the data and update IP address diff --git a/respond/collector_test.go b/respond/collector_test.go index c16fdfb..b837259 100644 --- a/respond/collector_test.go +++ b/respond/collector_test.go @@ -39,5 +39,5 @@ func TestParse(t *testing.T) { assert.NoError(err) assert.NotNil(data) - assert.Equal("f81a67a5e9c1", data.NodeInfo.NodeID) + assert.Equal("f81a67a5e9c1", data.Nodeinfo.NodeID) } diff --git a/runtime/node.go b/runtime/node.go index 3e2059c..b10be10 100644 --- a/runtime/node.go +++ b/runtime/node.go @@ -14,7 +14,7 @@ type Node struct { Lastseen jsontime.Time `json:"lastseen"` Online bool `json:"online"` Statistics *data.Statistics `json:"statistics"` - Nodeinfo *data.NodeInfo `json:"nodeinfo"` + Nodeinfo *data.Nodeinfo `json:"nodeinfo"` Neighbours *data.Neighbours `json:"-"` } diff --git a/runtime/node_test.go b/runtime/node_test.go index 00c696e..b30c416 100644 --- a/runtime/node_test.go +++ b/runtime/node_test.go @@ -13,7 +13,7 @@ func TestNode(t *testing.T) { node := &Node{} assert.False(node.IsGateway()) - node.Nodeinfo = &data.NodeInfo{} + node.Nodeinfo = &data.Nodeinfo{} assert.False(node.IsGateway()) node.Nodeinfo.VPN = true diff --git a/runtime/nodes.go b/runtime/nodes.go index 91e8ac8..a4f0b08 100644 --- a/runtime/nodes.go +++ b/runtime/nodes.go @@ -64,8 +64,8 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node { } nodes.List[nodeID] = node } - if res.NodeInfo != nil { - nodes.readIfaces(res.NodeInfo) + if res.Nodeinfo != nil { + nodes.readIfaces(res.Nodeinfo) } nodes.Unlock() @@ -81,7 +81,7 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node { node.Lastseen = now node.Online = true node.Neighbours = res.Neighbours - node.Nodeinfo = res.NodeInfo + node.Nodeinfo = res.Nodeinfo node.Statistics = res.Statistics return node @@ -182,7 +182,7 @@ func (nodes *Nodes) expire() { } // adds the nodes interface addresses to the internal map -func (nodes *Nodes) readIfaces(nodeinfo *data.NodeInfo) { +func (nodes *Nodes) readIfaces(nodeinfo *data.Nodeinfo) { nodeID := nodeinfo.NodeID network := nodeinfo.Network diff --git a/runtime/nodes_test.go b/runtime/nodes_test.go index 70e2eff..0212afc 100644 --- a/runtime/nodes_test.go +++ b/runtime/nodes_test.go @@ -102,7 +102,7 @@ func TestUpdateNodes(t *testing.T) { &data.WirelessAirtime{}, }, }, - NodeInfo: &data.NodeInfo{}, + Nodeinfo: &data.Nodeinfo{}, } nodes.Update("abcdef012345", res) @@ -146,10 +146,10 @@ func TestAddNode(t *testing.T) { nodes.AddNode(&Node{}) assert.Len(nodes.List, 0) - nodes.AddNode(&Node{Nodeinfo: &data.NodeInfo{}}) + nodes.AddNode(&Node{Nodeinfo: &data.Nodeinfo{}}) assert.Len(nodes.List, 0) - nodes.AddNode(&Node{Nodeinfo: &data.NodeInfo{NodeID: "blub"}}) + nodes.AddNode(&Node{Nodeinfo: &data.Nodeinfo{NodeID: "blub"}}) assert.Len(nodes.List, 1) } @@ -163,7 +163,7 @@ func TestLinksNodes(t *testing.T) { assert.Len(nodes.List, 0) nodes.Update("f4f26dd7a30a", &data.ResponseData{ - NodeInfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "f4f26dd7a30a", Network: data.Network{ Mac: "f4:f2:6d:d7:a3:0a", @@ -172,7 +172,7 @@ func TestLinksNodes(t *testing.T) { }) nodes.Update("f4f26dd7a30b", &data.ResponseData{ - NodeInfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "f4f26dd7a30b", }, Neighbours: &data.Neighbours{ diff --git a/runtime/stats_test.go b/runtime/stats_test.go index 93363e8..d68fee0 100644 --- a/runtime/stats_test.go +++ b/runtime/stats_test.go @@ -84,7 +84,7 @@ func createTestNodes() *Nodes { Total: 23, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "abcdef012345", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -104,7 +104,7 @@ func createTestNodes() *Nodes { Total: 2, }, }, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "112233445566", Hardware: data.Hardware{ Model: "TP-Link 841", @@ -123,7 +123,7 @@ func createTestNodes() *Nodes { nodes.AddNode(&Node{ Online: true, - Nodeinfo: &data.NodeInfo{ + Nodeinfo: &data.Nodeinfo{ NodeID: "0xdeadbeef0x", VPN: true, Hardware: data.Hardware{