main.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. var version = "dev"
  13. func main() {
  14. app := cli.NewApp()
  15. app.Name = "Netclient CLI"
  16. app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
  17. app.Version = version
  18. ncutils.SetVersion(version)
  19. cliFlags := cli_options.GetFlags(ncutils.GetHostname())
  20. app.Commands = cli_options.GetCommands(cliFlags[:])
  21. setGarbageCollection()
  22. if ncutils.IsWindows() {
  23. ncwindows.InitWindows()
  24. } else {
  25. ncutils.CheckUID()
  26. ncutils.CheckWG()
  27. }
  28. err := app.Run(os.Args)
  29. if err != nil {
  30. log.Fatal(err)
  31. }
  32. }
  33. func setGarbageCollection() {
  34. _, gcset := os.LookupEnv("GOGC")
  35. if !gcset {
  36. debug.SetGCPercent(ncutils.DEFAULT_GC_PERCENT)
  37. }
  38. }