[TASK] rename NodeInfo to Nodeinfo (same naming overall)
This commit is contained in:
parent
27fde7cd8c
commit
bd13b99378
@ -1,7 +1,7 @@
|
|||||||
package data
|
package data
|
||||||
|
|
||||||
// NodeInfo struct
|
// Nodeinfo struct
|
||||||
type NodeInfo struct {
|
type Nodeinfo struct {
|
||||||
NodeID string `json:"node_id"`
|
NodeID string `json:"node_id"`
|
||||||
Network Network `json:"network"`
|
Network Network `json:"network"`
|
||||||
Owner *Owner `json:"owner"`
|
Owner *Owner `json:"owner"`
|
||||||
|
@ -3,6 +3,6 @@ package data
|
|||||||
// ResponseData struct
|
// ResponseData struct
|
||||||
type ResponseData struct {
|
type ResponseData struct {
|
||||||
Neighbours *Neighbours `json:"neighbours"`
|
Neighbours *Neighbours `json:"neighbours"`
|
||||||
NodeInfo *NodeInfo `json:"nodeinfo"`
|
Nodeinfo *Nodeinfo `json:"nodeinfo"`
|
||||||
Statistics *Statistics `json:"statistics"`
|
Statistics *Statistics `json:"statistics"`
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
Total: 23,
|
Total: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "abcdef012345",
|
NodeID: "abcdef012345",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -146,7 +146,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
Total: 2,
|
Total: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "112233445566",
|
NodeID: "112233445566",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -156,7 +156,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
|
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Online: true,
|
Online: true,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "0xdeadbeef0x",
|
NodeID: "0xdeadbeef0x",
|
||||||
VPN: true,
|
VPN: true,
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
|
@ -52,7 +52,7 @@ func TestToInflux(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "deadbeef",
|
NodeID: "deadbeef",
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "nobody",
|
Contact: "nobody",
|
||||||
@ -96,7 +96,7 @@ func TestToInflux(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
neighbour := &runtime.Node{
|
neighbour := &runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "foobar",
|
NodeID: "foobar",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "BAFF1E5",
|
Mac: "BAFF1E5",
|
||||||
@ -117,7 +117,7 @@ func TestToInflux(t *testing.T) {
|
|||||||
|
|
||||||
// do not add a empty statistics of a node
|
// do not add a empty statistics of a node
|
||||||
droppednode := &runtime.Node{
|
droppednode := &runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "notfound",
|
NodeID: "notfound",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "instats",
|
Mac: "instats",
|
||||||
|
@ -51,7 +51,7 @@ func Connect(configuration map[string]interface{}) (database.Connection, error)
|
|||||||
|
|
||||||
func (conn *Connection) InsertNode(node *runtime.Node) {
|
func (conn *Connection) InsertNode(node *runtime.Node) {
|
||||||
res := &data.ResponseData{
|
res := &data.ResponseData{
|
||||||
NodeInfo: node.Nodeinfo,
|
Nodeinfo: node.Nodeinfo,
|
||||||
Statistics: node.Statistics,
|
Statistics: node.Statistics,
|
||||||
Neighbours: node.Neighbours,
|
Neighbours: node.Neighbours,
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func TestStart(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
conn.InsertNode(&runtime.Node{
|
conn.InsertNode(&runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "73deadbeaf13",
|
NodeID: "73deadbeaf13",
|
||||||
Hostname: "inject-test",
|
Hostname: "inject-test",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
|
@ -23,7 +23,7 @@ func TestFilterBlacklist(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
// keep node without nodeid
|
// keep node without nodeid
|
||||||
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{}})
|
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
|
||||||
assert.NotNil(n)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// tests with blacklist
|
// tests with blacklist
|
||||||
@ -31,11 +31,11 @@ func TestFilterBlacklist(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
// blacklist contains node with nodeid -> drop it
|
// 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)
|
assert.Nil(n)
|
||||||
|
|
||||||
// blacklist does not contains node without nodeid -> keep it
|
// 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)
|
assert.NotNil(n)
|
||||||
|
|
||||||
n = filter.Apply(&runtime.Node{})
|
n = filter.Apply(&runtime.Node{})
|
||||||
|
@ -29,7 +29,7 @@ func (config *domainAppendSite) Apply(node *runtime.Node) *runtime.Node {
|
|||||||
Lastseen: node.Lastseen,
|
Lastseen: node.Lastseen,
|
||||||
Online: node.Online,
|
Online: node.Online,
|
||||||
Statistics: node.Statistics,
|
Statistics: node.Statistics,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: nodeinfo.NodeID,
|
NodeID: nodeinfo.NodeID,
|
||||||
Network: nodeinfo.Network,
|
Network: nodeinfo.Network,
|
||||||
System: data.System{
|
System: data.System{
|
||||||
|
@ -17,7 +17,7 @@ func TestFilter(t *testing.T) {
|
|||||||
|
|
||||||
// delete owner by configuration
|
// delete owner by configuration
|
||||||
filter, _ = build(true)
|
filter, _ = build(true)
|
||||||
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
|
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
|
||||||
System: data.System{
|
System: data.System{
|
||||||
SiteCode: "ffhb",
|
SiteCode: "ffhb",
|
||||||
DomainCode: "city",
|
DomainCode: "city",
|
||||||
@ -30,7 +30,7 @@ func TestFilter(t *testing.T) {
|
|||||||
|
|
||||||
// keep owner configuration
|
// keep owner configuration
|
||||||
filter, _ = build(false)
|
filter, _ = build(false)
|
||||||
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
|
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
|
||||||
System: data.System{
|
System: data.System{
|
||||||
SiteCode: "ffhb",
|
SiteCode: "ffhb",
|
||||||
DomainCode: "city",
|
DomainCode: "city",
|
||||||
|
@ -29,7 +29,7 @@ func (config *domainAsSite) Apply(node *runtime.Node) *runtime.Node {
|
|||||||
Lastseen: node.Lastseen,
|
Lastseen: node.Lastseen,
|
||||||
Online: node.Online,
|
Online: node.Online,
|
||||||
Statistics: node.Statistics,
|
Statistics: node.Statistics,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: nodeinfo.NodeID,
|
NodeID: nodeinfo.NodeID,
|
||||||
Network: nodeinfo.Network,
|
Network: nodeinfo.Network,
|
||||||
System: data.System{
|
System: data.System{
|
||||||
|
@ -17,7 +17,7 @@ func TestFilter(t *testing.T) {
|
|||||||
|
|
||||||
// delete owner by configuration
|
// delete owner by configuration
|
||||||
filter, _ = build(true)
|
filter, _ = build(true)
|
||||||
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
|
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
|
||||||
System: data.System{
|
System: data.System{
|
||||||
SiteCode: "ffhb",
|
SiteCode: "ffhb",
|
||||||
DomainCode: "city",
|
DomainCode: "city",
|
||||||
@ -30,7 +30,7 @@ func TestFilter(t *testing.T) {
|
|||||||
|
|
||||||
// keep owner configuration
|
// keep owner configuration
|
||||||
filter, _ = build(false)
|
filter, _ = build(false)
|
||||||
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
|
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
|
||||||
System: data.System{
|
System: data.System{
|
||||||
SiteCode: "ffhb",
|
SiteCode: "ffhb",
|
||||||
DomainCode: "city",
|
DomainCode: "city",
|
||||||
|
@ -68,7 +68,7 @@ func TestFilter(t *testing.T) {
|
|||||||
nodes := &runtime.Nodes{
|
nodes := &runtime.Nodes{
|
||||||
List: map[string]*runtime.Node{
|
List: map[string]*runtime.Node{
|
||||||
"a": {
|
"a": {
|
||||||
Nodeinfo: &data.NodeInfo{NodeID: "a"},
|
Nodeinfo: &data.Nodeinfo{NodeID: "a"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ func TestFilter(t *testing.T) {
|
|||||||
nodes = &runtime.Nodes{
|
nodes = &runtime.Nodes{
|
||||||
List: map[string]*runtime.Node{
|
List: map[string]*runtime.Node{
|
||||||
"a": {
|
"a": {
|
||||||
Nodeinfo: &data.NodeInfo{NodeID: "a"},
|
Nodeinfo: &data.Nodeinfo{NodeID: "a"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@ func TestFilterHasLocation(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
// node has location (with 0,0) -> keep it
|
// 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{},
|
Location: &data.Location{},
|
||||||
}})
|
}})
|
||||||
assert.NotNil(n)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// node without location has no location -> drop it
|
// 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)
|
assert.Nil(n)
|
||||||
|
|
||||||
// node without nodeinfo has no location -> drop it
|
// node without nodeinfo has no location -> drop it
|
||||||
@ -38,13 +38,13 @@ func TestFilterHasLocation(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
// node has location (with 0,0) -> drop it
|
// 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{},
|
Location: &data.Location{},
|
||||||
}})
|
}})
|
||||||
assert.Nil(n)
|
assert.Nil(n)
|
||||||
|
|
||||||
// node without location has no location -> keep it
|
// 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)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// node without nodeinfo has no location -> keep it
|
// node without nodeinfo has no location -> keep it
|
||||||
|
@ -18,7 +18,7 @@ func TestFilterInArea(t *testing.T) {
|
|||||||
"longitude_max": 12.0,
|
"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},
|
Location: &data.Location{Latitude: 4.0, Longitude: 11.0},
|
||||||
}})
|
}})
|
||||||
assert.NotNil(n)
|
assert.NotNil(n)
|
||||||
@ -28,35 +28,35 @@ func TestFilterInArea(t *testing.T) {
|
|||||||
assert.NotNil(n)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// keep without location -> use has_location for it
|
// 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)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// zeros not in area (0, 0)
|
// 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{},
|
Location: &data.Location{},
|
||||||
}})
|
}})
|
||||||
assert.Nil(n)
|
assert.Nil(n)
|
||||||
|
|
||||||
// in area
|
// 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},
|
Location: &data.Location{Latitude: 4.0, Longitude: 11.0},
|
||||||
}})
|
}})
|
||||||
assert.NotNil(n)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// over max longitude -> dropped
|
// 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},
|
Location: &data.Location{Latitude: 4.0, Longitude: 13.0},
|
||||||
}})
|
}})
|
||||||
assert.Nil(n)
|
assert.Nil(n)
|
||||||
|
|
||||||
// over max latitude -> dropped
|
// 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},
|
Location: &data.Location{Latitude: 6.0, Longitude: 11.0},
|
||||||
}})
|
}})
|
||||||
assert.Nil(n)
|
assert.Nil(n)
|
||||||
|
|
||||||
// lower then mix latitde -> dropped
|
// 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},
|
Location: &data.Location{Latitude: 1.0, Longitude: 2.0},
|
||||||
}})
|
}})
|
||||||
assert.Nil(n)
|
assert.Nil(n)
|
||||||
|
@ -29,7 +29,7 @@ func (no *noowner) Apply(node *runtime.Node) *runtime.Node {
|
|||||||
Lastseen: node.Lastseen,
|
Lastseen: node.Lastseen,
|
||||||
Online: node.Online,
|
Online: node.Online,
|
||||||
Statistics: node.Statistics,
|
Statistics: node.Statistics,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: nodeinfo.NodeID,
|
NodeID: nodeinfo.NodeID,
|
||||||
Network: nodeinfo.Network,
|
Network: nodeinfo.Network,
|
||||||
System: nodeinfo.System,
|
System: nodeinfo.System,
|
||||||
|
@ -17,7 +17,7 @@ func TestFilter(t *testing.T) {
|
|||||||
|
|
||||||
// delete owner by configuration
|
// delete owner by configuration
|
||||||
filter, _ = build(true)
|
filter, _ = build(true)
|
||||||
n := filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
|
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "blub",
|
Contact: "blub",
|
||||||
},
|
},
|
||||||
@ -28,7 +28,7 @@ func TestFilter(t *testing.T) {
|
|||||||
|
|
||||||
// keep owner configuration
|
// keep owner configuration
|
||||||
filter, _ = build(false)
|
filter, _ = build(false)
|
||||||
n = filter.Apply(&runtime.Node{Nodeinfo: &data.NodeInfo{
|
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "blub",
|
Contact: "blub",
|
||||||
},
|
},
|
||||||
|
@ -22,11 +22,11 @@ func TestFilterSite(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
// wronge node
|
// 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)
|
assert.Nil(n)
|
||||||
|
|
||||||
// right node
|
// 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)
|
assert.NotNil(n)
|
||||||
|
|
||||||
// node without data -> wrong node
|
// node without data -> wrong node
|
||||||
|
@ -14,7 +14,7 @@ func TestTransform(t *testing.T) {
|
|||||||
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Online: true,
|
Online: true,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "node_a",
|
NodeID: "node_a",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "node:a:mac",
|
Mac: "node:a:mac",
|
||||||
@ -51,7 +51,7 @@ func TestTransform(t *testing.T) {
|
|||||||
})
|
})
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Online: true,
|
Online: true,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "node_c",
|
NodeID: "node_c",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "node:c:mac",
|
Mac: "node:c:mac",
|
||||||
@ -81,7 +81,7 @@ func TestTransform(t *testing.T) {
|
|||||||
})
|
})
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Online: true,
|
Online: true,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "node_b",
|
NodeID: "node_b",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "node:b:mac",
|
Mac: "node:b:mac",
|
||||||
@ -117,7 +117,7 @@ func TestTransform(t *testing.T) {
|
|||||||
})
|
})
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Online: false,
|
Online: false,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "node_d",
|
NodeID: "node_d",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "node:d:mac",
|
Mac: "node:d:mac",
|
||||||
|
@ -12,7 +12,7 @@ func TestRegister(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
nodes := runtime.NewNodes(&runtime.NodesConfig{})
|
||||||
node := NewNode(nodes, &runtime.Node{
|
node := NewNode(nodes, &runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "whoami",
|
Contact: "whoami",
|
||||||
},
|
},
|
||||||
@ -26,7 +26,7 @@ func TestRegister(t *testing.T) {
|
|||||||
assert.Len(node.Addresses, 1)
|
assert.Len(node.Addresses, 1)
|
||||||
|
|
||||||
node = NewNode(nodes, &runtime.Node{
|
node = NewNode(nodes, &runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "whoami",
|
Contact: "whoami",
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TestNode struct {
|
type TestNode struct {
|
||||||
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
|
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
|
||||||
Neighbours *data.Neighbours `json:"neighbours"`
|
Neighbours *data.Neighbours `json:"neighbours"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ func testGetNodesByFile(files ...string) *runtime.Nodes {
|
|||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
node := testGetNodeByFile(file)
|
node := testGetNodeByFile(file)
|
||||||
nodes.Update(file, &data.ResponseData{
|
nodes.Update(file, &data.ResponseData{
|
||||||
NodeInfo: node.Nodeinfo,
|
Nodeinfo: node.Nodeinfo,
|
||||||
Neighbours: node.Neighbours,
|
Neighbours: node.Neighbours,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ type Node struct {
|
|||||||
Lastseen jsontime.Time `json:"lastseen"`
|
Lastseen jsontime.Time `json:"lastseen"`
|
||||||
Flags Flags `json:"flags"`
|
Flags Flags `json:"flags"`
|
||||||
Statistics *Statistics `json:"statistics"`
|
Statistics *Statistics `json:"statistics"`
|
||||||
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
|
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
|
||||||
Neighbours *data.Neighbours `json:"-"`
|
Neighbours *data.Neighbours `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
Total: 23,
|
Total: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "abcdef012345",
|
NodeID: "abcdef012345",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -52,7 +52,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
Free: 8,
|
Free: 8,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "112233445566",
|
NodeID: "112233445566",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -61,7 +61,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
})
|
})
|
||||||
|
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "0xdeadbeef0x",
|
NodeID: "0xdeadbeef0x",
|
||||||
VPN: true,
|
VPN: true,
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
|
@ -25,7 +25,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
Total: 23,
|
Total: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "abcdef012345",
|
NodeID: "abcdef012345",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -41,7 +41,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
Total: 2,
|
Total: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "112233445566",
|
NodeID: "112233445566",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -54,7 +54,7 @@ func createTestNodes() *runtime.Nodes {
|
|||||||
})
|
})
|
||||||
|
|
||||||
nodes.AddNode(&runtime.Node{
|
nodes.AddNode(&runtime.Node{
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "0xdeadbeef0x",
|
NodeID: "0xdeadbeef0x",
|
||||||
VPN: true,
|
VPN: true,
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
|
@ -260,7 +260,7 @@ func (res *Response) parse() (*data.ResponseData, error) {
|
|||||||
func (coll *Collector) saveResponse(addr *net.UDPAddr, res *data.ResponseData) {
|
func (coll *Collector) saveResponse(addr *net.UDPAddr, res *data.ResponseData) {
|
||||||
// Search for NodeID
|
// Search for NodeID
|
||||||
var nodeID string
|
var nodeID string
|
||||||
if val := res.NodeInfo; val != nil {
|
if val := res.Nodeinfo; val != nil {
|
||||||
nodeID = val.NodeID
|
nodeID = val.NodeID
|
||||||
} else if val := res.Neighbours; val != nil {
|
} else if val := res.Neighbours; val != nil {
|
||||||
nodeID = val.NodeID
|
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 {
|
if res.Neighbours != nil && res.Neighbours.NodeID != nodeID {
|
||||||
res.Neighbours = nil
|
res.Neighbours = nil
|
||||||
}
|
}
|
||||||
if res.NodeInfo != nil && res.NodeInfo.NodeID != nodeID {
|
if res.Nodeinfo != nil && res.Nodeinfo.NodeID != nodeID {
|
||||||
res.NodeInfo = nil
|
res.Nodeinfo = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the data and update IP address
|
// Process the data and update IP address
|
||||||
|
@ -39,5 +39,5 @@ func TestParse(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(data)
|
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"`
|
Lastseen jsontime.Time `json:"lastseen"`
|
||||||
Online bool `json:"online"`
|
Online bool `json:"online"`
|
||||||
Statistics *data.Statistics `json:"statistics"`
|
Statistics *data.Statistics `json:"statistics"`
|
||||||
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
|
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
|
||||||
Neighbours *data.Neighbours `json:"-"`
|
Neighbours *data.Neighbours `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ func TestNode(t *testing.T) {
|
|||||||
node := &Node{}
|
node := &Node{}
|
||||||
assert.False(node.IsGateway())
|
assert.False(node.IsGateway())
|
||||||
|
|
||||||
node.Nodeinfo = &data.NodeInfo{}
|
node.Nodeinfo = &data.Nodeinfo{}
|
||||||
assert.False(node.IsGateway())
|
assert.False(node.IsGateway())
|
||||||
|
|
||||||
node.Nodeinfo.VPN = true
|
node.Nodeinfo.VPN = true
|
||||||
|
@ -64,8 +64,8 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node {
|
|||||||
}
|
}
|
||||||
nodes.List[nodeID] = node
|
nodes.List[nodeID] = node
|
||||||
}
|
}
|
||||||
if res.NodeInfo != nil {
|
if res.Nodeinfo != nil {
|
||||||
nodes.readIfaces(res.NodeInfo)
|
nodes.readIfaces(res.Nodeinfo)
|
||||||
}
|
}
|
||||||
nodes.Unlock()
|
nodes.Unlock()
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node {
|
|||||||
node.Lastseen = now
|
node.Lastseen = now
|
||||||
node.Online = true
|
node.Online = true
|
||||||
node.Neighbours = res.Neighbours
|
node.Neighbours = res.Neighbours
|
||||||
node.Nodeinfo = res.NodeInfo
|
node.Nodeinfo = res.Nodeinfo
|
||||||
node.Statistics = res.Statistics
|
node.Statistics = res.Statistics
|
||||||
|
|
||||||
return node
|
return node
|
||||||
@ -182,7 +182,7 @@ func (nodes *Nodes) expire() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// adds the nodes interface addresses to the internal map
|
// 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
|
nodeID := nodeinfo.NodeID
|
||||||
network := nodeinfo.Network
|
network := nodeinfo.Network
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ func TestUpdateNodes(t *testing.T) {
|
|||||||
&data.WirelessAirtime{},
|
&data.WirelessAirtime{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
NodeInfo: &data.NodeInfo{},
|
Nodeinfo: &data.Nodeinfo{},
|
||||||
}
|
}
|
||||||
nodes.Update("abcdef012345", res)
|
nodes.Update("abcdef012345", res)
|
||||||
|
|
||||||
@ -146,10 +146,10 @@ func TestAddNode(t *testing.T) {
|
|||||||
nodes.AddNode(&Node{})
|
nodes.AddNode(&Node{})
|
||||||
assert.Len(nodes.List, 0)
|
assert.Len(nodes.List, 0)
|
||||||
|
|
||||||
nodes.AddNode(&Node{Nodeinfo: &data.NodeInfo{}})
|
nodes.AddNode(&Node{Nodeinfo: &data.Nodeinfo{}})
|
||||||
assert.Len(nodes.List, 0)
|
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)
|
assert.Len(nodes.List, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ func TestLinksNodes(t *testing.T) {
|
|||||||
assert.Len(nodes.List, 0)
|
assert.Len(nodes.List, 0)
|
||||||
|
|
||||||
nodes.Update("f4f26dd7a30a", &data.ResponseData{
|
nodes.Update("f4f26dd7a30a", &data.ResponseData{
|
||||||
NodeInfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "f4f26dd7a30a",
|
NodeID: "f4f26dd7a30a",
|
||||||
Network: data.Network{
|
Network: data.Network{
|
||||||
Mac: "f4:f2:6d:d7:a3:0a",
|
Mac: "f4:f2:6d:d7:a3:0a",
|
||||||
@ -172,7 +172,7 @@ func TestLinksNodes(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
nodes.Update("f4f26dd7a30b", &data.ResponseData{
|
nodes.Update("f4f26dd7a30b", &data.ResponseData{
|
||||||
NodeInfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "f4f26dd7a30b",
|
NodeID: "f4f26dd7a30b",
|
||||||
},
|
},
|
||||||
Neighbours: &data.Neighbours{
|
Neighbours: &data.Neighbours{
|
||||||
|
@ -84,7 +84,7 @@ func createTestNodes() *Nodes {
|
|||||||
Total: 23,
|
Total: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "abcdef012345",
|
NodeID: "abcdef012345",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -104,7 +104,7 @@ func createTestNodes() *Nodes {
|
|||||||
Total: 2,
|
Total: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "112233445566",
|
NodeID: "112233445566",
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
Model: "TP-Link 841",
|
Model: "TP-Link 841",
|
||||||
@ -123,7 +123,7 @@ func createTestNodes() *Nodes {
|
|||||||
|
|
||||||
nodes.AddNode(&Node{
|
nodes.AddNode(&Node{
|
||||||
Online: true,
|
Online: true,
|
||||||
Nodeinfo: &data.NodeInfo{
|
Nodeinfo: &data.Nodeinfo{
|
||||||
NodeID: "0xdeadbeef0x",
|
NodeID: "0xdeadbeef0x",
|
||||||
VPN: true,
|
VPN: true,
|
||||||
Hardware: data.Hardware{
|
Hardware: data.Hardware{
|
||||||
|
Loading…
Reference in New Issue
Block a user