|
@@ -4,6 +4,7 @@ import (
|
|
"context"
|
|
"context"
|
|
"fmt"
|
|
"fmt"
|
|
"log"
|
|
"log"
|
|
|
|
+
|
|
"github.com/gravitl/netmaker/functions"
|
|
"github.com/gravitl/netmaker/functions"
|
|
nodepb "github.com/gravitl/netmaker/grpc"
|
|
nodepb "github.com/gravitl/netmaker/grpc"
|
|
"github.com/gravitl/netmaker/models"
|
|
"github.com/gravitl/netmaker/models"
|
|
@@ -50,8 +51,8 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe
|
|
Postup: node.PostUp,
|
|
Postup: node.PostUp,
|
|
Checkininterval: node.CheckInInterval,
|
|
Checkininterval: node.CheckInInterval,
|
|
Dnsoff: !servercfg.IsDNSMode(),
|
|
Dnsoff: !servercfg.IsDNSMode(),
|
|
- Ispending: node.IsPending,
|
|
|
|
- Isingressgateway: node.IsIngressGateway,
|
|
|
|
|
|
+ Ispending: node.IsPending == "yes",
|
|
|
|
+ Isingressgateway: node.IsIngressGateway == "yes",
|
|
Ingressgatewayrange: node.IngressGatewayRange,
|
|
Ingressgatewayrange: node.IngressGatewayRange,
|
|
Publickey: node.PublicKey,
|
|
Publickey: node.PublicKey,
|
|
Listenport: node.ListenPort,
|
|
Listenport: node.ListenPort,
|
|
@@ -83,7 +84,6 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo
|
|
Password: data.GetPassword(),
|
|
Password: data.GetPassword(),
|
|
Interface: data.GetInterface(),
|
|
Interface: data.GetInterface(),
|
|
Network: data.GetNodenetwork(),
|
|
Network: data.GetNodenetwork(),
|
|
- IsPending: data.GetIspending(),
|
|
|
|
PublicKey: data.GetPublickey(),
|
|
PublicKey: data.GetPublickey(),
|
|
ListenPort: data.GetListenport(),
|
|
ListenPort: data.GetListenport(),
|
|
UDPHolePunch: data.GetUdpholepunch(),
|
|
UDPHolePunch: data.GetUdpholepunch(),
|
|
@@ -101,7 +101,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo
|
|
//Check to see if network will allow manual sign up
|
|
//Check to see if network will allow manual sign up
|
|
//may want to switch this up with the valid key check and avoid a DB call that way.
|
|
//may want to switch this up with the valid key check and avoid a DB call that way.
|
|
if network.AllowManualSignUp == "yes" {
|
|
if network.AllowManualSignUp == "yes" {
|
|
- node.IsPending = true
|
|
|
|
|
|
+ node.IsPending = "yes"
|
|
} else {
|
|
} else {
|
|
return nil, status.Errorf(
|
|
return nil, status.Errorf(
|
|
codes.Internal,
|
|
codes.Internal,
|
|
@@ -133,7 +133,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo
|
|
Interface: node.Interface,
|
|
Interface: node.Interface,
|
|
Nodenetwork: node.Network,
|
|
Nodenetwork: node.Network,
|
|
Dnsoff: !servercfg.IsDNSMode(),
|
|
Dnsoff: !servercfg.IsDNSMode(),
|
|
- Ispending: node.IsPending,
|
|
|
|
|
|
+ Ispending: node.IsPending == "yes",
|
|
Publickey: node.PublicKey,
|
|
Publickey: node.PublicKey,
|
|
Listenport: node.ListenPort,
|
|
Listenport: node.ListenPort,
|
|
Keepalive: node.PersistentKeepalive,
|
|
Keepalive: node.PersistentKeepalive,
|
|
@@ -157,7 +157,7 @@ func (s *NodeServiceServer) CheckIn(ctx context.Context, req *nodepb.CheckInReq)
|
|
data := req.GetNode()
|
|
data := req.GetNode()
|
|
//postchanges := req.GetPostchanges()
|
|
//postchanges := req.GetPostchanges()
|
|
// Now we have to convert this into a NodeItem type to convert into BSON
|
|
// Now we have to convert this into a NodeItem type to convert into BSON
|
|
- log.Println("checkin data:",data)
|
|
|
|
|
|
+ log.Println("checkin data:", data)
|
|
node := models.Node{
|
|
node := models.Node{
|
|
// ID: primitive.NilObjectID,
|
|
// ID: primitive.NilObjectID,
|
|
MacAddress: data.GetMacaddress(),
|
|
MacAddress: data.GetMacaddress(),
|
|
@@ -171,7 +171,7 @@ func (s *NodeServiceServer) CheckIn(ctx context.Context, req *nodepb.CheckInReq)
|
|
PersistentKeepalive: data.GetKeepalive(),
|
|
PersistentKeepalive: data.GetKeepalive(),
|
|
PublicKey: data.GetPublickey(),
|
|
PublicKey: data.GetPublickey(),
|
|
UDPHolePunch: data.GetUdpholepunch(),
|
|
UDPHolePunch: data.GetUdpholepunch(),
|
|
- SaveConfig: data.GetSaveconfig(),
|
|
|
|
|
|
+ SaveConfig: data.GetSaveconfig(),
|
|
}
|
|
}
|
|
|
|
|
|
checkinresponse, err := NodeCheckIn(node, node.Network)
|
|
checkinresponse, err := NodeCheckIn(node, node.Network)
|
|
@@ -203,7 +203,7 @@ func (s *NodeServiceServer) CheckIn(ctx context.Context, req *nodepb.CheckInReq)
|
|
func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNodeReq) (*nodepb.UpdateNodeRes, error) {
|
|
func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNodeReq) (*nodepb.UpdateNodeRes, error) {
|
|
// Get the node data from the request
|
|
// Get the node data from the request
|
|
data := req.GetNode()
|
|
data := req.GetNode()
|
|
- log.Println("DATA:",data)
|
|
|
|
|
|
+ log.Println("DATA:", data)
|
|
// Now we have to convert this into a NodeItem type to convert into BSON
|
|
// Now we have to convert this into a NodeItem type to convert into BSON
|
|
newnode := models.Node{
|
|
newnode := models.Node{
|
|
// ID: primitive.NilObjectID,
|
|
// ID: primitive.NilObjectID,
|
|
@@ -219,11 +219,10 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo
|
|
Interface: data.GetInterface(),
|
|
Interface: data.GetInterface(),
|
|
PostDown: data.GetPostdown(),
|
|
PostDown: data.GetPostdown(),
|
|
PostUp: data.GetPostup(),
|
|
PostUp: data.GetPostup(),
|
|
- IsPending: data.GetIspending(),
|
|
|
|
PublicKey: data.GetPublickey(),
|
|
PublicKey: data.GetPublickey(),
|
|
ListenPort: data.GetListenport(),
|
|
ListenPort: data.GetListenport(),
|
|
UDPHolePunch: data.GetUdpholepunch(),
|
|
UDPHolePunch: data.GetUdpholepunch(),
|
|
- SaveConfig: data.GetSaveconfig(),
|
|
|
|
|
|
+ SaveConfig: data.GetSaveconfig(),
|
|
}
|
|
}
|
|
|
|
|
|
// Convert the Id string to a MongoDB ObjectId
|
|
// Convert the Id string to a MongoDB ObjectId
|
|
@@ -231,7 +230,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo
|
|
networkName := newnode.Network
|
|
networkName := newnode.Network
|
|
network, _ := functions.GetParentNetwork(networkName)
|
|
network, _ := functions.GetParentNetwork(networkName)
|
|
|
|
|
|
- log.Println("NODE SAVECONFIG:",newnode.SaveConfig)
|
|
|
|
|
|
+ log.Println("NODE SAVECONFIG:", newnode.SaveConfig)
|
|
node, err := functions.GetNodeByMacAddress(networkName, macaddress)
|
|
node, err := functions.GetNodeByMacAddress(networkName, macaddress)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, status.Errorf(
|
|
return nil, status.Errorf(
|
|
@@ -261,7 +260,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo
|
|
Postdown: newnode.PostDown,
|
|
Postdown: newnode.PostDown,
|
|
Postup: newnode.PostUp,
|
|
Postup: newnode.PostUp,
|
|
Nodenetwork: newnode.Network,
|
|
Nodenetwork: newnode.Network,
|
|
- Ispending: newnode.IsPending,
|
|
|
|
|
|
+ Ispending: newnode.IsPending == "yes",
|
|
Publickey: newnode.PublicKey,
|
|
Publickey: newnode.PublicKey,
|
|
Dnsoff: !servercfg.IsDNSMode(),
|
|
Dnsoff: !servercfg.IsDNSMode(),
|
|
Listenport: newnode.ListenPort,
|
|
Listenport: newnode.ListenPort,
|