Browse Source

check for unique mac address on node creation

Matthew R Kasun 3 years ago
parent
commit
8522911524
1 changed files with 5 additions and 0 deletions
  1. 5 0
      controllers/node_grpc.go

+ 5 - 0
controllers/node_grpc.go

@@ -6,6 +6,7 @@ import (
 	"errors"
 	"time"
 
+	"github.com/gravitl/netmaker/functions"
 	nodepb "github.com/gravitl/netmaker/grpc"
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logic"
@@ -68,6 +69,10 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.Object)
 			return nil, errors.New("invalid key, and network does not allow no-key signups")
 		}
 	}
+	unique, _ := functions.IsMacAddressUnique(node.MacAddress, node.Network)
+	if !unique {
+		return nil, errors.New("macaddress is not unique")
+	}
 
 	getServerAddrs(&node)