From 3ad2350c798a7a4027f4ecd43d8b44f82c767d37 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 5 Nov 2021 07:24:00 +0000 Subject: [PATCH] Fix new version of hujson --- acls.go | 9 ++++++++- acls_types.go | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/acls.go b/acls.go index 4d4d45b..cb02e04 100644 --- a/acls.go +++ b/acls.go @@ -38,7 +38,14 @@ func (h *Headscale) LoadACLPolicy(path string) error { if err != nil { return err } - err = hujson.Unmarshal(b, &policy) + + ast, err := hujson.Parse(b) + if err != nil { + return err + } + ast.Standardize() + b = ast.Pack() + err = json.Unmarshal(b, &policy) if err != nil { return err } diff --git a/acls_types.go b/acls_types.go index 01e42d5..67b74e7 100644 --- a/acls_types.go +++ b/acls_types.go @@ -1,6 +1,7 @@ package headscale import ( + "encoding/json" "strings" "github.com/tailscale/hujson" @@ -43,7 +44,13 @@ type ACLTest struct { func (h *Hosts) UnmarshalJSON(data []byte) error { hosts := Hosts{} hs := make(map[string]string) - err := hujson.Unmarshal(data, &hs) + ast, err := hujson.Parse(data) + if err != nil { + return err + } + ast.Standardize() + data = ast.Pack() + err = json.Unmarshal(data, &hs) if err != nil { return err }