netclientutils_darwin.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package ncutils
  2. import (
  3. "log"
  4. "os/exec"
  5. "strings"
  6. )
  7. // RunCmd - runs a local command
  8. func RunCmd(command string, printerr bool) (string, error) {
  9. args := strings.Fields(command)
  10. cmd := exec.Command(args[0], args[1:]...)
  11. cmd.Wait()
  12. out, err := cmd.CombinedOutput()
  13. if err != nil && printerr {
  14. log.Println("error running command:", command)
  15. log.Println(strings.TrimSuffix(string(out), "\n"))
  16. }
  17. return string(out), err
  18. }
  19. // RunCmdFormatted - run a command formatted for MacOS
  20. func RunCmdFormatted(command string, printerr bool) (string, error) {
  21. return "", nil
  22. }
  23. // GetEmbedded - if files required for MacOS, put here
  24. func GetEmbedded() error {
  25. return nil
  26. }
  27. // CreateWireGuardConf - creates a WireGuard conf string
  28. //func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, peers []wgtypes.PeerConfig) (string, error) {
  29. // peersString, err := parsePeers(node.PersistentKeepalive, peers)
  30. // var listenPortString string
  31. // if node.MTU <= 0 {
  32. // node.MTU = 1280
  33. // }
  34. // if listenPort != "" {
  35. // listenPortString += "ListenPort = " + listenPort
  36. // }
  37. // if err != nil {
  38. // return "", err
  39. // }
  40. // config := fmt.Sprintf(`[Interface]
  41. //Address = %s
  42. //PrivateKey = %s
  43. //MTU = %s
  44. //%s
  45. //
  46. //%s
  47. //
  48. //`,
  49. // node.Address+"/32",
  50. // privatekey,
  51. // strconv.Itoa(int(node.MTU)),
  52. // listenPortString,
  53. // peersString)
  54. // return config, nil
  55. //}