end with dot.
This commit is contained in:
parent
ed4fee935d
commit
5e2ae637a0
@ -21,13 +21,16 @@ type Domain struct {
|
|||||||
NegativeTtl uint32 `gorm:"not null,size:255,default:\"86400\"" json:"negative_ttl"`
|
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 := strings.Split(d.AdminEmail, "@")
|
||||||
s[0] = strings.Replace(s[0], ".", "\\", -1)
|
s[0] = strings.Replace(s[0], ".", "\\", -1)
|
||||||
|
if !strings.HasSuffix(s[1], ".") {
|
||||||
|
s[1] = fmt.Sprintf("%s.", s[1])
|
||||||
|
}
|
||||||
return strings.Join(s, ".")
|
return strings.Join(s, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Domain) WithDotEnd() string {
|
func (d Domain) WithDotEnd() string {
|
||||||
if strings.HasSuffix(d.DomainName, ".") {
|
if strings.HasSuffix(d.DomainName, ".") {
|
||||||
return d.DomainName
|
return d.DomainName
|
||||||
} else {
|
} else {
|
||||||
@ -36,8 +39,14 @@ func (d *Domain) WithDotEnd() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Domain) GenerateSOA() dns.SOARecord {
|
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{
|
return dns.SOARecord{
|
||||||
Ns: d.MainDNS,
|
Ns: ns,
|
||||||
MBox: d.EmailSOAForamt(),
|
MBox: d.EmailSOAForamt(),
|
||||||
Refresh: d.RefreshInterval,
|
Refresh: d.RefreshInterval,
|
||||||
Retry: d.RetryInterval,
|
Retry: d.RetryInterval,
|
||||||
|
Loading…
Reference in New Issue
Block a user