mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-11 15:44:52 +08:00
* add live status of node * handle static node status * add public IP field to server configuration * get public Ip from config * improve node status logic * improvise status check * use only checkin status on old nodes --------- Co-authored-by: the_aceix <aceixsmartx@gmail.com>
26 lines
471 B
Go
26 lines
471 B
Go
package logic
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/gravitl/netmaker/models"
|
|
)
|
|
|
|
var GetNodeStatus = getNodeStatus
|
|
|
|
func getNodeStatus(node *models.Node, t bool) {
|
|
// On CE check only last check-in time
|
|
if node.IsStatic {
|
|
if !node.StaticNode.Enabled {
|
|
node.Status = models.OfflineSt
|
|
return
|
|
}
|
|
node.Status = models.OnlineSt
|
|
return
|
|
}
|
|
if time.Since(node.LastCheckIn) > time.Minute*10 {
|
|
node.Status = models.OfflineSt
|
|
return
|
|
}
|
|
node.Status = models.OnlineSt
|
|
}
|