disable link for offline nodes + improve offline state
This commit is contained in:
parent
9049b6d937
commit
719cf13f87
|
@ -29,7 +29,9 @@ func (t *Time) UnmarshalJSON(data []byte) (err error) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (t Time) GetTime() time.Time{
|
||||||
|
return t.time
|
||||||
|
}
|
||||||
func (t Time) Unix() int64 {
|
func (t Time) Unix() int64 {
|
||||||
return t.time.Unix()
|
return t.time.Unix()
|
||||||
}
|
}
|
||||||
|
@ -37,3 +39,10 @@ func (t Time) Unix() int64 {
|
||||||
func (t Time) IsZero() bool {
|
func (t Time) IsZero() bool {
|
||||||
return t.time.IsZero()
|
return t.time.IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t Time) Add(d time.Duration) Time {
|
||||||
|
return Time{time: t.time.Add(d)}
|
||||||
|
}
|
||||||
|
func (t Time) After(u Time) bool {
|
||||||
|
return t.time.After(u.GetTime())
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,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 neighbours := node.Neighbours; neighbours != nil {
|
if neighbours := node.Neighbours; neighbours != nil {
|
||||||
for _, batadvNeighbours := range neighbours.Batadv {
|
for _, batadvNeighbours := range neighbours.Batadv {
|
||||||
for targetAddress, link := range batadvNeighbours.Neighbours {
|
for targetAddress, link := range batadvNeighbours.Neighbours {
|
||||||
|
@ -80,6 +81,7 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (builder *GraphBuilder) Extract() ([]*GraphNode, []*GraphLink) {
|
func (builder *GraphBuilder) Extract() ([]*GraphNode, []*GraphLink) {
|
||||||
links := make([]*GraphLink, len(builder.links))
|
links := make([]*GraphLink, len(builder.links))
|
||||||
|
|
|
@ -139,7 +139,7 @@ func (nodes *Nodes) worker() {
|
||||||
//
|
//
|
||||||
// set node as offline (without statistics)
|
// set node as offline (without statistics)
|
||||||
for _, node := range nodes.List {
|
for _, node := range nodes.List {
|
||||||
if node.Statistics != nil && node.Lastseen.Unix()+int64(5*nodes.config.Respondd.CollectInterval) < nodes.Timestamp.Unix() {
|
if node.Statistics != nil && nodes.Timestamp.After(node.Lastseen.Add( time.Second * time.Duration (5 * nodes.config.Respondd.CollectInterval ))) {
|
||||||
if node.Flags != nil {
|
if node.Flags != nil {
|
||||||
node.Flags.Online = false
|
node.Flags.Online = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue