Skip to content

Commit

Permalink
Fix location of opt pseudosection and prevent empty additional sectio…
Browse files Browse the repository at this point in the history
…n in dig-like output (#1320)

Automatically submitted.
  • Loading branch information
bshea3 authored Dec 24, 2021
1 parent 32b1ed5 commit af5144a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,11 @@ func (dns *Msg) String() string {
s += "ANSWER: " + strconv.Itoa(len(dns.Answer)) + ", "
s += "AUTHORITY: " + strconv.Itoa(len(dns.Ns)) + ", "
s += "ADDITIONAL: " + strconv.Itoa(len(dns.Extra)) + "\n"
opt := dns.IsEdns0()
if opt != nil {
// OPT PSEUDOSECTION
s += opt.String() + "\n"
}
if len(dns.Question) > 0 {
s += "\n;; QUESTION SECTION:\n"
for _, r := range dns.Question {
Expand All @@ -923,10 +928,10 @@ func (dns *Msg) String() string {
}
}
}
if len(dns.Extra) > 0 {
if len(dns.Extra) > 0 && (opt == nil || len(dns.Extra) > 1) {
s += "\n;; ADDITIONAL SECTION:\n"
for _, r := range dns.Extra {
if r != nil {
if r != nil && r.Header().Rrtype != TypeOPT {
s += r.String() + "\n"
}
}
Expand Down

0 comments on commit af5144a

Please sign in to comment.