Compare commits

...

6 Commits
0.3 ... master

Author SHA1 Message Date
adcb67e9c2 Merge pull request 'bugfixes' (#1) from develop into master
All checks were successful
continuous-integration/drone/tag Build is passing
Reviewed-on: #1
2021-03-21 13:25:41 +00:00
afdea7e64f up block TTL 2021-02-25 13:25:19 +01:00
4394d6078d changed regex for parsing host format 2021-02-25 13:24:57 +01:00
ebce605863 dont handle missing rr with nxdomain 2021-02-24 14:09:28 +01:00
7255fc02c8 Revert "added debug messages"
This reverts commit 00a82aca87.
2021-02-24 13:50:13 +01:00
00a82aca87 added debug messages 2021-02-15 12:02:12 +01:00
2 changed files with 12 additions and 6 deletions

View File

@ -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)

View File

@ -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