Skip to content

Commit

Permalink
RFC2136: Do not repeat zones sort
Browse files Browse the repository at this point in the history
  • Loading branch information
CRASH-Tech committed Oct 16, 2023
1 parent 20b9200 commit 3e59dc3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions provider/rfc2136/rfc2136.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 3e59dc3

Please sign in to comment.