add the ability to pass in an auth key file

This commit is contained in:
Aaron Bieber 2022-11-17 06:19:17 -07:00
parent 3673cf1ebf
commit 9a867c7438
No known key found for this signature in database
2 changed files with 8 additions and 1 deletions

View File

@ -15,7 +15,7 @@
in {
tsvnstat = pkgs.buildGoModule {
pname = "tsvnstat";
version = "v0.0.1";
version = "v0.0.2";
src = ./.;
vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM=";

View File

@ -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")