1
0
mirror of https://github.com/Luzifer/named-blacklist.git synced 2024-09-19 16:23:00 +00:00

Collect comments for all sources

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-02-11 16:04:59 +01:00
parent 2a224984a5
commit 9d52d69430
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
2 changed files with 15 additions and 3 deletions

20
main.go
View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"sort" "sort"
"strings"
"sync" "sync"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -105,14 +106,25 @@ func main() {
} }
func addIfNotExists(entries []entry, e entry) []entry { func addIfNotExists(entries []entry, e entry) []entry {
var (
found bool
out []entry
)
for _, pe := range entries { for _, pe := range entries {
if pe.Domain == e.Domain { if pe.Domain == e.Domain {
// Entry already exists, skip found = true
return entries pe.Comment = strings.Join([]string{pe.Comment, e.Comment}, ", ")
}
} }
return append(entries, e) out = append(out, pe)
}
if !found {
out = append(out, e)
}
return out
} }
func cleanFromList(blacklist, whitelist []entry) []entry { func cleanFromList(blacklist, whitelist []entry) []entry {

Binary file not shown.