From 8187085e39c3447261c9e3bd19506007371e30ca Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 21 Jun 2020 12:33:43 +0200 Subject: [PATCH] Added missing cmd --- .gitignore | 2 +- cmd/headscale/headscale.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cmd/headscale/headscale.go diff --git a/.gitignore b/.gitignore index 751dd847..a5915f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,5 @@ # vendor/ config.json -headscale +./headscale *.key diff --git a/cmd/headscale/headscale.go b/cmd/headscale/headscale.go new file mode 100644 index 00000000..72186b09 --- /dev/null +++ b/cmd/headscale/headscale.go @@ -0,0 +1,36 @@ +package main + +import ( + "log" + + "github.com/juanfont/headscale" + "github.com/spf13/viper" +) + +func main() { + viper.SetConfigName("config") + viper.AddConfigPath(".") + viper.AutomaticEnv() + err := viper.ReadInConfig() + if err != nil { + log.Fatalf("Fatal error config file: %s \n", err) + } + + cfg := headscale.Config{ + ServerURL: viper.GetString("server_url"), + Addr: viper.GetString("listen_addr"), + PrivateKeyPath: viper.GetString("private_key_path"), + + DBhost: viper.GetString("db_host"), + DBport: viper.GetInt("db_port"), + DBname: viper.GetString("db_name"), + DBuser: viper.GetString("db_user"), + DBpass: viper.GetString("db_pass"), + } + h, err := headscale.NewHeadscale(cfg) + if err != nil { + log.Fatalln(err) + } + + h.Serve() +}