diff --git a/defaults.go b/defaults.go index a3d158f2..8fa82037 100644 --- a/defaults.go +++ b/defaults.go @@ -3,9 +3,6 @@ package dns // Everything is assumed in the ClassINET class. If // you need other classes you are on your own. -// Add SetEDNS0 -// IsEDNS0 function - // SetReply creates a reply packet from a request message. func (dns *Msg) SetReply(request *Msg) { dns.MsgHdr.Id = request.MsgHdr.Id @@ -188,9 +185,14 @@ func (dns *Msg) IsTsig() (ok bool) { return } -// IsEdns0 checks if the message has a Edns0 record, as the last -// or the one before the last, in the additional section. +// IsEdns0 checks if the message has a Edns0 record, any EDNS0 +// record in the additional section will do func (dns *Msg) IsEdns0() (ok bool) { + for _, r := range dns.Extra { + if r.Header().Rrtype == TypeOPT { + return true + } + } return } diff --git a/msg.go b/msg.go index caf3f7c7..f6e87d2f 100644 --- a/msg.go +++ b/msg.go @@ -880,8 +880,8 @@ func (h *MsgHdr) String() string { return " MsgHdr" } - s := ";; opcode: " + opcode_str[h.Opcode] - s += ", status: " + rcode_str[h.Rcode] + s := ";; opcode: " + Opcode_str[h.Opcode] + s += ", status: " + Rcode_str[h.Rcode] s += ", id: " + strconv.Itoa(int(h.Id)) + "\n" s += ";; flags:"