diff --git a/internal/authoritative.go b/internal/authoritative.go index cb6fcc8..be08e48 100644 --- a/internal/authoritative.go +++ b/internal/authoritative.go @@ -121,7 +121,15 @@ func handleRequest(w dns.ResponseWriter, r *dns.Msg, zone zoneView) { } if len(m.Answer) == 0 { - m.SetRcode(m, dns.RcodeNameError) + var soa dns.RR + 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) diff --git a/internal/blacklist.go b/internal/blacklist.go index 49ae789..2634383 100644 --- a/internal/blacklist.go +++ b/internal/blacklist.go @@ -12,7 +12,7 @@ import ( "github.com/miekg/dns" ) -const blockTTL uint32 = 300 +const blockTTL uint32 = 604800 var nullIPv4 = net.IPv4(0, 0, 0, 0) var nullIPv6 = net.ParseIP("::/0") @@ -86,12 +86,10 @@ func parseRawBlacklist(blacklist configBlacklist, raw string) []string { // parseHostFormat parse the string in the format of a hostfile func parseHostFormat(raw string) []string { finalList := make([]string, 0) - reg := regexp.MustCompile(`(?mi)^\s*(#*)\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-zA-Z0-9\.\- ]+)$`) + reg := regexp.MustCompile(`(?m)^\s*(0\.0\.0\.0) ([a-zA-Z0-9-.]*)`) matches := reg.FindAllStringSubmatch(raw, -1) for _, match := range matches { - if match[1] != "#" { - finalList = append(finalList, dns.Fqdn(match[3])) - } + finalList = append(finalList, dns.Fqdn(match[2])) } return finalList