IPv6 blocking: add a synthetic SOA record
This commit is contained in:
parent
b9b19f3381
commit
0b5c0af5ee
|
@ -1,6 +1,11 @@
|
|||
package main
|
||||
|
||||
import "github.com/miekg/dns"
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
type PluginBlockIPv6 struct{}
|
||||
|
||||
|
@ -43,6 +48,27 @@ func (plugin *PluginBlockIPv6) Eval(pluginsState *PluginsState, msg *dns.Msg) er
|
|||
hinfo.Cpu = "AAAA queries have been locally blocked by dnscrypt-proxy"
|
||||
hinfo.Os = "Set block_ipv6 to false to disable this feature"
|
||||
synth.Answer = []dns.RR{hinfo}
|
||||
qName := question.Name
|
||||
i := strings.Index(qName, ".")
|
||||
parentZone := "."
|
||||
if !(i < 0 || i+1 >= len(qName)) {
|
||||
parentZone = qName[i+1:]
|
||||
}
|
||||
dotParentZone := "."
|
||||
if parentZone != "." {
|
||||
dotParentZone += parentZone
|
||||
}
|
||||
soa := new(dns.SOA)
|
||||
soa.Mbox = "h" + dotParentZone
|
||||
soa.Ns = "n" + dotParentZone
|
||||
soa.Serial = uint32(time.Now().Unix())
|
||||
soa.Refresh = 10000
|
||||
soa.Minttl = 2400
|
||||
soa.Expire = 604800
|
||||
soa.Retry = 300
|
||||
soa.Hdr = dns.RR_Header{Name: parentZone, Rrtype: dns.TypeSOA,
|
||||
Class: dns.ClassINET, Ttl: 60}
|
||||
synth.Ns = []dns.RR{soa}
|
||||
pluginsState.synthResponse = synth
|
||||
pluginsState.action = PluginsActionSynth
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue