2022-08-04 20:40:27 +02:00
package rwth
import (
"encoding/json"
"fmt"
2022-08-14 20:46:56 -04:00
2023-05-20 19:21:45 +02:00
"github.com/StackExchange/dnscontrol/v4/providers"
2022-08-04 20:40:27 +02:00
)
type rwthProvider struct {
apiToken string
zones map [ string ] zone
}
// features is used to let dnscontrol know which features are supported by the RWTH DNS Admin.
var features = providers . DocumentationNotes {
2024-03-18 18:30:09 -04:00
// The default for unlisted capabilities is 'Cannot'.
// See providers/capabilities.go for the entire list of capabilities.
2022-08-04 20:40:27 +02:00
providers . CanAutoDNSSEC : providers . Unimplemented ( "Supported by RWTH but not implemented yet." ) ,
providers . CanGetZones : providers . Can ( ) ,
2024-03-20 12:36:54 -04:00
providers . CanConcur : providers . Cannot ( ) ,
2022-08-04 20:40:27 +02:00
providers . CanUseAlias : providers . Cannot ( ) ,
providers . CanUseCAA : providers . Can ( ) ,
providers . CanUseDS : providers . Unimplemented ( "DS records are only supported at the apex and require a different API call that hasn't been implemented yet." ) ,
2023-03-16 19:04:20 +01:00
providers . CanUseLOC : providers . Cannot ( ) ,
2022-08-04 20:40:27 +02:00
providers . CanUseNAPTR : providers . Cannot ( ) ,
providers . CanUsePTR : providers . Can ( "PTR records with empty targets are not supported" ) ,
providers . CanUseSRV : providers . Can ( "SRV records with empty targets are not supported." ) ,
providers . CanUseSSHFP : providers . Can ( ) ,
providers . CanUseTLSA : providers . Cannot ( ) ,
providers . DocCreateDomains : providers . Cannot ( ) ,
providers . DocDualHost : providers . Cannot ( ) ,
providers . DocOfficiallySupported : providers . Cannot ( ) ,
}
// init registers the registrar and the domain service provider with dnscontrol.
func init ( ) {
fns := providers . DspFuncs {
Initializer : New ,
RecordAuditor : AuditRecords ,
}
providers . RegisterDomainServiceProviderType ( "RWTH" , fns , features )
}
2022-08-14 20:46:56 -04:00
// New allocates a DNS service provider.
2022-08-04 20:40:27 +02:00
func New ( settings map [ string ] string , _ json . RawMessage ) ( providers . DNSServiceProvider , error ) {
if settings [ "api_token" ] == "" {
return nil , fmt . Errorf ( "missing RWTH api_token" )
}
api := & rwthProvider { apiToken : settings [ "api_token" ] }
return api , nil
}