From 5e0ca30b2e73fb8d05b54e9069fe7a33b578830a Mon Sep 17 00:00:00 2001 From: grumbulon Date: Thu, 15 Dec 2022 17:11:38 -0500 Subject: [PATCH] lint --- pkg/query/print.go | 2 +- pkg/query/struct.go | 8 ++++++-- pkg/query/util.go | 16 +++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pkg/query/print.go b/pkg/query/print.go index 1737525..9842855 100644 --- a/pkg/query/print.go +++ b/pkg/query/print.go @@ -303,7 +303,7 @@ func MakePrintable(res util.Response, opts *util.Options) (*Message, error) { } if opts.Display.Additional { - ret.displayAdditional(msg, opts, opt) + err = ret.displayAdditional(msg, opts, opt) if err != nil { return nil, fmt.Errorf("unable to display additional: %w", err) } diff --git a/pkg/query/struct.go b/pkg/query/struct.go index d3a1119..877c05c 100644 --- a/pkg/query/struct.go +++ b/pkg/query/struct.go @@ -8,7 +8,7 @@ import ( // Message is for overall DNS responses. // -//nolint:govet // Better looking output is worth a few bytes. +//nolint:govet,tagliatelle // Better looking output is worth a few bytes. type Message struct { DateString string `json:"dateString,omitempty" xml:"dateString,omitempty" yaml:"dateString,omitempty"` DateSeconds string `json:"dateSeconds,omitempty" xml:"dateSeconds,omitempty" yaml:"dateSeconds,omitempty"` @@ -45,6 +45,8 @@ type Message struct { } // Question is a DNS Query. +// +//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"` @@ -53,7 +55,9 @@ type Question struct { ClassName string `json:"CLASSname,omitempty" xml:"CLASSname,omitempty" yaml:"CLASSname,omitempty" example:"1"` } -// RRHeader is for DNS Resource Headers. +// Answer is for DNS Resource Headers. +// +//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"` diff --git a/pkg/query/util.go b/pkg/query/util.go index e543aba..748d56f 100644 --- a/pkg/query/util.go +++ b/pkg/query/util.go @@ -17,6 +17,7 @@ func (message *Message) displayQuestion(msg *dns.Msg, opts *util.Options, opt *d name string err error ) + for _, question := range msg.Question { if opts.Display.UcodeTranslate { name, err = idna.ToUnicode(question.Name) @@ -33,6 +34,7 @@ func (message *Message) displayQuestion(msg *dns.Msg, opts *util.Options, opt *d message.Class = dns.ClassToString[question.Qclass] message.ClassName = dns.TypeToString[question.Qtype] } + return nil } @@ -42,6 +44,7 @@ func (message *Message) displayAnswers(msg *dns.Msg, opts *util.Options, opt *dn name string err error ) + for _, answer := range msg.Answer { temp := strings.Split(answer.String(), "\t") @@ -63,7 +66,6 @@ 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, @@ -73,7 +75,8 @@ func (message *Message) displayAnswers(msg *dns.Msg, opts *util.Options, opt *dn Value: temp[len(temp)-1], }) } - return err + + return nil } func (message *Message) displayAuthority(msg *dns.Msg, opts *util.Options, opt *dns.OPT) error { @@ -104,7 +107,6 @@ func (message *Message) displayAuthority(msg *dns.Msg, opts *util.Options, opt * } message.AuthoritativeRRs = append(message.AuthoritativeRRs, Answer{ - Name: name, TypeName: dns.TypeToString[ns.Header().Rrtype], Type: ns.Header().Rrtype, @@ -116,7 +118,8 @@ func (message *Message) displayAuthority(msg *dns.Msg, opts *util.Options, opt * Value: temp[len(temp)-1], }) } - return err + + return nil } func (message *Message) displayAdditional(msg *dns.Msg, opts *util.Options, opt *dns.OPT) error { @@ -125,6 +128,7 @@ func (message *Message) displayAdditional(msg *dns.Msg, opts *util.Options, opt name string err error ) + for _, additional := range msg.Extra { if additional.Header().Rrtype == dns.StringToType["OPT"] { continue @@ -160,9 +164,11 @@ func (message *Message) displayAdditional(msg *dns.Msg, opts *util.Options, opt }) } } - return err + + return nil } +// ParseOpt parses opts. func (message *Message) ParseOpt(rr dns.OPT) ([]Opts, error) { ret := []Opts{} // Most of this is taken from https://github.com/miekg/dns/blob/master/edns.go#L76