+ dnsforward: support IPv6 (AAAA response)
If question type is AAAA: Before this patch we responded with NXDOMAIN. Now we send an empty response if host rule is IPv4; or we send an AAAA answer if host rule is IPv6. + block ipv6 if rule is "0.0.0.0 blockdomain"
This commit is contained in:
@@ -555,9 +555,18 @@ func (d *Dnsfilter) matchHost(host string, qtype uint16) (Result, error) {
|
||||
// either IPv4 or IPv4-mapped IPv6 address
|
||||
res.IP = hostRule.IP.To4()
|
||||
return res, nil
|
||||
} else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil {
|
||||
res.IP = hostRule.IP
|
||||
return res, nil
|
||||
|
||||
} else if qtype == dns.TypeAAAA {
|
||||
ip4 := hostRule.IP.To4()
|
||||
if ip4 == nil {
|
||||
res.IP = hostRule.IP
|
||||
return res, nil
|
||||
}
|
||||
if bytes.Equal(ip4, []byte{0, 0, 0, 0}) {
|
||||
// send IP="::" response for a rule "0.0.0.0 blockdomain"
|
||||
res.IP = net.IPv6zero
|
||||
return res, nil
|
||||
}
|
||||
}
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user