main.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //go:generate goversioninfo -icon=windowsdata/resource/netmaker.ico -manifest=netclient.exe.manifest.xml -64=true -o=netclient.syso
  2. package main
  3. import (
  4. "log"
  5. "os"
  6. "runtime/debug"
  7. "github.com/gravitl/netmaker/netclient/cli_options"
  8. "github.com/gravitl/netmaker/netclient/ncutils"
  9. "github.com/gravitl/netmaker/netclient/ncwindows"
  10. "github.com/urfave/cli/v2"
  11. )
  12. func main() {
  13. app := cli.NewApp()
  14. app.Name = "Netclient CLI"
  15. app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
  16. app.Version = ncutils.Version
  17. cliFlags := cli_options.GetFlags(ncutils.GetHostname())
  18. app.Commands = cli_options.GetCommands(cliFlags[:])
  19. setGarbageCollection()
  20. if ncutils.IsWindows() {
  21. ncwindows.InitWindows()
  22. } else {
  23. ncutils.CheckUID()
  24. ncutils.CheckWG()
  25. }
  26. err := app.Run(os.Args)
  27. if err != nil {
  28. log.Fatal(err)
  29. }
  30. }
  31. func setGarbageCollection() {
  32. _, gcset := os.LookupEnv("GOGC")
  33. if !gcset {
  34. debug.SetGCPercent(ncutils.DEFAULT_GC_PERCENT)
  35. }
  36. }