From 5e94032cd0f734ba5cfbd793393aae4c5188bde0 Mon Sep 17 00:00:00 2001 From: bloved Date: Tue, 12 Jan 2021 13:35:36 +0100 Subject: [PATCH] - killfile stats: incremented only when adding a new domain in BL - Malformed lines stats: stats are reset at refresh; ignoring blank/comment lines --- 01.killfile.go | 11 +++++++++-- adlist_hosts.go | 6 ++++++ adlist_single.go | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/01.killfile.go b/01.killfile.go index 60f6071..8ad4b18 100644 --- a/01.killfile.go +++ b/01.killfile.go @@ -26,11 +26,18 @@ func bWriteThread() { for item := range bChannel { + alreadyInSomeDB := false + for _, config := range item.Kconfigs { + if !alreadyInSomeDB { + alreadyInSomeDB = domainInKillfile(item.Kdomain, config) + } writeInKillfile(item.Kdomain, item.Ksource, config) } - incrementStats("BL domains from "+item.Ksource, 1) - incrementStats("TOTAL", 1) + if !alreadyInSomeDB { + incrementStats("BL domains from "+item.Ksource, 1) + incrementStats("TOTAL", 1) + } } diff --git a/adlist_hosts.go b/adlist_hosts.go index fc45b74..32dfb47 100644 --- a/adlist_hosts.go +++ b/adlist_hosts.go @@ -20,6 +20,9 @@ func DoubleIndexFilter(durl string, configs stringarray) error { fmt.Println("DoubleIndexFilter: Retrieving HostFile from: ", durl) + // resets malformed HostLines for url + setstatsvalue("Malformed HostLines "+durl, 0) + var err error // Get the data @@ -48,6 +51,9 @@ func DoubleIndexFilter(durl string, configs stringarray) error { line := scanner.Text() + if len(line) == 0 || strings.TrimSpace(line)[0] == '#' { + continue + } h := strings.FieldsFunc(line, splitter) if h == nil { diff --git a/adlist_single.go b/adlist_single.go index bbdd3fc..9f5318f 100644 --- a/adlist_single.go +++ b/adlist_single.go @@ -18,6 +18,9 @@ func SingleIndexFilter(durl string, configs stringarray) error { fmt.Println("Retrieving DomainFile from: ", durl) + // resets malformed HostLines for url + setstatsvalue("Malformed DomainLines "+durl, 0) + var err error // Get the data @@ -46,6 +49,9 @@ func SingleIndexFilter(durl string, configs stringarray) error { line := scanner.Text() + if len(line) == 0 || strings.TrimSpace(line)[0] == '#' { + continue + } h := strings.FieldsFunc(line, splitter) if h == nil {