diff --git a/controllers/domain.go b/controllers/domain.go index 7ea9194..4e32d85 100644 --- a/controllers/domain.go +++ b/controllers/domain.go @@ -22,7 +22,7 @@ func (c *Controller) CreateDomain(d *models.Domain) (*models.Domain, error) { } r := &models.RecordWithType[dns.SOARecord]{} - r.Zone = fmt.Sprintf("%s.", d.DomainName) + r.Zone = d.WithDotEnd() r.Name = "@" r.RecordType = models.RecordTypeSOA r.Content.Ns = d.MainDNS diff --git a/models/domain.go b/models/domain.go index a792b34..f110428 100644 --- a/models/domain.go +++ b/models/domain.go @@ -1,6 +1,9 @@ package models -import "strings" +import ( + "fmt" + "strings" +) type Domain struct { ID int `gorm:"primaryKey" json:"id"` @@ -21,3 +24,11 @@ func (d *Domain) EmailSOAForamt() string { s[0] = strings.Replace(s[0], ".", "\\", -1) return strings.Join(s, ".") } + +func (d *Domain) WithDotEnd() string { + if strings.HasSuffix(d.DomainName, ".") { + return d.DomainName + } else { + return fmt.Sprintf("%s.", d.DomainName) + } +}