Compare commits

...

2 Commits

Author SHA1 Message Date
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

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