From a311c333a99cd6ed92e69d5d78291ff12777e5a7 Mon Sep 17 00:00:00 2001 From: W Anders Date: Tue, 7 May 2024 19:51:30 -0600 Subject: [PATCH] fixed cname resolution --- lookup.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lookup.go b/lookup.go index 75e4c5a..e6fa779 100644 --- a/lookup.go +++ b/lookup.go @@ -197,11 +197,15 @@ func (netboxdns *NetboxDNS) lookupDirect( zone *netbox.Zone, family int, ) (*lookupResponse, error) { + queryTypes := []string{dns.TypeToString[qtype]} + if qtype == dns.TypeA || qtype == dns.TypeAAAA { + queryTypes = append(queryTypes, "CNAME") + } records, err := netbox.GetRecordsQuery( netboxdns.requestClient, &netbox.RecordQuery{ FQDN: qname, - Type: []string{dns.TypeToString[qtype]}, + Type: queryTypes, Zone: zone, }, ) @@ -222,7 +226,8 @@ func (netboxdns *NetboxDNS) lookupDirect( if err != nil { return nil, err } - if qtype == dns.TypeCNAME { + cnames := filterRRByType(answer, dns.TypeCNAME) + if qtype == dns.TypeCNAME || len(cnames) > 0 { answer = append(answer, extra...) extra = nil }