parent
cbe2577aa9
commit
e9420828a2
|
@ -11,7 +11,7 @@ import (
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Firstseen jsontime.Time `json:"firstseen"`
|
Firstseen jsontime.Time `json:"firstseen"`
|
||||||
Lastseen jsontime.Time `json:"lastseen"`
|
Lastseen jsontime.Time `json:"lastseen"`
|
||||||
Flags *Flags `json:"flags,omitempty"`
|
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:"-"`
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) {
|
||||||
|
|
||||||
// Add links
|
// Add links
|
||||||
for sourceID, node := range nodes {
|
for sourceID, node := range nodes {
|
||||||
if flag := node.Flags; flag == nil || flag.Online {
|
if node.Flags.Online {
|
||||||
if neighbours := node.Neighbours; neighbours != nil {
|
if neighbours := node.Neighbours; neighbours != nil {
|
||||||
// Batman neighbours
|
// Batman neighbours
|
||||||
for _, batadvNeighbours := range neighbours.Batadv {
|
for _, batadvNeighbours := range neighbours.Batadv {
|
||||||
|
|
|
@ -35,7 +35,11 @@ func testGetNodesByFile(files ...string) *Nodes {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
nodes.List[file] = testGetNodeByFile(file)
|
node := testGetNodeByFile(file)
|
||||||
|
nodes.Update(file, &data.ResponseData{
|
||||||
|
NodeInfo: node.Nodeinfo,
|
||||||
|
Neighbours: node.Neighbours,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodes
|
return nodes
|
||||||
|
|
|
@ -11,12 +11,12 @@ import (
|
||||||
|
|
||||||
// Node struct
|
// Node struct
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Firstseen jsontime.Time `json:"firstseen"`
|
Firstseen jsontime.Time `json:"firstseen"`
|
||||||
Lastseen jsontime.Time `json:"lastseen"`
|
Lastseen jsontime.Time `json:"lastseen"`
|
||||||
Flags *meshviewer.Flags `json:"flags,omitempty"`
|
Flags meshviewer.Flags `json:"flags"`
|
||||||
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:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns tags and fields for InfluxDB
|
// Returns tags and fields for InfluxDB
|
||||||
|
|
|
@ -56,20 +56,13 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node {
|
||||||
if node == nil {
|
if node == nil {
|
||||||
node = &Node{
|
node = &Node{
|
||||||
Firstseen: now,
|
Firstseen: now,
|
||||||
Flags: &meshviewer.Flags{
|
|
||||||
Online: true,
|
|
||||||
Gateway: false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
nodes.List[nodeID] = node
|
nodes.List[nodeID] = node
|
||||||
}
|
}
|
||||||
nodes.Unlock()
|
nodes.Unlock()
|
||||||
|
|
||||||
node.Lastseen = now
|
node.Lastseen = now
|
||||||
|
node.Flags.Online = true
|
||||||
if node.Flags != nil {
|
|
||||||
node.Flags.Online = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update neighbours
|
// Update neighbours
|
||||||
if val := res.Neighbours; val != nil {
|
if val := res.Neighbours; val != nil {
|
||||||
|
@ -174,9 +167,7 @@ func (nodes *Nodes) expire() {
|
||||||
delete(nodes.List, id)
|
delete(nodes.List, id)
|
||||||
} else if node.Lastseen.Before(offlineTime) {
|
} else if node.Lastseen.Before(offlineTime) {
|
||||||
// set to offline
|
// set to offline
|
||||||
if node.Flags != nil {
|
node.Flags.Online = false
|
||||||
node.Flags.Online = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue