From 3e59dc37197535a6f3b2b427435f8eba357a88f0 Mon Sep 17 00:00:00 2001 From: "s.kharlamov" Date: Mon, 16 Oct 2023 08:27:47 +0000 Subject: [PATCH] RFC2136: Do not repeat zones sort --- provider/rfc2136/rfc2136.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/provider/rfc2136/rfc2136.go b/provider/rfc2136/rfc2136.go index a6c6460ed0..1efc3c2224 100644 --- a/provider/rfc2136/rfc2136.go +++ b/provider/rfc2136/rfc2136.go @@ -88,6 +88,11 @@ func NewRfc2136Provider(host string, port int, zoneName []string, insecure bool, return nil, errors.Errorf("%s is not supported TSIG algorithm", secretAlg) } + // Sort zones + sort.Slice(zoneName, func(i, j int) bool { + return len(strings.Split(zoneName[i], ".")) > len(strings.Split(zoneName[j], ".")) + }) + r := &rfc2136Provider{ nameserver: net.JoinHostPort(host, strconv.Itoa(port)), zoneName: zoneName, @@ -442,10 +447,6 @@ func chunkBy(slice []*endpoint.Endpoint, chunkSize int) [][]*endpoint.Endpoint { } func findMsgZone(ep *endpoint.Endpoint, m *dns.Msg, r *rfc2136Provider) { - sort.Slice(r.zoneName, func(i, j int) bool { - return len(strings.Split(r.zoneName[i], ".")) > len(strings.Split(r.zoneName[j], ".")) - }) - for _, zone := range r.zoneName { if strings.HasSuffix(ep.DNSName, zone) { r.krb5Realm = strings.ToUpper(dns.Fqdn(zone))