append zone root to domains without .
This commit is contained in:
parent
bf950f10ac
commit
19d67c2209
|
@ -8,6 +8,7 @@ import (
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ZoneConfig struct {
|
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")
|
return nil, errors.New("A record TTL cannot be 0 or empty")
|
||||||
}
|
}
|
||||||
for _, domain := range record.Domains {
|
for _, domain := range record.Domains {
|
||||||
|
if !strings.HasSuffix(domain, ".") {
|
||||||
|
domain = domain + "." + cfg.Zone.Root + "."
|
||||||
|
}
|
||||||
zone.ARecords = append(zone.ARecords, RecordA{
|
zone.ARecords = append(zone.ARecords, RecordA{
|
||||||
In: domain,
|
In: domain,
|
||||||
Ip: record.Ipv4.To4(),
|
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")
|
return nil, errors.New("AAAA record TTL cannot be 0 or empty")
|
||||||
}
|
}
|
||||||
for _, domain := range record.Domains {
|
for _, domain := range record.Domains {
|
||||||
|
if !strings.HasSuffix(domain, ".") {
|
||||||
|
domain = domain + "." + cfg.Zone.Root + "."
|
||||||
|
}
|
||||||
zone.AAAARecords = append(zone.AAAARecords, RecordAAAA{
|
zone.AAAARecords = append(zone.AAAARecords, RecordAAAA{
|
||||||
In: domain,
|
In: domain,
|
||||||
Ip: record.Ipv6,
|
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")
|
return nil, errors.New("CNAME record TTL cannot be 0 or empty")
|
||||||
}
|
}
|
||||||
for _, domain := range record.Domains {
|
for _, domain := range record.Domains {
|
||||||
|
if !strings.HasSuffix(domain, ".") {
|
||||||
|
domain = domain + "." + cfg.Zone.Root + "."
|
||||||
|
}
|
||||||
zone.CNAMERecords = append(zone.CNAMERecords, RecordCNAME{
|
zone.CNAMERecords = append(zone.CNAMERecords, RecordCNAME{
|
||||||
In: domain,
|
In: domain,
|
||||||
Target: record.Target,
|
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")
|
return nil, errors.New("TXT record TTL cannot be 0 or empty")
|
||||||
}
|
}
|
||||||
for _, domain := range record.Domains {
|
for _, domain := range record.Domains {
|
||||||
|
if !strings.HasSuffix(domain, ".") {
|
||||||
|
domain = domain + "." + cfg.Zone.Root + "."
|
||||||
|
}
|
||||||
zone.TXTRecords = append(zone.TXTRecords, RecordTXT{
|
zone.TXTRecords = append(zone.TXTRecords, RecordTXT{
|
||||||
In: domain,
|
In: domain,
|
||||||
Content: record.Content,
|
Content: record.Content,
|
||||||
|
|
Loading…
Reference in New Issue