Browse Source

bug squashin

worker-9 4 years ago
parent
commit
68a3109cae
3 changed files with 11 additions and 3 deletions
  1. 8 0
      models/node.go
  2. 1 1
      netclient/functions/checkin.go
  3. 2 2
      netclient/server/grpc.go

+ 8 - 0
models/node.go

@@ -20,6 +20,7 @@ const TEN_YEARS_IN_SECONDS = 300000000
 const NODE_UPDATE_KEY = "updatekey"
 const NODE_UPDATE_KEY = "updatekey"
 const NODE_DELETE = "delete"
 const NODE_DELETE = "delete"
 const NODE_IS_PENDING = "pending"
 const NODE_IS_PENDING = "pending"
+const NODE_NOOP = "noop"
 
 
 var seededRand *rand.Rand = rand.New(
 var seededRand *rand.Rand = rand.New(
 	rand.NewSource(time.Now().UnixNano()))
 	rand.NewSource(time.Now().UnixNano()))
@@ -68,6 +69,12 @@ type Node struct {
 	IPForwarding        string   `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"`
 	IPForwarding        string   `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"`
 }
 }
 
 
+func (node *Node) SetDefaultAction() {
+	if node.Action == "" {
+		node.Action = NODE_NOOP
+	}
+}
+
 func (node *Node) SetRoamingDefault() {
 func (node *Node) SetRoamingDefault() {
 	if node.Roaming == "" {
 	if node.Roaming == "" {
 		node.Roaming = "no"
 		node.Roaming = "no"
@@ -197,6 +204,7 @@ func (node *Node) SetDefaults() {
 	node.SetLastPeerUpdate()
 	node.SetLastPeerUpdate()
 	node.SetRoamingDefault()
 	node.SetRoamingDefault()
 	node.SetPullChangesDefault()
 	node.SetPullChangesDefault()
+	node.SetDefaultAction()
 	node.SetID()
 	node.SetID()
 	node.KeyUpdateTimeStamp = time.Now().Unix()
 	node.KeyUpdateTimeStamp = time.Now().Unix()
 }
 }

+ 1 - 1
netclient/functions/checkin.go

@@ -98,7 +98,7 @@ func checkNodeActions(node *models.Node, network string, servercfg config.Server
 			log.Println("Unable to process reset keys request:", err)
 			log.Println("Unable to process reset keys request:", err)
 			return ""
 			return ""
 		}
 		}
-		node.Action = ""
+		node.Action = models.NODE_NOOP
 		if err = config.ModConfig(node); err != nil {
 		if err = config.ModConfig(node); err != nil {
 			return ""
 			return ""
 		}
 		}

+ 2 - 2
netclient/server/grpc.go

@@ -166,8 +166,8 @@ func GetPeers(macaddress string, network string, server string, dualstack bool,
 		Data: macaddress + "###" + network,
 		Data: macaddress + "###" + network,
 		Type: nodepb.STRING_TYPE,
 		Type: nodepb.STRING_TYPE,
 	}
 	}
-	ctx := context.Background()
-	ctx, err = auth.SetJWT(wcclient, network)
+
+	ctx, err := auth.SetJWT(wcclient, network)
 	if err != nil {
 	if err != nil {
 		log.Println("Failed to authenticate.")
 		log.Println("Failed to authenticate.")
 		return peers, hasGateway, gateways, err
 		return peers, hasGateway, gateways, err