From 22f4cc7fcb88a04b99a83c61348aee024a86a1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Wed, 3 Jul 2024 01:45:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/controllers/cert_controller.go | 4 ++++ app/http/requests/cert/dns_store.go | 6 +++--- app/models/cert_dns.go | 2 +- docs/docs.go | 2 +- docs/swagger.json | 2 +- docs/swagger.yaml | 2 +- go.mod | 2 ++ go.sum | 4 ++++ pkg/acme/solvers.go | 7 +++++++ 9 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/http/controllers/cert_controller.go b/app/http/controllers/cert_controller.go index e684d413bb..374f481141 100644 --- a/app/http/controllers/cert_controller.go +++ b/app/http/controllers/cert_controller.go @@ -73,6 +73,10 @@ func (r *CertController) DNSProviders(ctx http.Context) http.Response { "name": "DNSPod", "dns": acme.DnsPod, }, + { + "name": "腾讯云", + "dns": acme.Tencent, + }, { "name": "阿里云", "dns": acme.AliYun, diff --git a/app/http/requests/cert/dns_store.go b/app/http/requests/cert/dns_store.go index e8f5c309de..847423f5d0 100644 --- a/app/http/requests/cert/dns_store.go +++ b/app/http/requests/cert/dns_store.go @@ -19,13 +19,13 @@ func (r *DNSStore) Authorize(ctx http.Context) error { func (r *DNSStore) Rules(ctx http.Context) map[string]string { return map[string]string{ - "type": "required|in:dnspod,aliyun,cloudflare", + "type": "required|in:dnspod,tencent,aliyun,cloudflare", "name": "required", "data": "required", "data.id": "required_if:type,dnspod", "data.token": "required_if:type,dnspod", - "data.access_key": "required_if:type,aliyun", - "data.secret_key": "required_if:type,aliyun", + "data.access_key": "required_if:type,aliyun,tencent", + "data.secret_key": "required_if:type,aliyun,tencent", "data.api_key": "required_if:type,cloudflare", } } diff --git a/app/models/cert_dns.go b/app/models/cert_dns.go index 74bd269e4d..df85cb1bac 100644 --- a/app/models/cert_dns.go +++ b/app/models/cert_dns.go @@ -9,7 +9,7 @@ import ( type CertDNS struct { orm.Model Name string `gorm:"not null" json:"name"` // 备注名称 - Type string `gorm:"not null" json:"type"` // DNS 提供商 (dnspod, aliyun, cloudflare) + Type string `gorm:"not null" json:"type"` // DNS 提供商 (dnspod, tencent, aliyun, cloudflare) Data acme.DNSParam `gorm:"not null;serializer:json" json:"dns_param"` Certs []*Cert `gorm:"foreignKey:DNSID" json:"-"` diff --git a/docs/docs.go b/docs/docs.go index eac911c400..979a5107f4 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5158,7 +5158,7 @@ const docTemplate = `{ "type": "string" }, "type": { - "description": "DNS 提供商 (dnspod, aliyun, cloudflare)", + "description": "DNS 提供商 (dnspod, tencent, aliyun, cloudflare)", "type": "string" }, "updated_at": { diff --git a/docs/swagger.json b/docs/swagger.json index fded468776..e438c38039 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5151,7 +5151,7 @@ "type": "string" }, "type": { - "description": "DNS 提供商 (dnspod, aliyun, cloudflare)", + "description": "DNS 提供商 (dnspod, tencent, aliyun, cloudflare)", "type": "string" }, "updated_at": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 16e1a66cd7..9ddc1e92e7 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -148,7 +148,7 @@ definitions: description: 备注名称 type: string type: - description: DNS 提供商 (dnspod, aliyun, cloudflare) + description: DNS 提供商 (dnspod, tencent, aliyun, cloudflare) type: string updated_at: $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' diff --git a/go.mod b/go.mod index 38bdfe36f8..f1a12546f9 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/libdns/cloudflare v0.1.1 github.com/libdns/dnspod v0.0.3 github.com/libdns/libdns v0.2.2 + github.com/libdns/tencentcloud v1.0.0 github.com/mholt/acmez/v2 v2.0.1 github.com/mholt/archiver/v3 v3.5.1 github.com/shirou/gopsutil v3.21.11+incompatible @@ -167,6 +168,7 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/swaggo/files/v2 v2.0.0 // indirect + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.597 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect diff --git a/go.sum b/go.sum index f034187c03..09421d9dfe 100644 --- a/go.sum +++ b/go.sum @@ -361,6 +361,8 @@ github.com/libdns/libdns v0.2.0/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSO github.com/libdns/libdns v0.2.1/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40= github.com/libdns/libdns v0.2.2 h1:O6ws7bAfRPaBsgAYt8MDe2HcNBGC29hkZ9MX2eUSX3s= github.com/libdns/libdns v0.2.2/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ= +github.com/libdns/tencentcloud v1.0.0 h1:u4LXnYu/lu/9P5W+MCVPeSDnwI+6w+DxYhQ1wSnQOuU= +github.com/libdns/tencentcloud v1.0.0/go.mod h1:NlCgPumzUsZWSOo1+Q/Hfh8G6TNRAaTUeWQdg6LbtUI= github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4= github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -509,6 +511,8 @@ github.com/swaggo/http-swagger/v2 v2.0.2 h1:FKCdLsl+sFCx60KFsyM0rDarwiUSZ8DqbfSy github.com/swaggo/http-swagger/v2 v2.0.2/go.mod h1:r7/GBkAWIfK6E/OLnE8fXnviHiDeAHmgIyooa4xm3AQ= github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.597 h1:C0GHdLTfikLVoEzfhgPfrZ7LwlG0xiCmk6iwNKE+xs0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.597/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= diff --git a/pkg/acme/solvers.go b/pkg/acme/solvers.go index ea5f68fac0..dac87a3bf0 100644 --- a/pkg/acme/solvers.go +++ b/pkg/acme/solvers.go @@ -3,6 +3,7 @@ package acme import ( "context" "fmt" + "github.com/libdns/tencentcloud" "os" "path/filepath" "time" @@ -125,6 +126,11 @@ func (s dnsSolver) getDNSProvider() (DNSProvider, error) { dns = &dnspod.Provider{ APIToken: s.param.ID + "," + s.param.Token, } + case Tencent: + dns = &tencentcloud.Provider{ + SecretId: s.param.AccessKey, + SecretKey: s.param.SecretKey, + } case AliYun: dns = &alidns.Provider{ AccKeyID: s.param.AccessKey, @@ -145,6 +151,7 @@ type DnsType string const ( DnsPod DnsType = "dnspod" + Tencent DnsType = "tencent" AliYun DnsType = "aliyun" CloudFlare DnsType = "cloudflare" )