sacrebleu-dns/core/handleDnsRequest.go
Mael GRAMAIN 78744ea1ac AXFR support
#11
2021-01-01 22:34:54 -04:00

25 lines
525 B
Go

package core
import (
"github.com/miekg/dns"
)
//HandleDNSRequest : Handle the DNS request using miekg/dns
//Requires dns.ReponseWriter and dns.Msg args
func HandleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
//dns.Msg object
//Will be passed to the parseQuery() function
m := new(dns.Msg)
m.SetReply(r)
m.Compress = false
if r.Question[0].Qtype == dns.TypeAXFR {
parseAXFR(m)
} else if r.Opcode == dns.OpcodeQuery { //Only respond to dns queries
parseQuery(m)
}
w.WriteMsg(m) //Write the DNS response
}