Fix location of opt pseudosection and prevent empty additional section in dig-like output (#1320)
Automatically submitted.
This commit is contained in:
parent
32b1ed5f32
commit
af5144a5ca
9
msg.go
9
msg.go
|
@ -901,6 +901,11 @@ func (dns *Msg) String() string {
|
||||||
s += "ANSWER: " + strconv.Itoa(len(dns.Answer)) + ", "
|
s += "ANSWER: " + strconv.Itoa(len(dns.Answer)) + ", "
|
||||||
s += "AUTHORITY: " + strconv.Itoa(len(dns.Ns)) + ", "
|
s += "AUTHORITY: " + strconv.Itoa(len(dns.Ns)) + ", "
|
||||||
s += "ADDITIONAL: " + strconv.Itoa(len(dns.Extra)) + "\n"
|
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 {
|
if len(dns.Question) > 0 {
|
||||||
s += "\n;; QUESTION SECTION:\n"
|
s += "\n;; QUESTION SECTION:\n"
|
||||||
for _, r := range dns.Question {
|
for _, r := range dns.Question {
|
||||||
|
@ -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"
|
s += "\n;; ADDITIONAL SECTION:\n"
|
||||||
for _, r := range dns.Extra {
|
for _, r := range dns.Extra {
|
||||||
if r != nil {
|
if r != nil && r.Header().Rrtype != TypeOPT {
|
||||||
s += r.String() + "\n"
|
s += r.String() + "\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue