From 5e2ae637a0fa75393a34cc982f761fc8d2d5a0eb Mon Sep 17 00:00:00 2001 From: Sense T Date: Wed, 10 Apr 2024 14:56:15 +0800 Subject: [PATCH] end with dot. --- models/domain.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/models/domain.go b/models/domain.go index 87b4b49..64b3b0d 100644 --- a/models/domain.go +++ b/models/domain.go @@ -21,13 +21,16 @@ type Domain struct { NegativeTtl uint32 `gorm:"not null,size:255,default:\"86400\"" json:"negative_ttl"` } -func (d *Domain) EmailSOAForamt() string { +func (d Domain) EmailSOAForamt() string { s := strings.Split(d.AdminEmail, "@") s[0] = strings.Replace(s[0], ".", "\\", -1) + if !strings.HasSuffix(s[1], ".") { + s[1] = fmt.Sprintf("%s.", s[1]) + } return strings.Join(s, ".") } -func (d *Domain) WithDotEnd() string { +func (d Domain) WithDotEnd() string { if strings.HasSuffix(d.DomainName, ".") { return d.DomainName } else { @@ -36,8 +39,14 @@ func (d *Domain) WithDotEnd() string { } func (d *Domain) GenerateSOA() dns.SOARecord { + var ns string + if !strings.HasSuffix(d.MainDNS, ".") { + ns = fmt.Sprintf("%s.", d.MainDNS) + } else { + ns = d.MainDNS + } return dns.SOARecord{ - Ns: d.MainDNS, + Ns: ns, MBox: d.EmailSOAForamt(), Refresh: d.RefreshInterval, Retry: d.RetryInterval,