2021-08-31 03:58:23 +08:00
|
|
|
//go:generate goversioninfo -icon=windowsdata/resource/netmaker.ico -manifest=netclient.exe.manifest.xml -64=true -o=netclient.syso
|
|
|
|
|
2021-03-26 00:17:52 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-07-26 02:22:20 +08:00
|
|
|
"log"
|
|
|
|
"os"
|
2021-09-20 02:03:47 +08:00
|
|
|
"runtime/debug"
|
|
|
|
|
2021-12-09 05:52:32 +08:00
|
|
|
"github.com/gravitl/netmaker/netclient/cli_options"
|
2021-09-20 02:03:47 +08:00
|
|
|
"github.com/gravitl/netmaker/netclient/ncutils"
|
2021-08-31 03:58:23 +08:00
|
|
|
"github.com/gravitl/netmaker/netclient/ncwindows"
|
2021-07-26 02:22:20 +08:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-03-26 00:17:52 +08:00
|
|
|
)
|
|
|
|
|
2022-02-08 20:01:39 +08:00
|
|
|
var version = "dev"
|
|
|
|
|
2021-03-26 00:17:52 +08:00
|
|
|
func main() {
|
2021-07-26 02:22:20 +08:00
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "Netclient CLI"
|
|
|
|
app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
|
2022-02-08 20:01:39 +08:00
|
|
|
app.Version = version
|
|
|
|
ncutils.SetVersion(version)
|
2021-03-26 00:17:52 +08:00
|
|
|
|
2021-12-09 05:52:32 +08:00
|
|
|
cliFlags := cli_options.GetFlags(ncutils.GetHostname())
|
|
|
|
app.Commands = cli_options.GetCommands(cliFlags[:])
|
2021-03-28 00:50:27 +08:00
|
|
|
|
2021-09-11 03:48:18 +08:00
|
|
|
setGarbageCollection()
|
|
|
|
|
2021-09-20 02:03:47 +08:00
|
|
|
if ncutils.IsWindows() {
|
2021-08-31 03:58:23 +08:00
|
|
|
ncwindows.InitWindows()
|
|
|
|
} else {
|
2021-12-09 05:52:32 +08:00
|
|
|
ncutils.CheckUID()
|
|
|
|
ncutils.CheckWG()
|
2021-08-31 03:58:23 +08:00
|
|
|
}
|
2022-02-02 13:18:02 +08:00
|
|
|
|
|
|
|
err := app.Run(os.Args)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
2021-07-26 02:22:20 +08:00
|
|
|
}
|
2021-03-26 00:17:52 +08:00
|
|
|
}
|
2021-09-11 03:48:18 +08:00
|
|
|
|
2021-09-20 02:03:47 +08:00
|
|
|
func setGarbageCollection() {
|
|
|
|
_, gcset := os.LookupEnv("GOGC")
|
2021-09-11 03:48:18 +08:00
|
|
|
if !gcset {
|
2021-09-20 02:03:47 +08:00
|
|
|
debug.SetGCPercent(ncutils.DEFAULT_GC_PERCENT)
|
2021-09-11 03:48:18 +08:00
|
|
|
}
|
2021-09-20 02:03:47 +08:00
|
|
|
}
|