From 792ddecf6c1c77bcb5dca71e3879ce70fe1693cc Mon Sep 17 00:00:00 2001 From: Sam Therapy Date: Thu, 15 Dec 2022 19:30:01 +0000 Subject: [PATCH] fix(print): use any on TTL (#169) This allows JSON to use either an int or string depending on output Reviewed-on: https://git.froth.zone/sam/awl/pulls/169 Reviewed-by: grumbulon --- pkg/query/print.go | 4 ++-- pkg/query/struct.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/query/print.go b/pkg/query/print.go index 33734d6..edfb72a 100644 --- a/pkg/query/print.go +++ b/pkg/query/print.go @@ -302,7 +302,7 @@ func MakePrintable(res util.Response, opts *util.Options) (*Message, error) { temp := strings.Split(answer.String(), "\t") var ( - ttl string + ttl any name string ) @@ -310,7 +310,7 @@ func MakePrintable(res util.Response, opts *util.Options) (*Message, error) { if opts.Display.HumanTTL { ttl = (time.Duration(answer.Header().Ttl) * time.Second).String() } else { - ttl = strconv.Itoa(int(answer.Header().Ttl)) + ttl = answer.Header().Ttl } } diff --git a/pkg/query/struct.go b/pkg/query/struct.go index 3ad2159..1b063c3 100644 --- a/pkg/query/struct.go +++ b/pkg/query/struct.go @@ -51,7 +51,7 @@ type Question struct { // RRHeader is for DNS Resource Headers. type RRHeader struct { Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty" example:"127.0.0.1"` - TTL string `json:"ttl,omitempty" xml:"ttl,omitempty" yaml:"ttl,omitempty" example:"0ms"` + TTL any `json:"ttl,omitempty" xml:"ttl,omitempty" yaml:"ttl,omitempty" example:"0ms"` Class string `json:"class,omitempty" xml:"class,omitempty" yaml:"class,omitempty" example:"A"` Type string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"` Rdlength uint16 `json:"-" xml:"-" yaml:"-"`