Initial commit

This commit is contained in:
2026-06-30 15:14:37 +08:00
commit 15dab96872
311 changed files with 95639 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
package dnsprovider
import (
"context"
"fmt"
"github.com/libdns/cloudflare"
"github.com/libdns/libdns"
)
// CloudflareProvider Cloudflare DNS 服务商实现
type CloudflareProvider struct {
client *cloudflare.Provider
domain string
}
// NewCloudflareProvider 创建 Cloudflare DNS 服务商实例
func NewCloudflareProvider(config ProviderConfig) (*CloudflareProvider, error) {
if config.APIToken == "" {
return nil, fmt.Errorf("API Token 不能为空")
}
provider := &cloudflare.Provider{
APIToken: config.APIToken,
}
return &CloudflareProvider{
client: provider,
domain: config.Domain,
}, nil
}
// AppendRecords 添加 DNS 记录
func (p *CloudflareProvider) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error) {
return p.client.AppendRecords(ctx, zone, recs)
}
// SetRecords 设置 DNS 记录(会覆盖现有记录)
func (p *CloudflareProvider) SetRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error) {
return p.client.SetRecords(ctx, zone, recs)
}
// GetRecords 获取 DNS 记录
func (p *CloudflareProvider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) {
return p.client.GetRecords(ctx, zone)
}
// DeleteRecords 删除 DNS 记录
func (p *CloudflareProvider) DeleteRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error) {
return p.client.DeleteRecords(ctx, zone, recs)
}