Skip to content

Commit

Permalink
feat: support all external-dns records; fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
muhlba91 committed Nov 9, 2023
1 parent d955d8d commit b455a9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/adguard/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ func (p *Provider) Records(ctx context.Context) ([]*endpoint.Endpoint, error) {
}

func endpointSupported(e *endpoint.Endpoint) bool {
return e.RecordType == endpoint.RecordTypeA || e.RecordType == endpoint.RecordTypeTXT || e.RecordType == endpoint.RecordTypeAAAA || e.RecordType == endpoint.RecordTypeCNAME
// Adguard does not have any restriction, and we can allow all upstream/external-dns ones
return e.RecordType == endpoint.RecordTypeA || e.RecordType == endpoint.RecordTypeTXT || e.RecordType == endpoint.RecordTypeAAAA || e.RecordType == endpoint.RecordTypeCNAME || e.RecordType == endpoint.RecordTypeSRV || e.RecordType == endpoint.RecordTypeNS || e.RecordType == endpoint.RecordTypePTR || e.RecordType == endpoint.RecordTypeMX
}

func deserializeToEndpoint(rule string) (*endpoint.Endpoint, error) {
Expand Down
13 changes: 9 additions & 4 deletions internal/adguard/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,26 @@ func TestEndpointSupported(t *testing.T) {
{
name: "SRV record",
endpoint: endpoint.NewEndpoint("domain.com", endpoint.RecordTypeSRV, "rsv"),
valid: false,
valid: true,
},
{
name: "NS record",
endpoint: endpoint.NewEndpoint("domain.com", endpoint.RecordTypeNS, "1.1.1.1"),
valid: false,
valid: true,
},
{
name: "PTR record",
endpoint: endpoint.NewEndpoint("1.1.1.1", endpoint.RecordTypePTR, "domain.com"),
valid: false,
valid: true,
},
{
name: "MX record",
endpoint: endpoint.NewEndpoint("1.1.1.1", endpoint.RecordTypeMX, "10 mail.domain.com."),
valid: true,
},
{
name: "SOA record",
endpoint: endpoint.NewEndpoint("1.1.1.1", "SOA", "invalid record"),
valid: false,
},
}
Expand Down Expand Up @@ -594,7 +599,7 @@ func TestApplyChanges(t *testing.T) {
Create: []*endpoint.Endpoint{
{
DNSName: "domain.com",
RecordType: endpoint.RecordTypeSRV,
RecordType: "SOA",
Targets: []string{
"srv",
},
Expand Down

0 comments on commit b455a9d

Please sign in to comment.