mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 07:16:06 +08:00
added better handling of wg ifaces on windows + fix connect issue
This commit is contained in:
parent
4af1823614
commit
3b1ff49344
|
@ -97,7 +97,11 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {
|
|||
logger.Log(1, "error saving node", err.Error())
|
||||
return
|
||||
}
|
||||
updateNodePeers(¤tNode)
|
||||
if ifaceDelta { // reduce number of unneeded updates, by only sending on iface changes
|
||||
if err = PublishPeerUpdate(¤tNode, true); err != nil {
|
||||
logger.Log(0, "error updating peers when node", currentNode.Name, currentNode.ID, "informed the server of an interface change", err.Error())
|
||||
}
|
||||
}
|
||||
logger.Log(1, "updated node", id, newNode.Name)
|
||||
}()
|
||||
}
|
||||
|
|
|
@ -129,9 +129,6 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
|
|||
wireguard.UpdateKeepAlive(file, newNode.PersistentKeepalive)
|
||||
}
|
||||
logger.Log(0, "applying WG conf to "+file)
|
||||
if ncutils.IsWindows() {
|
||||
wireguard.RemoveConfGraceful(nodeCfg.Node.Interface)
|
||||
}
|
||||
err = wireguard.ApplyConf(&nodeCfg.Node, nodeCfg.Node.Interface, file)
|
||||
if err != nil {
|
||||
logger.Log(0, "error restarting wg after node update -", err.Error())
|
||||
|
@ -227,9 +224,6 @@ func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
|
|||
if err := config.ModNodeConfig(&cfg.Node); err != nil {
|
||||
logger.Log(0, "failed to save internet gateway", err.Error())
|
||||
}
|
||||
if ncutils.IsWindows() {
|
||||
wireguard.RemoveConfGraceful(cfg.Node.Interface)
|
||||
}
|
||||
if err := wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, file); err != nil {
|
||||
logger.Log(0, "error applying internet gateway", err.Error())
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ func ApplyConf(node *models.Node, ifacename string, confPath string) error {
|
|||
var err error
|
||||
switch os {
|
||||
case "windows":
|
||||
ApplyWindowsConf(confPath, isConnected)
|
||||
ApplyWindowsConf(confPath, ifacename, isConnected)
|
||||
case "nowgquick":
|
||||
ApplyWithoutWGQuick(node, ifacename, confPath, isConnected)
|
||||
default:
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// ApplyWGQuickConf - applies wg-quick commands if os supports
|
||||
func ApplyWGQuickConf(confPath, ifacename string, isConnected bool) error {
|
||||
if ncutils.IsWindows() {
|
||||
return ApplyWindowsConf(confPath, isConnected)
|
||||
return ApplyWindowsConf(confPath, ifacename, isConnected)
|
||||
} else {
|
||||
_, err := os.Stat(confPath)
|
||||
if err != nil {
|
||||
|
|
|
@ -8,7 +8,9 @@ import (
|
|||
)
|
||||
|
||||
// ApplyWindowsConf - applies the WireGuard configuration file on Windows
|
||||
func ApplyWindowsConf(confPath string, isConnected bool) error {
|
||||
func ApplyWindowsConf(confPath, iface string, isConnected bool) error {
|
||||
RemoveConfGraceful(iface) // have to remove gracefully before applying windows conf
|
||||
|
||||
if !isConnected {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue