mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-05-05 22:56:09 +02:00
Add IPv6 AAAA record support to PiHole provider
This commit is contained in:
parent
d07a03c8fa
commit
f8a9c07230
@ -145,6 +145,7 @@ func (p *piholeClient) listRecords(ctx context.Context, rtype string) ([]*endpoi
|
||||
if !ok {
|
||||
return out, nil
|
||||
}
|
||||
loop:
|
||||
for _, rec := range data {
|
||||
name := rec[0]
|
||||
target := rec[1]
|
||||
@ -152,6 +153,16 @@ func (p *piholeClient) listRecords(ctx context.Context, rtype string) ([]*endpoi
|
||||
log.Debugf("Skipping %s that does not match domain filter", name)
|
||||
continue
|
||||
}
|
||||
switch rtype {
|
||||
case endpoint.RecordTypeA:
|
||||
if strings.Contains(target, ":") {
|
||||
continue loop
|
||||
}
|
||||
case endpoint.RecordTypeAAAA:
|
||||
if strings.Contains(target, ".") {
|
||||
continue loop
|
||||
}
|
||||
}
|
||||
out = append(out, &endpoint.Endpoint{
|
||||
DNSName: name,
|
||||
Targets: []string{target},
|
||||
@ -180,7 +191,7 @@ func (p *piholeClient) cnameRecordsScript() string {
|
||||
|
||||
func (p *piholeClient) urlForRecordType(rtype string) (string, error) {
|
||||
switch rtype {
|
||||
case endpoint.RecordTypeA:
|
||||
case endpoint.RecordTypeA, endpoint.RecordTypeAAAA:
|
||||
return p.aRecordsScript(), nil
|
||||
case endpoint.RecordTypeCNAME:
|
||||
return p.cnameRecordsScript(), nil
|
||||
@ -287,7 +298,7 @@ func (p *piholeClient) newDNSActionForm(action string, ep *endpoint.Endpoint) *u
|
||||
form.Add("action", action)
|
||||
form.Add("domain", ep.DNSName)
|
||||
switch ep.RecordType {
|
||||
case endpoint.RecordTypeA:
|
||||
case endpoint.RecordTypeA, endpoint.RecordTypeAAAA:
|
||||
form.Add("ip", ep.Targets[0])
|
||||
case endpoint.RecordTypeCNAME:
|
||||
form.Add("target", ep.Targets[0])
|
||||
|
||||
@ -71,10 +71,15 @@ func (p *PiholeProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
aaaaRecords, err := p.api.listRecords(ctx, endpoint.RecordTypeAAAA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cnameRecords, err := p.api.listRecords(ctx, endpoint.RecordTypeCNAME)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
aRecords = append(aRecords, aaaaRecords...)
|
||||
return append(aRecords, cnameRecords...), nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user