Initial commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package dnsprovider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/libdns/libdns"
|
||||
tencentcloud "github.com/libdns/tencentcloud"
|
||||
)
|
||||
|
||||
// TencentCloudProvider 腾讯云 DNSPod 服务商实现
|
||||
type TencentCloudProvider struct {
|
||||
client *tencentcloud.Provider
|
||||
domain string
|
||||
}
|
||||
|
||||
// NewTencentCloudProvider 创建腾讯云 DNS 服务商实例
|
||||
func NewTencentCloudProvider(config ProviderConfig) (*TencentCloudProvider, error) {
|
||||
if config.SecretId == "" || config.SecretKey == "" {
|
||||
return nil, fmt.Errorf("SecretId 和 SecretKey 不能为空")
|
||||
}
|
||||
|
||||
provider := &tencentcloud.Provider{
|
||||
SecretId: config.SecretId,
|
||||
SecretKey: config.SecretKey,
|
||||
}
|
||||
|
||||
return &TencentCloudProvider{
|
||||
client: provider,
|
||||
domain: config.Domain,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AppendRecords 添加 DNS 记录
|
||||
func (p *TencentCloudProvider) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error) {
|
||||
return p.client.AppendRecords(ctx, zone, recs)
|
||||
}
|
||||
|
||||
// SetRecords 设置 DNS 记录(会覆盖现有记录)
|
||||
func (p *TencentCloudProvider) SetRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error) {
|
||||
return p.client.SetRecords(ctx, zone, recs)
|
||||
}
|
||||
|
||||
// GetRecords 获取 DNS 记录
|
||||
func (p *TencentCloudProvider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) {
|
||||
return p.client.GetRecords(ctx, zone)
|
||||
}
|
||||
|
||||
// DeleteRecords 删除 DNS 记录
|
||||
func (p *TencentCloudProvider) DeleteRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error) {
|
||||
return p.client.DeleteRecords(ctx, zone, recs)
|
||||
}
|
||||
Reference in New Issue
Block a user