Skip to content

Commit

Permalink
fixes #8276
Browse files Browse the repository at this point in the history
  • Loading branch information
fdurand committed Sep 12, 2024
1 parent 0009032 commit d5ee24b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions go/cmd/pfdns/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
func init() {
dnsserver.Directives = insertBefore(dnsserver.Directives, searchIndex(dnsserver.Directives, "forward"), "pfdns")
dnsserver.Directives = insertBefore(dnsserver.Directives, searchIndex(dnsserver.Directives, "log")+1, "logger")
dnsserver.Directives = moveValueAfter(dnsserver.Directives, "hosts", "pfdns")
}

func main() {
Expand Down Expand Up @@ -48,3 +49,22 @@ func searchIndex(a []string, value string) int {
}
return -1
}

func removeValue(s []string, value string) []string {
for i, v := range s {
if v == value {
return append(s[:i], s[i+1:]...)
}
}
return s
}

func moveValueBefore(a []string, value string, after string) []string {
b := removeValue(a, value)
return insertBefore(b, searchIndex(b, after), value)
}

func moveValueAfter(a []string, value string, after string) []string {
b := removeValue(a, value)
return insertBefore(b, searchIndex(b, after)+1, value)
}

0 comments on commit d5ee24b

Please sign in to comment.