mirror of
				https://github.com/gravitl/netmaker.git
				synced 2025-10-31 08:26:23 +08:00 
			
		
		
		
	* add node status api * upsate node status api to return map data * resolve merge conflicts
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			555 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			555 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package logic
 | |
| 
 | |
| import (
 | |
| 	"time"
 | |
| 
 | |
| 	"github.com/gravitl/netmaker/models"
 | |
| )
 | |
| 
 | |
| var GetNodeStatus = GetNodeCheckInStatus
 | |
| 
 | |
| func GetNodeCheckInStatus(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 !node.Connected {
 | |
| 		node.Status = models.Disconnected
 | |
| 		return
 | |
| 	}
 | |
| 	if time.Since(node.LastCheckIn) > time.Minute*10 {
 | |
| 		node.Status = models.OfflineSt
 | |
| 		return
 | |
| 	}
 | |
| 	node.Status = models.OnlineSt
 | |
| }
 |