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 {
|
2019-11-17 10:44:11 +01:00
|
|
|
Address *net.UDPAddr `json:"-"` // the last known address
|
|
|
|
Firstseen jsontime.Time `json:"firstseen"`
|
|
|
|
Lastseen jsontime.Time `json:"lastseen"`
|
|
|
|
Online bool `json:"online"`
|
|
|
|
Statistics *data.Statistics `json:"statistics"`
|
|
|
|
Nodeinfo *data.Nodeinfo `json:"nodeinfo"`
|
|
|
|
Neighbours *data.Neighbours `json:"-"`
|
|
|
|
CustomFields map[string]interface{} `json:"custom_fields"`
|
2017-04-10 18:54:12 +02:00
|
|
|
}
|
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 {
|
[TASK] add output raw-jsonl
PR at github: #199
This output takes the respondd response as sent by the node and includes
it in a Line-Delimited JSON (JSONL) document. In this format each line
can be interpreted as separate JSON element, which is useful for json
streaming. The first line is json object holding the timestamp and
version of the file. Then there follows one line for each node, each
containing a json object.
An example output looks like this:
{"version":1,"updated_at":"2021-03-27T21:58:48+0100","format":"raw-nodes-jsonl"}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
...
Signed-off-by: Leonardo Mörlein <git@irrelefant.net>
2021-03-29 16:12:26 +02:00
|
|
|
SourceID string
|
2021-03-26 10:18:29 +01:00
|
|
|
SourceHostname string
|
[TASK] add output raw-jsonl
PR at github: #199
This output takes the respondd response as sent by the node and includes
it in a Line-Delimited JSON (JSONL) document. In this format each line
can be interpreted as separate JSON element, which is useful for json
streaming. The first line is json object holding the timestamp and
version of the file. Then there follows one line for each node, each
containing a json object.
An example output looks like this:
{"version":1,"updated_at":"2021-03-27T21:58:48+0100","format":"raw-nodes-jsonl"}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
...
Signed-off-by: Leonardo Mörlein <git@irrelefant.net>
2021-03-29 16:12:26 +02:00
|
|
|
SourceAddress string
|
|
|
|
TargetID string
|
|
|
|
TargetAddress string
|
2021-03-26 10:18:29 +01:00
|
|
|
TargetHostname string
|
[TASK] add output raw-jsonl
PR at github: #199
This output takes the respondd response as sent by the node and includes
it in a Line-Delimited JSON (JSONL) document. In this format each line
can be interpreted as separate JSON element, which is useful for json
streaming. The first line is json object holding the timestamp and
version of the file. Then there follows one line for each node, each
containing a json object.
An example output looks like this:
{"version":1,"updated_at":"2021-03-27T21:58:48+0100","format":"raw-nodes-jsonl"}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
{"firstseen": ..., "lastseen": ..., "online":true, "statistics": {...}, "nodeinfo": {...}, "neighbours":null, "custom_fields":null}
...
Signed-off-by: Leonardo Mörlein <git@irrelefant.net>
2021-03-29 16:12:26 +02:00
|
|
|
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
|
|
|
|
}
|