Skip to content

Commit

Permalink
azure: add aaaa support
Browse files Browse the repository at this point in the history
  • Loading branch information
jbpaux committed Sep 1, 2023
1 parent b2de466 commit e9fb8a8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions provider/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down
23 changes: 23 additions & 0 deletions provider/azure/azure_private_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e9fb8a8

Please sign in to comment.