diff --git a/pkg/query/struct.go b/pkg/query/struct.go index 1dc5b58..ff4a411 100644 --- a/pkg/query/struct.go +++ b/pkg/query/struct.go @@ -65,8 +65,7 @@ type Answer struct { Class uint16 `json:"CLASS,omitempty" xml:"class,omitempty" yaml:"class,omitempty" example:"A"` ClassName string `json:"CLASSname,omitempty" xml:"CLASSname,omitempty" yaml:"CLASSname,omitempty" example:"A"` TTL string `json:"TTL,omitempty" xml:"ttl,omitempty" yaml:"ttl,omitempty" example:"0ms"` - ValueA string `json:"rdataA,omitempty" xml:"rdataA,omitempty" yaml:"rdataA,omitempty"` - ValueAAAA string `json:"rdataAAAA,omitempty" xml:"rdataAAAA,omitempty" yaml:"rdataAAAA,omitempty"` + Value string `json:"rdata,omitempty" xml:"rdata,omitempty" yaml:"rdata,omitempty"` Rdlength uint16 `json:"RDLENGTH,omitempty" xml:"RDLENGTH,omitempty" yaml:"RDLENGTH,omitempty"` Rdhex string `json:"RDATAHEX,omitempty" xml:"RDATAHEX,omitempty" yaml:"RDATAHEX,omitempty"` } diff --git a/pkg/query/util.go b/pkg/query/util.go index 54611d3..7f0e349 100644 --- a/pkg/query/util.go +++ b/pkg/query/util.go @@ -12,8 +12,6 @@ import ( "golang.org/x/net/idna" ) -const aaaa = "AAAA" - func (message *Message) displayQuestion(msg *dns.Msg, opts *util.Options, opt *dns.OPT) error { var ( name string @@ -67,31 +65,17 @@ func (message *Message) displayAnswers(msg *dns.Msg, opts *util.Options, opt *dn name = answer.Header().Name } - switch dns.TypeToString[answer.Header().Rrtype] { - case "A": - message.AdditionalRRs = append(message.AdditionalRRs, Answer{ - Name: name, - ClassName: dns.ClassToString[answer.Header().Class], - Class: answer.Header().Class, - TypeName: dns.TypeToString[answer.Header().Rrtype], - Type: answer.Header().Rrtype, - Rdlength: answer.Header().Rdlength, - TTL: ttl, - ValueA: temp[len(temp)-1], - }) + message.AnswerRRs = append(message.AnswerRRs, Answer{ + Name: name, + ClassName: dns.ClassToString[answer.Header().Class], + Class: answer.Header().Class, + TypeName: dns.TypeToString[answer.Header().Rrtype], + Type: answer.Header().Rrtype, + Rdlength: answer.Header().Rdlength, + TTL: ttl, - case aaaa: - message.AdditionalRRs = append(message.AdditionalRRs, Answer{ - Name: name, - ClassName: dns.ClassToString[answer.Header().Class], - Class: answer.Header().Class, - TypeName: dns.TypeToString[answer.Header().Rrtype], - Type: answer.Header().Rrtype, - Rdlength: answer.Header().Rdlength, - TTL: ttl, - ValueAAAA: temp[len(temp)-1], - }) - } + Value: temp[len(temp)-1], + }) } return nil @@ -124,31 +108,17 @@ func (message *Message) displayAuthority(msg *dns.Msg, opts *util.Options, opt * name = ns.Header().Name } - switch dns.TypeToString[ns.Header().Rrtype] { - case "A": - message.AdditionalRRs = append(message.AdditionalRRs, Answer{ - Name: name, - TypeName: dns.TypeToString[ns.Header().Rrtype], - Type: ns.Header().Rrtype, - Class: ns.Header().Class, - ClassName: dns.ClassToString[ns.Header().Class], - Rdlength: ns.Header().Rdlength, - TTL: ttl, - ValueA: temp[len(temp)-1], - }) + message.AuthoritativeRRs = append(message.AuthoritativeRRs, Answer{ + Name: name, + TypeName: dns.TypeToString[ns.Header().Rrtype], + Type: ns.Header().Rrtype, + Class: ns.Header().Class, + ClassName: dns.ClassToString[ns.Header().Class], + Rdlength: ns.Header().Rdlength, + TTL: ttl, - case aaaa: - message.AdditionalRRs = append(message.AdditionalRRs, Answer{ - Name: name, - TypeName: dns.TypeToString[ns.Header().Rrtype], - Type: ns.Header().Rrtype, - Class: ns.Header().Class, - ClassName: dns.ClassToString[ns.Header().Class], - Rdlength: ns.Header().Rdlength, - TTL: ttl, - ValueAAAA: temp[len(temp)-1], - }) - } + Value: temp[len(temp)-1], + }) } return nil @@ -183,31 +153,16 @@ func (message *Message) displayAdditional(msg *dns.Msg, opts *util.Options, opt } else { name = additional.Header().Name } - switch dns.TypeToString[additional.Header().Rrtype] { - case "A": - message.AdditionalRRs = append(message.AdditionalRRs, Answer{ - Name: name, - TypeName: dns.TypeToString[additional.Header().Rrtype], - Type: additional.Header().Rrtype, - Class: additional.Header().Rrtype, - ClassName: dns.ClassToString[additional.Header().Class], - Rdlength: additional.Header().Rdlength, - TTL: ttl, - ValueA: temp[len(temp)-1], - }) - - case aaaa: - message.AdditionalRRs = append(message.AdditionalRRs, Answer{ - Name: name, - TypeName: dns.TypeToString[additional.Header().Rrtype], - Type: additional.Header().Rrtype, - Class: additional.Header().Rrtype, - ClassName: dns.ClassToString[additional.Header().Class], - Rdlength: additional.Header().Rdlength, - TTL: ttl, - ValueAAAA: temp[len(temp)-1], - }) - } + message.AdditionalRRs = append(message.AdditionalRRs, Answer{ + Name: name, + TypeName: dns.TypeToString[additional.Header().Rrtype], + Type: additional.Header().Rrtype, + Class: additional.Header().Class, + ClassName: dns.ClassToString[additional.Header().Class], + Rdlength: additional.Header().Rdlength, + TTL: ttl, + Value: temp[len(temp)-1], + }) } }