From 7fb529965ddef54bf5489b4bc7984d20409ba3a6 Mon Sep 17 00:00:00 2001 From: "s.kharlamov" Date: Tue, 17 Oct 2023 23:06:47 +0000 Subject: [PATCH] RFC2136: return string from findMsgZone --- provider/rfc2136/rfc2136.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/provider/rfc2136/rfc2136.go b/provider/rfc2136/rfc2136.go index d8881ff95..b800fb982 100644 --- a/provider/rfc2136/rfc2136.go +++ b/provider/rfc2136/rfc2136.go @@ -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) } @@ -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) } @@ -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) } @@ -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(".") }