mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-27 09:36:08 +08:00
fixed issues around windows
This commit is contained in:
parent
6724e1226d
commit
98023deeb9
2 changed files with 10 additions and 5 deletions
|
@ -39,7 +39,7 @@ func RestartWindowsDaemon() {
|
|||
StopWindowsDaemon()
|
||||
// start daemon, will not restart or start another
|
||||
ncutils.RunCmd(strings.Replace(ncutils.GetNetclientPathSpecific(), `\\`, `\`, -1)+`winsw.exe start`, false)
|
||||
ncutils.Log(strings.Replace(ncutils.GetNetclientPathSpecific(), `\\`, `\`, -1) + `winsw.exe start`)
|
||||
// ncutils.Log(strings.Replace(ncutils.GetNetclientPathSpecific(), `\\`, `\`, -1) + `winsw.exe start`)
|
||||
}
|
||||
|
||||
// CleanupWindows - cleans up windows files
|
||||
|
@ -78,7 +78,7 @@ func writeServiceConfig() error {
|
|||
|
||||
// StopWindowsDaemon - stops the Windows daemon
|
||||
func StopWindowsDaemon() {
|
||||
ncutils.Log("no networks detected, stopping Windows, Netclient daemon")
|
||||
ncutils.Log("stopping Windows, Netclient daemon")
|
||||
// stop daemon, will not overwrite
|
||||
ncutils.RunCmd(strings.Replace(ncutils.GetNetclientPathSpecific(), `\\`, `\`, -1)+`winsw.exe stop`, true)
|
||||
}
|
||||
|
|
|
@ -167,6 +167,7 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
}
|
||||
// ensure you clear any existing interface first
|
||||
d, _ := wgclient.Device(deviceiface)
|
||||
startTime := time.Now()
|
||||
for d != nil && d.Name == deviceiface {
|
||||
if err = RemoveConf(deviceiface, false); err != nil { // remove interface first
|
||||
if strings.Contains(err.Error(), "does not exist") {
|
||||
|
@ -176,6 +177,9 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
}
|
||||
time.Sleep(time.Second >> 2)
|
||||
d, _ = wgclient.Device(deviceiface)
|
||||
if time.Now().After(startTime.Add(time.Second << 4)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
ApplyConf(node, ifacename, confPath) // Apply initially
|
||||
ncutils.PrintLog("waiting for interface...", 1) // ensure interface is created
|
||||
|
@ -207,6 +211,7 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
}
|
||||
ncutils.PrintLog("interface ready - netclient.. ENGAGE", 1)
|
||||
if syncconf { // should never be called really.
|
||||
fmt.Println("why here")
|
||||
err = SyncWGQuickConf(ifacename, confPath)
|
||||
}
|
||||
if !ncutils.HasWgQuick() && ncutils.IsLinux() {
|
||||
|
@ -269,7 +274,7 @@ func SetWGConfig(network string, peerupdate bool) error {
|
|||
// RemoveConf - removes a configuration for a given WireGuard interface
|
||||
func RemoveConf(iface string, printlog bool) error {
|
||||
os := runtime.GOOS
|
||||
if !ncutils.HasWgQuick() {
|
||||
if ncutils.IsLinux() && !ncutils.HasWgQuick() {
|
||||
os = "nowgquick"
|
||||
}
|
||||
var err error
|
||||
|
@ -295,12 +300,12 @@ func ApplyConf(node *models.Node, ifacename string, confPath string) error {
|
|||
}
|
||||
var err error
|
||||
switch os {
|
||||
case "nowgquick":
|
||||
ApplyWithoutWGQuick(node, ifacename, confPath)
|
||||
case "windows":
|
||||
ApplyWindowsConf(confPath)
|
||||
case "darwin":
|
||||
ApplyMacOSConf(node, ifacename, confPath)
|
||||
case "nowgquick":
|
||||
ApplyWithoutWGQuick(node, ifacename, confPath)
|
||||
default:
|
||||
ApplyWGQuickConf(confPath, ifacename)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue