windows.go 740 B

12345678910111213141516171819202122232425
  1. package wireguard
  2. import (
  3. "fmt"
  4. "github.com/gravitl/netmaker/logger"
  5. "github.com/gravitl/netmaker/netclient/ncutils"
  6. )
  7. // ApplyWindowsConf - applies the WireGuard configuration file on Windows
  8. func ApplyWindowsConf(confPath string) error {
  9. var commandLine = fmt.Sprintf(`wireguard.exe /installtunnelservice "%s"`, confPath)
  10. if _, err := ncutils.RunCmdFormatted(commandLine, false); err != nil {
  11. return err
  12. }
  13. return nil
  14. }
  15. // RemoveWindowsConf - removes the WireGuard configuration file on Windows and dpapi file
  16. func RemoveWindowsConf(ifacename string, printlog bool) error {
  17. if _, err := ncutils.RunCmd("wireguard.exe /uninstalltunnelservice "+ifacename, printlog); err != nil {
  18. logger.Log(1, err.Error())
  19. }
  20. return nil
  21. }