Skip to content

Commit 84b3aad

Browse files
committed
fix(models): adjust TTL handling with min/max bounds and default value
Signed-off-by: okrc <[email protected]>
1 parent 0bcd265 commit 84b3aad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

models.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ func (r DnsRecord) libdnsRecord(zone string) (libdns.Record, error) {
146146

147147
func edgeOneRecord(zone string, r libdns.Record) DnsRecord {
148148
rr := r.RR()
149-
150-
ttl := max(rr.TTL, 60*time.Second)
149+
var ttl time.Duration
150+
if rr.TTL == 0 {
151+
ttl = 300 * time.Second
152+
} else {
153+
ttl = max(min(rr.TTL, 86400*time.Second), 60*time.Second)
154+
}
151155
name, _ := idna.ToASCII(strings.TrimSuffix(libdns.AbsoluteName(rr.Name, zone), "."))
152156

153157
record := DnsRecord{

0 commit comments

Comments
 (0)