From e9fb8a8f36d2282a78487f875daf6c4bf6ecc4df Mon Sep 17 00:00:00 2001 From: jbpaux <9682558+jbpaux@users.noreply.github.com> Date: Fri, 1 Sep 2023 20:55:10 +0200 Subject: [PATCH] azure: add aaaa support --- provider/azure/azure.go | 23 +++++++++++++++++++++++ provider/azure/azure_private_dns.go | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/provider/azure/azure.go b/provider/azure/azure.go index 4f4348ba1..1d8c39021 100644 --- a/provider/azure/azure.go +++ b/provider/azure/azure.go @@ -344,6 +344,19 @@ func (p *AzureProvider) newRecordSet(endpoint *endpoint.Endpoint) (dns.RecordSet ARecords: aRecords, }, }, nil + case dns.RecordTypeAAAA: + aaaaRecords := make([]*dns.AaaaRecord, len(endpoint.Targets)) + for i, target := range endpoint.Targets { + aaaaRecords[i] = &dns.AaaaRecord{ + IPv6Address: to.Ptr(target), + } + } + return dns.RecordSet{ + Properties: &dns.RecordSetProperties{ + TTL: to.Ptr(ttl), + AaaaRecords: aaaaRecords, + }, + }, nil case dns.RecordTypeCNAME: return dns.RecordSet{ Properties: &dns.RecordSetProperties{ @@ -410,6 +423,16 @@ func extractAzureTargets(recordSet *dns.RecordSet) []string { return targets } + // Check for AAAA records + aaaaRecords := properties.AaaaRecords + if len(aaaaRecords) > 0 && (aaaaRecords)[0].IPv6Address != nil { + targets := make([]string, len(aaaaRecords)) + for i, aaaaRecord := range aaaaRecords { + targets[i] = *aaaaRecord.IPv6Address + } + return targets + } + // Check for CNAME records cnameRecord := properties.CnameRecord if cnameRecord != nil && cnameRecord.Cname != nil { diff --git a/provider/azure/azure_private_dns.go b/provider/azure/azure_private_dns.go index 6581ac07f..e6adb9df2 100644 --- a/provider/azure/azure_private_dns.go +++ b/provider/azure/azure_private_dns.go @@ -335,6 +335,19 @@ func (p *AzurePrivateDNSProvider) newRecordSet(endpoint *endpoint.Endpoint) (pri ARecords: aRecords, }, }, nil + case privatedns.RecordTypeAAAA: + aaaaRecords := make([]*privatedns.AaaaRecord, len(endpoint.Targets)) + for i, target := range endpoint.Targets { + aaaaRecords[i] = &privatedns.AaaaRecord{ + IPv6Address: to.Ptr(target), + } + } + return privatedns.RecordSet{ + Properties: &privatedns.RecordSetProperties{ + TTL: to.Ptr(ttl), + AaaaRecords: aaaaRecords, + }, + }, nil case privatedns.RecordTypeCNAME: return privatedns.RecordSet{ Properties: &privatedns.RecordSetProperties{ @@ -393,6 +406,16 @@ func extractAzurePrivateDNSTargets(recordSet *privatedns.RecordSet) []string { return targets } + // Check for AAAA records + aaaaRecords := properties.AaaaRecords + if len(aaaaRecords) > 0 && (aaaaRecords)[0].IPv6Address != nil { + targets := make([]string, len(aaaaRecords)) + for i, aaaaRecord := range aaaaRecords { + targets[i] = *aaaaRecord.IPv6Address + } + return targets + } + // Check for CNAME records cnameRecord := properties.CnameRecord if cnameRecord != nil && cnameRecord.Cname != nil {