1
0
Fork 0
mirror of https://github.com/Luzifer/named-blacklist.git synced 2024-11-08 07:20:07 +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

19
main.go
View file

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

View file

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