another attempt at speeding this thing up.

This commit is contained in:
Hyatt 2022-03-21 18:40:21 -05:00
parent 1fe492f3cb
commit 13b9f1c048
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA
2 changed files with 34 additions and 30 deletions

View File

@ -38,24 +38,28 @@ func cleanBadDomains(domains []string) []string {
// remove allow-listed matches
total = len(domains)
for i, allowedItem := range config.Config.AllowLists {
log.Printf("[DEBUG] Processing %d of %d\n", i+1, len(config.Config.AllowLists))
// filter out bad regex
goodAllowedItemList := []string{}
for _, allowedItem := range config.Config.AllowLists {
_, err := regexp.Compile(allowedItem)
if err != nil {
log.Printf("[ERROR] Allow list item (%s) is not valid regex: %v\n", allowedItem, err)
break
}
goodAllowedItemList = append(goodAllowedItemList, allowedItem)
}
list = []string{}
for _, v := range domains {
r, err := regexp.Compile(allowedItem)
if err != nil {
log.Printf("[ERROR] Allow list item (%s) is not valid regex: %v\n", allowedItem, err)
break
}
if r.MatchString(v) {
list = []string{}
for _, v := range domains {
for _, allowedItem := range goodAllowedItemList {
if regexp.MustCompile(allowedItem).MatchString(v) {
log.Printf("[DEBUG] Removing allowed matching item: %s\n", v)
} else {
list = append(list, v)
}
}
domains = list
}
domains = list
log.Printf("[INFO] Allowed hosts removed: %d\n", total-len(domains))
log.Printf("[INFO] Total domains in list at end: %d.\n", len(domains))

View File

@ -38,25 +38,25 @@ allowList:
- ^ip6-allnodes$
- ^ip6-allrouters$
- ^ip6-allhosts$
- (^|\.)thepiratebay\.org
- (^|\.)sendgrid\.net
- (^|\.)googleadservices\.com
- (^|\.)doubleclick\.net
- (^|\.)sailthru\.com
- (^|\.)magiskmanager\.com
- (^|\.)apiservices\.krxd\.net
- (^|\.)logfiles\.zoom\.us
- (^|\.)logfiles-va\.zoom\.us
- (^|\.)nest\.com
- (^|\.)clients.\.google\.com
- (^|\.)login\.live\.com
- (^|\.)unagi\.amazon\.com
- (^|\.)unagi-na\.amazon\.com
- (^|\.)duckduckgo\.com
- (^|\.)msn\.com
- (^|\.)nexusrules\.officeapps\.live\.com
- (^|\.)playfabapi\.com
- (^|\.)vercel-dns\.com
- (^|\.)thepiratebay\.org$
- (^|\.)sendgrid\.net$
- (^|\.)googleadservices\.com$
- (^|\.)doubleclick\.net$
- (^|\.)sailthru\.com$
- (^|\.)magiskmanager\.com$
- (^|\.)apiservices\.krxd\.net$
- (^|\.)logfiles\.zoom\.us$
- (^|\.)logfiles-va\.zoom\.us$
- (^|\.)nest\.com$
- (^|\.)clients.\.google\.com$
- (^|\.)login\.live\.com$
- (^|\.)unagi\.amazon\.com$
- (^|\.)unagi-na\.amazon\.com$
- (^|\.)duckduckgo\.com$
- (^|\.)msn\.com$
- (^|\.)nexusrules\.officeapps\.live\.com$
- (^|\.)playfabapi\.com$
- (^|\.)vercel-dns\.com$
denyList:
- jindlecleanings.xyz
- "*.jindlecleanings.xyz"