mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 21:54:54 +08:00
added better handling of wg ifaces on windows + fix connect issue
This commit is contained in:
parent
4af1823614
commit
3b1ff49344
5 changed files with 10 additions and 10 deletions
|
@ -97,7 +97,11 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {
|
||||||
logger.Log(1, "error saving node", err.Error())
|
logger.Log(1, "error saving node", err.Error())
|
||||||
return
|
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)
|
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)
|
wireguard.UpdateKeepAlive(file, newNode.PersistentKeepalive)
|
||||||
}
|
}
|
||||||
logger.Log(0, "applying WG conf to "+file)
|
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)
|
err = wireguard.ApplyConf(&nodeCfg.Node, nodeCfg.Node.Interface, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log(0, "error restarting wg after node update -", err.Error())
|
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 {
|
if err := config.ModNodeConfig(&cfg.Node); err != nil {
|
||||||
logger.Log(0, "failed to save internet gateway", err.Error())
|
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 {
|
if err := wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, file); err != nil {
|
||||||
logger.Log(0, "error applying internet gateway", err.Error())
|
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
|
var err error
|
||||||
switch os {
|
switch os {
|
||||||
case "windows":
|
case "windows":
|
||||||
ApplyWindowsConf(confPath, isConnected)
|
ApplyWindowsConf(confPath, ifacename, isConnected)
|
||||||
case "nowgquick":
|
case "nowgquick":
|
||||||
ApplyWithoutWGQuick(node, ifacename, confPath, isConnected)
|
ApplyWithoutWGQuick(node, ifacename, confPath, isConnected)
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
// ApplyWGQuickConf - applies wg-quick commands if os supports
|
// ApplyWGQuickConf - applies wg-quick commands if os supports
|
||||||
func ApplyWGQuickConf(confPath, ifacename string, isConnected bool) error {
|
func ApplyWGQuickConf(confPath, ifacename string, isConnected bool) error {
|
||||||
if ncutils.IsWindows() {
|
if ncutils.IsWindows() {
|
||||||
return ApplyWindowsConf(confPath, isConnected)
|
return ApplyWindowsConf(confPath, ifacename, isConnected)
|
||||||
} else {
|
} else {
|
||||||
_, err := os.Stat(confPath)
|
_, err := os.Stat(confPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -8,7 +8,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ApplyWindowsConf - applies the WireGuard configuration file on Windows
|
// 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 {
|
if !isConnected {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue