fix(print): use any on TTL (#169)
All checks were successful
continuous-integration/drone/push Build is passing

This allows JSON to use either an int or string depending on output

Reviewed-on: #169
Reviewed-by: grumbulon <grumbulon@grumbulon.xyz>
This commit is contained in:
Sam Therapy 2022-12-15 19:30:01 +00:00
parent 10d1c4cd2b
commit 792ddecf6c
Signed by: Froth Git
GPG key ID: 5D8CD75CC6B79913
2 changed files with 3 additions and 3 deletions

View file

@ -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
}
}

View file

@ -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:"-"`