Skip to content

Commit

Permalink
RFC2136: return string from findMsgZone
Browse files Browse the repository at this point in the history
  • Loading branch information
CRASH-Tech committed Oct 17, 2023
1 parent 714078d commit 7fb5299
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions provider/rfc2136/rfc2136.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
continue
}

findMsgZone(ep, m, &r)
zone := findMsgZone(ep, m, r)
r.krb5Realm = strings.ToUpper(zone)
m.SetUpdate(zone)

r.AddRecord(m, ep)
}
Expand All @@ -290,7 +292,9 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
continue
}

findMsgZone(ep, m, &r)
zone := findMsgZone(ep, m, r)
r.krb5Realm = strings.ToUpper(zone)
m.SetUpdate(zone)

r.UpdateRecord(m, changes.UpdateOld[i], ep)
}
Expand All @@ -317,7 +321,9 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
continue
}

findMsgZone(ep, m, &r)
zone := findMsgZone(ep, m, r)
r.krb5Realm = strings.ToUpper(zone)
m.SetUpdate(zone)

r.RemoveRecord(m, ep)
}
Expand Down Expand Up @@ -451,17 +457,13 @@ func chunkBy(slice []*endpoint.Endpoint, chunkSize int) [][]*endpoint.Endpoint {
return chunks
}

func findMsgZone(ep *endpoint.Endpoint, m *dns.Msg, r *rfc2136Provider) {
func findMsgZone(ep *endpoint.Endpoint, m *dns.Msg, r rfc2136Provider) string {
for _, zone := range r.zoneNames {
if strings.HasSuffix(ep.DNSName, zone) {
r.krb5Realm = strings.ToUpper(dns.Fqdn(zone))
m.SetUpdate(dns.Fqdn(zone))

return
return dns.Fqdn(zone)
}
}

log.Warnf("No available zone found for %s, set it to 'root'", ep.DNSName)
r.krb5Realm = dns.Fqdn(".")
m.SetUpdate(dns.Fqdn("."))
return dns.Fqdn(".")
}

0 comments on commit 7fb5299

Please sign in to comment.