2017-04-10 16:54:12 +00:00
|
|
|
package runtime
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/FreifunkBremen/yanic/data"
|
2018-01-07 20:00:56 +00:00
|
|
|
"github.com/FreifunkBremen/yanic/lib/jsontime"
|
2017-04-10 16:54:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Node struct
|
|
|
|
type Node struct {
|
2017-10-18 16:22:14 +00:00
|
|
|
Address *net.UDPAddr `json:"-"` // the last known address
|
2017-04-10 16:54:12 +00:00
|
|
|
Firstseen jsontime.Time `json:"firstseen"`
|
|
|
|
Lastseen jsontime.Time `json:"lastseen"`
|
|
|
|
Online bool `json:"online"`
|
2019-01-19 20:59:43 +00:00
|
|
|
NoRespondd bool `json:"no_respondd"`
|
2017-04-10 16:54:12 +00:00
|
|
|
Statistics *data.Statistics `json:"statistics"`
|
|
|
|
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
|
|
|
|
Neighbours *data.Neighbours `json:"-"`
|
|
|
|
}
|
2017-04-18 01:07:41 +00:00
|
|
|
|
2017-09-27 11:55:02 +00:00
|
|
|
// Link represents a link between two nodes
|
|
|
|
type Link struct {
|
2017-12-05 22:17:49 +00:00
|
|
|
SourceID string
|
|
|
|
SourceAddress string
|
|
|
|
TargetID string
|
|
|
|
TargetAddress string
|
|
|
|
TQ float32
|
2017-09-27 11:55:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-18 01:07:41 +00: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
|
|
|
|
}
|