diff --git a/cmd/hvpn-node/hvpn-node.go b/cmd/hvpn-node/hvpn-node.go index 2663292..815bee6 100644 --- a/cmd/hvpn-node/hvpn-node.go +++ b/cmd/hvpn-node/hvpn-node.go @@ -40,21 +40,9 @@ func main() { // TODO: Define error exit codes slog.SetLogLoggerLevel(slog.LevelDebug) - uid := os.Getuid() - if uid == -1 { - slog.Warn("Running on windows! whatrr u doing?") - } else if uid == 0 { - slog.Warn("Running as root! avoid running as root by setting CAP_NET_ADMIN") - } - uuid, err := hvpnnode3.InitNodeUUID() - if err != nil { - slog.Error(err.Error()) - os.Exit(-1) - } - slog.Info("Node UUID: " + uuid.String()) app := createCliApp() - err = app.Run(os.Args) + err := app.Run(os.Args) if err != nil { slog.Error(err.Error()) os.Exit(1) @@ -195,6 +183,19 @@ func createCliApp() *cli.App { func setup() error { slog.Debug("Starting setup()") + uid := os.Getuid() + if uid == -1 { + slog.Warn("Running on windows! whatrr u doing?") + } else if uid == 0 { + slog.Warn("Running as root! avoid running as root by setting CAP_NET_ADMIN") + } + uuid, err := hvpnnode3.InitNodeUUID() + if err != nil { + slog.Error(err.Error()) + os.Exit(-1) + } + slog.Info("Node UUID: " + uuid.String()) + privKeyFile, err := os.Open(PrivateKeyPath) if err != nil { return cli.Exit(err, 1)