DNS服务商账号增加“最小TTL”选项

This commit is contained in:
GoEdgeLab
2024-05-12 09:33:51 +08:00
parent 8d049c8239
commit 058d586341
8 changed files with 74 additions and 17 deletions

View File

@@ -5,7 +5,9 @@ import (
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes"
)
type BaseProvider struct{}
type BaseProvider struct {
minTTL int32
}
// WrapError 封装解析相关错误
func (this *BaseProvider) WrapError(err error, domain string, record *dnstypes.Record) error {
@@ -25,3 +27,16 @@ func (this *BaseProvider) WrapError(err error, domain string, record *dnstypes.R
}
return fmt.Errorf("record operation failed: '%s %s %s %d': %w", fullname, record.Type, record.Value, record.TTL, err)
}
// SetMinTTL 设置最小TTL
func (this *BaseProvider) SetMinTTL(ttl int32) {
this.minTTL = ttl
}
// MinTTL 最小TTL
func (this *BaseProvider) MinTTL() int32 {
if this.minTTL > 0 {
return this.minTTL
}
return 0
}

View File

@@ -39,4 +39,10 @@ type ProviderInterface interface {
// DefaultRoute 默认线路
DefaultRoute() string
// SetMinTTL 设置最小TTL
SetMinTTL(ttl int32)
// MinTTL 最小TTL
MinTTL() int32
}