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

Fix comments, speed up

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-02-11 16:13:37 +01:00
parent 9d52d69430
commit 09170e8f8d
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 5 additions and 16 deletions

21
main.go
View file

@ -106,25 +106,14 @@ func main() {
} }
func addIfNotExists(entries []entry, e entry) []entry { func addIfNotExists(entries []entry, e entry) []entry {
var ( for i, pe := range entries {
found bool
out []entry
)
for _, pe := range entries {
if pe.Domain == e.Domain { if pe.Domain == e.Domain {
found = true entries[i].Comment = strings.Join([]string{pe.Comment, e.Comment}, ", ")
pe.Comment = strings.Join([]string{pe.Comment, e.Comment}, ", ") return entries
}
} }
out = append(out, pe) return append(entries, e)
}
if !found {
out = append(out, e)
}
return out
} }
func cleanFromList(blacklist, whitelist []entry) []entry { func cleanFromList(blacklist, whitelist []entry) []entry {

View file

@ -54,7 +54,7 @@ func (p providerHostFile) GetDomainList(d providerDefinition) ([]entry, error) {
continue continue
} }
comment := fmt.Sprintf("From: %q", d.Name) comment := fmt.Sprintf("%q", d.Name)
if len(groups) == 3 && strings.Trim(groups[2], "#") != "" { if len(groups) == 3 && strings.Trim(groups[2], "#") != "" {
comment = fmt.Sprintf("%s, Comment: %q", comment = fmt.Sprintf("%s, Comment: %q",
comment, comment,