append zone root to domains without .

This commit is contained in:
core 2023-10-02 13:48:31 -04:00
parent bf950f10ac
commit 19d67c2209
Signed by: core
GPG Key ID: FDBF740DADDCEECF
1 changed files with 13 additions and 0 deletions

View File

@ -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,