netmaker/netclient/wireguard/windows.go

26 lines
740 B
Go
Raw Normal View History

2021-09-20 02:03:47 +08:00
package wireguard
2021-11-18 10:57:27 +08:00
import (
"fmt"
"github.com/gravitl/netmaker/logger"
2021-11-18 10:57:27 +08:00
"github.com/gravitl/netmaker/netclient/ncutils"
)
2021-09-20 02:03:47 +08:00
2021-12-12 23:16:53 +08:00
// ApplyWindowsConf - applies the WireGuard configuration file on Windows
2021-09-20 02:03:47 +08:00
func ApplyWindowsConf(confPath string) error {
2021-11-18 10:57:27 +08:00
var commandLine = fmt.Sprintf(`wireguard.exe /installtunnelservice "%s"`, confPath)
if _, err := ncutils.RunCmdFormatted(commandLine, false); err != nil {
2021-09-20 02:03:47 +08:00
return err
}
return nil
}
2021-12-12 23:16:53 +08:00
// RemoveWindowsConf - removes the WireGuard configuration file on Windows and dpapi file
2021-09-20 02:03:47 +08:00
func RemoveWindowsConf(ifacename string, printlog bool) error {
if _, err := ncutils.RunCmd("wireguard.exe /uninstalltunnelservice "+ifacename, printlog); err != nil {
logger.Log(1, err.Error())
2021-12-12 23:16:53 +08:00
}
2021-09-20 02:03:47 +08:00
return nil
}