From 9a867c7438361310d1db0282309307cc1e2814f1 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Thu, 17 Nov 2022 06:19:17 -0700 Subject: [PATCH] add the ability to pass in an auth key file --- flake.nix | 2 +- main.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index e003d90..a37a9f2 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ in { tsvnstat = pkgs.buildGoModule { pname = "tsvnstat"; - version = "v0.0.1"; + version = "v0.0.2"; src = ./.; vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM="; diff --git a/main.go b/main.go index 8282176..a4a8c1a 100644 --- a/main.go +++ b/main.go @@ -51,10 +51,17 @@ func main() { name := flag.String("name", "", "name of service") dir := flag.String("dir", tmpDir, "directory containing vnstat images") + key := flag.String("key", "", "path to file containing the api key") flag.Parse() + keyData, err := os.ReadFile(*key) + if err != nil { + log.Fatal(err) + } + s := &tsnet.Server{ Hostname: *name, + AuthKey: string(keyData), } ln, err := s.Listen("tcp", ":80")