Remove Gateway field

This commit is contained in:
Julian Kornberger 2017-04-18 03:07:41 +02:00
parent 8b8b1441ba
commit 0df8f5d615
5 changed files with 11 additions and 5 deletions

View File

@ -33,7 +33,7 @@ func BuildNodesV1(nodes *runtime.Nodes) interface{} {
Lastseen: nodeOrigin.Lastseen,
Flags: Flags{
Online: nodeOrigin.Online,
Gateway: nodeOrigin.Gateway,
Gateway: nodeOrigin.IsGateway(),
},
Nodeinfo: nodeOrigin.Nodeinfo,
}

View File

@ -30,7 +30,7 @@ func BuildNodesV2(nodes *runtime.Nodes) interface{} {
Lastseen: nodeOrigin.Lastseen,
Flags: Flags{
Online: nodeOrigin.Online,
Gateway: nodeOrigin.Gateway,
Gateway: nodeOrigin.IsGateway(),
},
Nodeinfo: nodeOrigin.Nodeinfo,
}

View File

@ -13,8 +13,15 @@ type Node struct {
Firstseen jsontime.Time `json:"firstseen"`
Lastseen jsontime.Time `json:"lastseen"`
Online bool `json:"online"`
Gateway bool `json:"gateway"`
Statistics *data.Statistics `json:"statistics"`
Nodeinfo *data.NodeInfo `json:"nodeinfo"`
Neighbours *data.Neighbours `json:"-"`
}
// IsGateway returns whether the node is a gateway
func (node *Node) IsGateway() bool {
if info := node.Nodeinfo; info != nil {
return info.VPN
}
return false
}

View File

@ -63,7 +63,6 @@ func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node {
// Update nodeinfo
if val := res.NodeInfo; val != nil {
node.Nodeinfo = val
node.Gateway = val.VPN
}
// Update statistics

View File

@ -33,7 +33,7 @@ func NewGlobalStats(nodes *Nodes) (result *GlobalStats) {
result.ClientsWifi5 += stats.Clients.Wifi5
result.ClientsWifi += stats.Clients.Wifi
}
if node.Gateway {
if node.IsGateway() {
result.Gateways++
}
if info := node.Nodeinfo; info != nil {