mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-13 16:44:52 +08:00
testing server update
This commit is contained in:
parent
09c2f9bf8b
commit
3964d927ea
3 changed files with 12 additions and 7 deletions
|
@ -569,7 +569,7 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
json.NewEncoder(w).Encode(newNode)
|
json.NewEncoder(w).Encode(newNode)
|
||||||
|
|
||||||
runUpdates(&node, true)
|
runUpdates(&newNode, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteNode(w http.ResponseWriter, r *http.Request) {
|
func deleteNode(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -165,6 +165,9 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("DELETE: new node addres: " + newNode.Address)
|
||||||
|
log.Println("DELETE: current node addres: " + cfg.Node.Address)
|
||||||
|
|
||||||
ncutils.Log("received message to update node " + newNode.Name)
|
ncutils.Log("received message to update node " + newNode.Name)
|
||||||
// see if cache hit, if so skip
|
// see if cache hit, if so skip
|
||||||
var currentMessage = read(newNode.Network, lastNodeUpdate)
|
var currentMessage = read(newNode.Network, lastNodeUpdate)
|
||||||
|
@ -182,6 +185,7 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
|
||||||
//ensure that OS never changes
|
//ensure that OS never changes
|
||||||
newNode.OS = runtime.GOOS
|
newNode.OS = runtime.GOOS
|
||||||
// check if interface needs to delta
|
// check if interface needs to delta
|
||||||
|
log.Println("DELETE: running ifacedelta")
|
||||||
ifaceDelta := ncutils.IfaceDelta(&cfg.Node, &newNode)
|
ifaceDelta := ncutils.IfaceDelta(&cfg.Node, &newNode)
|
||||||
|
|
||||||
cfg.Node = newNode
|
cfg.Node = newNode
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package ncutils
|
package ncutils
|
||||||
|
|
||||||
import "github.com/gravitl/netmaker/models"
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/gravitl/netmaker/models"
|
||||||
|
)
|
||||||
|
|
||||||
func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
|
func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
|
||||||
// single comparison statements
|
// single comparison statements
|
||||||
if currentNode.IsServer != "yes" {
|
log.Println("DELETE: checking stuff")
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if newNode.Endpoint != currentNode.Endpoint ||
|
if newNode.Endpoint != currentNode.Endpoint ||
|
||||||
newNode.LocalAddress != currentNode.LocalAddress ||
|
newNode.LocalAddress != currentNode.LocalAddress ||
|
||||||
newNode.PublicKey != currentNode.PublicKey ||
|
newNode.PublicKey != currentNode.PublicKey ||
|
||||||
|
@ -57,7 +58,7 @@ func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Println("DELETE: guess it's false")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue