From 837705f66f3ceb72d0121f977d99c75fa06c1b18 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Fri, 25 Nov 2022 16:23:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0cloudFlare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/ssl/client.go | 15 +++++++++++++-- frontend/src/lang/modules/zh.ts | 2 +- .../website/ssl/dns-account/create/index.vue | 10 ++++++++++ .../src/views/website/ssl/dns-account/index.vue | 7 ++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/backend/utils/ssl/client.go b/backend/utils/ssl/client.go index 754b47015..ccefdc807 100644 --- a/backend/utils/ssl/client.go +++ b/backend/utils/ssl/client.go @@ -10,6 +10,7 @@ import ( "github.com/go-acme/lego/v4/challenge/dns01" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/providers/dns/alidns" + "github.com/go-acme/lego/v4/providers/dns/cloudflare" "github.com/go-acme/lego/v4/providers/dns/dnspod" "github.com/go-acme/lego/v4/providers/http/webroot" "github.com/go-acme/lego/v4/registration" @@ -62,8 +63,9 @@ func NewAcmeClient(email, privateKey string) (*AcmeClient, error) { type DnsType string const ( - DnsPod DnsType = "DnsPod" - AliYun DnsType = "AliYun" + DnsPod DnsType = "DnsPod" + AliYun DnsType = "AliYun" + Cloudflare DnsType = "Cloudflare" ) type DNSParam struct { @@ -101,6 +103,15 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string) error { return err } } + if dnsType == Cloudflare { + cloudflareConfig := cloudflare.NewDefaultConfig() + cloudflareConfig.AuthEmail = param.Email + cloudflareConfig.AuthKey = param.APIkey + p, err = cloudflare.NewDNSProviderConfig(cloudflareConfig) + if err != nil { + return err + } + } return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(3*time.Minute)) } diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 997c1604f..b2d00b9bd 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -729,7 +729,7 @@ export default { applySSL: '证书申请', SSLList: '证书列表', createDnsAccount: 'DNS账号', - aliyun: '阿里云', + aliyun: '阿里云DNS', manual: '手动解析', key: '密钥', check: '查看', diff --git a/frontend/src/views/website/ssl/dns-account/create/index.vue b/frontend/src/views/website/ssl/dns-account/create/index.vue index cdeb347d5..86176758c 100644 --- a/frontend/src/views/website/ssl/dns-account/create/index.vue +++ b/frontend/src/views/website/ssl/dns-account/create/index.vue @@ -30,6 +30,14 @@ +
+ + + + + + +
- + + +