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

@@ -292,10 +292,12 @@ func downcase(recs []*RecordConfig) {
for _, r := range recs {
r.Name = strings.ToLower(r.Name)
r.NameFQDN = strings.ToLower(r.NameFQDN)
switch r.Type {
case "ANAME", "CNAME", "MX", "NS", "PTR":
switch r.Type { // #rtype_variations
case "ANAME", "CNAME", "MX", "NS", "PTR", "SRV":
// These record types have a target that is case insensitive, so we downcase it.
r.Target = strings.ToLower(r.Target)
case "A", "AAAA", "ALIAS", "CAA", "IMPORT_TRANSFORM", "SRV", "TLSA", "TXT", "SOA", "CF_REDIRECT", "CF_TEMP_REDIRECT":
case "A", "AAAA", "ALIAS", "CAA", "IMPORT_TRANSFORM", "TLSA", "TXT", "SOA", "CF_REDIRECT", "CF_TEMP_REDIRECT":
// These record types have a target that is case sensitive, or is an IP address. We leave them alone.
// Do nothing.
default:
// TODO: we'd like to panic here, but custom record types complicate things.