Compare commits

..

No commits in common. "master" and "0.3" have entirely different histories.
master ... 0.3

2 changed files with 6 additions and 12 deletions

View File

@ -121,15 +121,7 @@ func handleRequest(w dns.ResponseWriter, r *dns.Msg, zone zoneView) {
} }
if len(m.Answer) == 0 { if len(m.Answer) == 0 {
var soa dns.RR m.SetRcode(m, dns.RcodeNameError)
for _, v := range zone.rr[dns.TypeSOA] {
if len(v) == 1 {
soa = v[0]
}
}
if soa != nil {
m.Extra = append(m.Extra, soa)
}
} }
w.WriteMsg(m) w.WriteMsg(m)

View File

@ -12,7 +12,7 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
) )
const blockTTL uint32 = 604800 const blockTTL uint32 = 300
var nullIPv4 = net.IPv4(0, 0, 0, 0) var nullIPv4 = net.IPv4(0, 0, 0, 0)
var nullIPv6 = net.ParseIP("::/0") var nullIPv6 = net.ParseIP("::/0")
@ -86,10 +86,12 @@ func parseRawBlacklist(blacklist configBlacklist, raw string) []string {
// parseHostFormat parse the string in the format of a hostfile // parseHostFormat parse the string in the format of a hostfile
func parseHostFormat(raw string) []string { func parseHostFormat(raw string) []string {
finalList := make([]string, 0) finalList := make([]string, 0)
reg := regexp.MustCompile(`(?m)^\s*(0\.0\.0\.0) ([a-zA-Z0-9-.]*)`) reg := regexp.MustCompile(`(?mi)^\s*(#*)\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-zA-Z0-9\.\- ]+)$`)
matches := reg.FindAllStringSubmatch(raw, -1) matches := reg.FindAllStringSubmatch(raw, -1)
for _, match := range matches { for _, match := range matches {
finalList = append(finalList, dns.Fqdn(match[2])) if match[1] != "#" {
finalList = append(finalList, dns.Fqdn(match[3]))
}
} }
return finalList return finalList