mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
DNS服务商账号增加“最小TTL”选项
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -39,4 +39,10 @@ type ProviderInterface interface {
|
||||
|
||||
// DefaultRoute 默认线路
|
||||
DefaultRoute() string
|
||||
|
||||
// SetMinTTL 设置最小TTL
|
||||
SetMinTTL(ttl int32)
|
||||
|
||||
// MinTTL 最小TTL
|
||||
MinTTL() int32
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user