2017-04-10 18:54:12 +02:00
|
|
|
package runtime
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
2018-01-07 21:00:56 +01:00
|
|
|
"github.com/FreifunkBremen/yanic/lib/jsontime"
|
2017-04-10 18:54:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Node struct
|
|
|
|
type Node struct {
|
2017-10-18 18:22:14 +02:00
|
|
|
Address *net.UDPAddr `json:"-"` // the last known address
|
2017-04-10 18:54:12 +02:00
|
|
|
Firstseen jsontime.Time `json:"firstseen"`
|
|
|
|
Lastseen jsontime.Time `json:"lastseen"`
|
|
|
|
Online bool `json:"online"`
|
2019-01-19 21:59:43 +01:00
|
|
|
NoRespondd bool `json:"no_respondd"`
|
2017-04-10 18:54:12 +02:00
|
|
|
Statistics *data.Statistics `json:"statistics"`
|
2019-01-24 02:56:13 +01:00
|
|
|
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
|
2017-04-10 18:54:12 +02:00
|
|
|
Neighbours *data.Neighbours `json:"-"`
|
|
|
|
}
|
2017-04-18 03:07:41 +02:00
|
|
|
|
2017-09-27 13:55:02 +02:00
|
|
|
// Link represents a link between two nodes
|
|
|
|
type Link struct {
|
2017-12-05 23:17:49 +01:00
|
|
|
SourceID string
|
|
|
|
SourceAddress string
|
|
|
|
TargetID string
|
|
|
|
TargetAddress string
|
|
|
|
TQ float32
|
2017-09-27 13:55:02 +02:00
|
|
|
}
|
|
|
|
|
2017-04-18 03:07:41 +02:00
|
|
|
// IsGateway returns whether the node is a gateway
|
|
|
|
func (node *Node) IsGateway() bool {
|
|
|
|
if info := node.Nodeinfo; info != nil {
|
|
|
|
return info.VPN
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|