XFR is now limited to certains IP configured in the config file
https://github.com/outout14/sacrebleu-dns/issues/11 https://github.com/outout14/sacrebleu-dns/issues/11#issuecomment-753423572pull/12/head
parent
384ca40434
commit
1ec2b3c5a2
@ -1,24 +1,36 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/outout14/sacrebleu-dns/utils"
|
||||
)
|
||||
|
||||
//HandleDNSRequest : Handle the DNS request using miekg/dns
|
||||
//Requires dns.ReponseWriter and dns.Msg args
|
||||
func HandleDNSRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||
|
||||
func HandleDNSRequest(w dns.ResponseWriter, r *dns.Msg, conf *utils.Conf) {
|
||||
//dns.Msg object
|
||||
//Will be passed to the parseQuery() function
|
||||
m := new(dns.Msg)
|
||||
m.SetReply(r)
|
||||
m.Compress = false
|
||||
|
||||
ip, _, _ := net.SplitHostPort(w.RemoteAddr().String())
|
||||
|
||||
if r.Question[0].Qtype == dns.TypeAXFR {
|
||||
parseAXFR(m)
|
||||
if utils.XfrAllowed(ip, conf) {
|
||||
parseAXFR(m)
|
||||
} else {
|
||||
m := new(dns.Msg)
|
||||
m.SetRcode(r, dns.RcodeRefused)
|
||||
w.WriteMsg(m)
|
||||
}
|
||||
|
||||
} else if r.Opcode == dns.OpcodeQuery { //Only respond to dns queries
|
||||
parseQuery(m)
|
||||
}
|
||||
|
||||
w.WriteMsg(m) //Write the DNS response
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue