1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Fix SRV record handling when target is shortname (#422)

* models/record.go: SRV targets are case insensitive. Downcase them.
* models/t_srv.go: Rename setTargetIntAndStrings() to setTargetSRVIntAndStrings() (makes it easier to search for /setTargetSRV/).
* pkg/js/parse_tests/021-srv.js*: SRV: Add parse_tests
* pkg/normalize/validate.go: SRV targets are hostnames, turn into FQDNs.
* Add  #rtype_variations warnings for future developers
This commit is contained in:
Tom Limoncelli
2018-12-07 16:30:04 -05:00
committed by GitHub
parent 292ea28208
commit 4ef9e8bc40
5 changed files with 72 additions and 8 deletions

View File

@@ -285,7 +285,11 @@ func NormalizeAndValidateConfig(config *models.DNSConfig) (errs []error) {
}
// Canonicalize Targets.
if rec.Type == "CNAME" || rec.Type == "MX" || rec.Type == "NS" {
if rec.Type == "CNAME" || rec.Type == "MX" || rec.Type == "NS" || rec.Type == "SRV" {
// #rtype_variations
// These record types have a target that is a hostname.
// We normalize them to a FQDN so there is less variation to handle. If a
// provider API requires a shortname, the provider must do the shortening.
rec.SetTarget(dnsutil.AddOrigin(rec.GetTargetField(), domain.Name+"."))
} else if rec.Type == "A" || rec.Type == "AAAA" {
rec.SetTarget(net.ParseIP(rec.GetTargetField()).String())