Browse Source

add node to zombie list after expiration

Anish Mukherjee 2 years ago
parent
commit
d8fe0b5194
1 changed files with 2 additions and 1 deletions
  1. 2 1
      logic/zombie.go

+ 2 - 1
logic/zombie.go

@@ -25,6 +25,7 @@ var (
 
 // CheckZombies - checks if new node has same macaddress as existing node
 // if so, existing node is added to zombie node quarantine list
+// also cleans up nodes past their expiration date
 func CheckZombies(newnode *models.Node, mac net.HardwareAddr) {
 	nodes, err := GetNetworkNodes(newnode.Network)
 	if err != nil {
@@ -37,7 +38,7 @@ func CheckZombies(newnode *models.Node, mac net.HardwareAddr) {
 			// should we delete the node if host not found ??
 			continue
 		}
-		if host.MacAddress.String() == mac.String() {
+		if host.MacAddress.String() == mac.String() || time.Now().After(node.ExpirationDateTime) {
 			logger.Log(0, "adding ", node.ID.String(), " to zombie list")
 			newZombie <- node.ID
 		}