diff --git a/zone_config.go b/zone_config.go index 79226d2..2d9de78 100644 --- a/zone_config.go +++ b/zone_config.go @@ -8,6 +8,7 @@ import ( "gopkg.in/yaml.v2" "net" "os" + "strings" ) type ZoneConfig struct { @@ -80,6 +81,9 @@ func LoadZone(path string) (*Zone, error) { return nil, errors.New("A record TTL cannot be 0 or empty") } for _, domain := range record.Domains { + if !strings.HasSuffix(domain, ".") { + domain = domain + "." + cfg.Zone.Root + "." + } zone.ARecords = append(zone.ARecords, RecordA{ In: domain, Ip: record.Ipv4.To4(), @@ -98,6 +102,9 @@ func LoadZone(path string) (*Zone, error) { return nil, errors.New("AAAA record TTL cannot be 0 or empty") } for _, domain := range record.Domains { + if !strings.HasSuffix(domain, ".") { + domain = domain + "." + cfg.Zone.Root + "." + } zone.AAAARecords = append(zone.AAAARecords, RecordAAAA{ In: domain, Ip: record.Ipv6, @@ -116,6 +123,9 @@ func LoadZone(path string) (*Zone, error) { return nil, errors.New("CNAME record TTL cannot be 0 or empty") } for _, domain := range record.Domains { + if !strings.HasSuffix(domain, ".") { + domain = domain + "." + cfg.Zone.Root + "." + } zone.CNAMERecords = append(zone.CNAMERecords, RecordCNAME{ In: domain, Target: record.Target, @@ -134,6 +144,9 @@ func LoadZone(path string) (*Zone, error) { return nil, errors.New("TXT record TTL cannot be 0 or empty") } for _, domain := range record.Domains { + if !strings.HasSuffix(domain, ".") { + domain = domain + "." + cfg.Zone.Root + "." + } zone.TXTRecords = append(zone.TXTRecords, RecordTXT{ In: domain, Content: record.Content,