2020-12-13 04:01:04 +01:00
|
|
|
package core
|
|
|
|
|
|
|
|
import "github.com/miekg/dns"
|
|
|
|
|
2020-12-22 04:12:02 +01:00
|
|
|
//HandleDNSRequest : Handle the DNS request using miekg/dns
|
2020-12-14 23:20:24 +01:00
|
|
|
//Requires dns.ReponseWriter and dns.Msg args
|
2020-12-22 04:12:02 +01:00
|
|
|
func HandleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
|
2020-12-13 04:01:04 +01:00
|
|
|
|
|
|
|
//dns.Msg object
|
|
|
|
//Will be passed to the parseQuery() function
|
|
|
|
m := new(dns.Msg)
|
|
|
|
m.SetReply(r)
|
2020-12-14 23:20:24 +01:00
|
|
|
m.Compress = false
|
2020-12-13 04:01:04 +01:00
|
|
|
|
2020-12-13 19:38:24 +01:00
|
|
|
if r.Opcode == dns.OpcodeQuery { //Only respond to dns queries
|
2020-12-13 04:01:04 +01:00
|
|
|
parseQuery(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
w.WriteMsg(m) //Write the DNS response
|
|
|
|
}
|