From 9226d0cdf06df7ceec2eaefbd834ce68e92e2b0c Mon Sep 17 00:00:00 2001 From: Sam Therapy Date: Thu, 15 Dec 2022 23:49:02 +0100 Subject: [PATCH] small things to make more correct Signed-off-by: Sam Therapy --- pkg/query/struct.go | 14 +++++++------- pkg/query/util.go | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pkg/query/struct.go b/pkg/query/struct.go index 877c05c..b95a1da 100644 --- a/pkg/query/struct.go +++ b/pkg/query/struct.go @@ -28,7 +28,7 @@ type Message struct { Name string `json:"QNAME,omitempty" xml:"QNAME,omitempty" yaml:"QNAME,omitempty" example:"localhost"` Type uint16 `json:"QTYPE,omitempty" xml:"QTYPE,omitempty" yaml:"QTYPE,omitempty" example:"IN"` TypeName string `json:"QTYPEname,omitempty" xml:"QTYPEname,omitempty" yaml:"QTYPEname,omitempty" example:"IN"` - Class string `json:"QCLASS,omitempty" xml:"QCLASS,omitempty" yaml:"QCLASS,omitempty" example:"A"` + Class uint16 `json:"QCLASS,omitempty" xml:"QCLASS,omitempty" yaml:"QCLASS,omitempty" example:"A"` ClassName string `json:"QCLASSname,omitempty" xml:"QCLASSname,omitempty" yaml:"QCLASSname,omitempty" example:"1"` RTT string `json:"queryTime,omitempty" xml:"queryTime,omitempty" yaml:"queryTime,omitempty"` Server string `json:"server,omitempty" xml:"server,omitempty" yaml:"server,omitempty"` @@ -49,9 +49,9 @@ type Message struct { //nolint:govet,tagliatelle type Question struct { Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty" example:"localhost"` - Type uint16 `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"` + Type uint16 `json:"TYPE,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"` TypeName string `json:"TYPEname,omitempty" xml:"TYPEname,omitempty" yaml:"TYPEname,omitempty" example:"IN"` - Class string `json:"class,omitempty" xml:"class,omitempty" yaml:"class,omitempty" example:"A"` + 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:"1"` } @@ -59,12 +59,12 @@ type Question struct { // //nolint:govet,tagliatelle type Answer struct { - Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty" example:"127.0.0.1"` - Type uint16 `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"` + Name string `json:"NAME,omitempty" xml:"name,omitempty" yaml:"name,omitempty" example:"127.0.0.1"` + Type uint16 `json:"TYPE,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"` TypeName string `json:"TYPEname,omitempty" xml:"TYPEname,omitempty" yaml:"TYPEname,omitempty" example:"IN"` - Class uint16 `json:"class,omitempty" xml:"class,omitempty" yaml:"class,omitempty" example:"A"` + 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"` + TTL string `json:"TTL,omitempty" xml:"ttl,omitempty" yaml:"ttl,omitempty" example:"0ms"` Value string `json:"response,omitempty" xml:"response,omitempty" yaml:"response,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 748d56f..0d8d7f5 100644 --- a/pkg/query/util.go +++ b/pkg/query/util.go @@ -29,10 +29,10 @@ func (message *Message) displayQuestion(msg *dns.Msg, opts *util.Options, opt *d } message.Name = name - message.Type = opt.Header().Rrtype + message.Type = question.Qtype message.TypeName = dns.TypeToString[question.Qtype] - message.Class = dns.ClassToString[question.Qclass] - message.ClassName = dns.TypeToString[question.Qtype] + message.Class = question.Qclass + message.ClassName = dns.ClassToString[question.Qclass] } return nil @@ -66,11 +66,13 @@ func (message *Message) displayAnswers(msg *dns.Msg, opts *util.Options, opt *dn } message.AnswerRRs = append(message.AnswerRRs, Answer{ - Name: name, - TypeName: dns.TypeToString[answer.Header().Rrtype], - Type: answer.Header().Rrtype, - Rdlength: answer.Header().Rdlength, - TTL: ttl, + 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, Value: temp[len(temp)-1], }) @@ -110,7 +112,7 @@ func (message *Message) displayAuthority(msg *dns.Msg, opts *util.Options, opt * Name: name, TypeName: dns.TypeToString[ns.Header().Rrtype], Type: ns.Header().Rrtype, - Class: ns.Header().Rrtype, + Class: ns.Header().Class, ClassName: dns.ClassToString[ns.Header().Class], Rdlength: ns.Header().Rdlength, TTL: ttl, @@ -156,7 +158,7 @@ func (message *Message) displayAdditional(msg *dns.Msg, opts *util.Options, opt Name: name, TypeName: dns.TypeToString[additional.Header().Rrtype], Type: additional.Header().Rrtype, - Class: additional.Header().Rrtype, + Class: additional.Header().Class, ClassName: dns.ClassToString[additional.Header().Class], Rdlength: additional.Header().Rdlength, TTL: ttl,