mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-09 14:46:36 +08:00
1
This commit is contained in:
parent
70f9bfcb16
commit
595e00125b
3 changed files with 21 additions and 7 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/logic"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
"github.com/gravitl/netmaker/mq"
|
||||
"github.com/gravitl/netmaker/servercfg"
|
||||
"github.com/gravitl/netmaker/serverctl"
|
||||
)
|
||||
|
@ -118,7 +119,9 @@ func keyUpdate(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
for _, node := range nodes {
|
||||
logger.Log(3, "updating node ", node.Name, " for a key update")
|
||||
runUpdates(&node, true)
|
||||
if node.IsServer != "yes" {
|
||||
runUpdates(&node, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +191,9 @@ func updateNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
for _, node := range nodes {
|
||||
runUpdates(&node, true)
|
||||
if err = mq.NodeUpdate(&node); err != nil {
|
||||
logger.Log(1, "failed to send update to node during a network wide update", node.Name, node.ID, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ func Daemon() error {
|
|||
|
||||
// UpdateKeys -- updates private key and returns new publickey
|
||||
func UpdateKeys(nodeCfg *config.ClientConfig, client mqtt.Client) error {
|
||||
ncutils.Log("received message to update keys")
|
||||
ncutils.Log("received message to update wireguard keys for network " + nodeCfg.Network)
|
||||
key, err := wgtypes.GeneratePrivateKey()
|
||||
if err != nil {
|
||||
ncutils.Log("error generating privatekey " + err.Error())
|
||||
|
|
|
@ -293,14 +293,23 @@ func ApplyConf(node *models.Node, ifacename string, confPath string) error {
|
|||
var err error
|
||||
switch os {
|
||||
case "nowgquick":
|
||||
err = ApplyWithoutWGQuick(node, ifacename, confPath)
|
||||
ApplyWithoutWGQuick(node, ifacename, confPath)
|
||||
case "windows":
|
||||
_ = ApplyWindowsConf(confPath)
|
||||
ApplyWindowsConf(confPath)
|
||||
case "darwin":
|
||||
_ = ApplyMacOSConf(node, ifacename, confPath)
|
||||
ApplyMacOSConf(node, ifacename, confPath)
|
||||
default:
|
||||
err = ApplyWGQuickConf(confPath, ifacename)
|
||||
ApplyWGQuickConf(confPath, ifacename)
|
||||
}
|
||||
|
||||
var nodeCfg config.ClientConfig
|
||||
nodeCfg.Network = node.Network
|
||||
nodeCfg.ReadConfig()
|
||||
ip, cidr, err := net.ParseCIDR(nodeCfg.NetworkSettings.AddressRange)
|
||||
if err == nil {
|
||||
local.SetCIDRRoute(node.Interface, ip.String(), cidr)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue