From 9f4bb8fe4a4a614a75a8707931c557d9de96167e Mon Sep 17 00:00:00 2001 From: Sam Therapy Date: Thu, 15 Dec 2022 19:42:38 +0100 Subject: [PATCH] fix(print): use any on TTL This allows JSON to use either an int or string depending on output Signed-off-by: Sam Therapy --- 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:"-"` -- 2.45.2