Fix default response generation (#492)
- response Opcode must match request - RD and CD semantics are only defined for QUERY
This commit is contained in:
parent
babbdab23a
commit
193f91db0b
|
@ -13,9 +13,12 @@ const hexDigit = "0123456789abcdef"
|
||||||
// SetReply creates a reply message from a request message.
|
// SetReply creates a reply message from a request message.
|
||||||
func (dns *Msg) SetReply(request *Msg) *Msg {
|
func (dns *Msg) SetReply(request *Msg) *Msg {
|
||||||
dns.Id = request.Id
|
dns.Id = request.Id
|
||||||
dns.RecursionDesired = request.RecursionDesired // Copy rd bit
|
|
||||||
dns.Response = true
|
dns.Response = true
|
||||||
dns.Opcode = OpcodeQuery
|
dns.Opcode = request.Opcode
|
||||||
|
if dns.Opcode == OpcodeQuery {
|
||||||
|
dns.RecursionDesired = request.RecursionDesired // Copy rd bit
|
||||||
|
dns.CheckingDisabled = request.CheckingDisabled // Copy cd bit
|
||||||
|
}
|
||||||
dns.Rcode = RcodeSuccess
|
dns.Rcode = RcodeSuccess
|
||||||
if len(request.Question) > 0 {
|
if len(request.Question) > 0 {
|
||||||
dns.Question = make([]Question, 1)
|
dns.Question = make([]Question, 1)
|
||||||
|
|
Loading…
Reference in New Issue