[TASK] rename NodeInfo to Nodeinfo (same naming overall)
This commit is contained in:
parent
27fde7cd8c
commit
bd13b99378
|
@ -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"`
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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{})
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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:"-"`
|
||||
}
|
||||
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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:"-"`
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue