Skip to content

Commit

Permalink
feat:证书 DNS 账号增加腾讯云类型 (#3673)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 authored Jan 22, 2024
1 parent e46f931 commit 64def5b
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 10 deletions.
25 changes: 18 additions & 7 deletions backend/utils/ssl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/go-acme/lego/v4/providers/dns/namecheap"
"github.com/go-acme/lego/v4/providers/dns/namedotcom"
"github.com/go-acme/lego/v4/providers/dns/namesilo"
"github.com/go-acme/lego/v4/providers/dns/tencentcloud"
"github.com/go-acme/lego/v4/providers/http/webroot"
"github.com/go-acme/lego/v4/registration"
"github.com/pkg/errors"
Expand Down Expand Up @@ -60,13 +61,14 @@ func NewAcmeClient(acmeAccount *model.WebsiteAcmeAccount) (*AcmeClient, error) {
type DnsType string

const (
DnsPod DnsType = "DnsPod"
AliYun DnsType = "AliYun"
CloudFlare DnsType = "CloudFlare"
NameSilo DnsType = "NameSilo"
NameCheap DnsType = "NameCheap"
NameCom DnsType = "NameCom"
Godaddy DnsType = "Godaddy"
DnsPod DnsType = "DnsPod"
AliYun DnsType = "AliYun"
CloudFlare DnsType = "CloudFlare"
NameSilo DnsType = "NameSilo"
NameCheap DnsType = "NameCheap"
NameCom DnsType = "NameCom"
Godaddy DnsType = "Godaddy"
TencentCloud DnsType = "TencentCloud"
)

type DNSParam struct {
Expand All @@ -78,6 +80,7 @@ type DNSParam struct {
APIkey string `json:"apiKey"`
APIUser string `json:"apiUser"`
APISecret string `json:"apiSecret"`
SecretID string `json:"secretID"`
}

func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool) error {
Expand Down Expand Up @@ -146,6 +149,14 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool) e
nameComConfig.PollingInterval = 30 * time.Second
nameComConfig.TTL = 3600
p, err = namedotcom.NewDNSProviderConfig(nameComConfig)
case TencentCloud:
tencentCloudConfig := tencentcloud.NewDefaultConfig()
tencentCloudConfig.SecretID = param.SecretID
tencentCloudConfig.SecretKey = param.SecretKey
tencentCloudConfig.PropagationTimeout = 30 * time.Minute
tencentCloudConfig.PollingInterval = 30 * time.Second
tencentCloudConfig.TTL = 3600
p, err = tencentcloud.NewDNSProviderConfig(tencentCloudConfig)
}
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/global/mimetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ export const DNSTypes = [
value: 'AliYun',
},
{
label: 'DNSPod',
label: i18n.global.t('website.tencentCloud'),
value: 'TencentCloud',
},
{
label: 'DNSPod (' + i18n.global.t('ssl.deprecated') + ')',
value: 'DnsPod',
},
{
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,7 @@ const message = {
primaryDomainHelper: 'Support domain name: port',
acmeAccountType: 'Account Type',
keyType: 'Key algorithm',
tencentCloud: 'Tencent Cloud',
},
php: {
short_open_tag: 'Short tag support',
Expand Down Expand Up @@ -1938,6 +1939,9 @@ const message = {
skipDNSCheck: 'Skip DNS check',
skipDNSCheckHelper: 'If there is an application timeout problem, please check here, otherwise do not check it',
cfHelper: 'Do not use Global API Key',
deprecated: 'will be deprecated',
deprecatedHelper:
'Maintenance has been stopped and may be abandoned in a future version. Please use Tencent Cloud method for analysis',
},
firewall: {
create: 'Create rule',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,7 @@ const message = {
primaryDomainHelper: '支援網域:port',
acmeAccountType: '賬號類型',
keyType: '密鑰演算法',
tencentCloud: '騰訊雲',
},
php: {
short_open_tag: '短標簽支持',
Expand Down Expand Up @@ -1819,6 +1820,8 @@ const message = {
skipDNSCheck: '跳 DNS 校驗',
skipDNSCheckHelper: '如果出現申請超時問題請勾選此處其他情況請勿勾選',
cfHelper: '請勿使用 Global API Key',
deprecated: '即將廢棄',
deprecatedHelper: '已經停止維護可能會在以後的某個版本廢棄請使用騰訊雲方式解析',
},
firewall: {
create: '創建規則',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,7 @@ const message = {
primaryDomainHelper: '支持域名:端口',
acmeAccountType: '账号类型',
keyType: '密钥算法',
tencentCloud: '腾讯云',
},
php: {
short_open_tag: '短标签支持',
Expand Down Expand Up @@ -1819,6 +1820,8 @@ const message = {
skipDNSCheck: '跳 DNS 校验',
skipDNSCheckHelper: '如果出现申请超时问题请勾选此处其他情况请勿勾选',
cfHelper: '请勿使用 Global API Key',
deprecated: '即将废弃',
deprecatedHelper: '已经停止维护可能会在以后的某个版本废弃请使用腾讯云方式解析',
},
firewall: {
create: '创建规则',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/website/ssl/detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
v-if="ssl.dnsAccount && ssl.dnsAccount.id > 0"
>
{{ ssl.dnsAccount.name }}
<el-tag type="info">{{ ssl.dnsAccount.type }}</el-tag>
<el-tag type="info">{{ getDNSName(ssl.dnsAccount.type) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item
:label="$t('ssl.acmeAccount')"
Expand Down Expand Up @@ -76,7 +76,7 @@
import DrawerHeader from '@/components/drawer-header/index.vue';
import { GetSSL } from '@/api/modules/website';
import { ref } from 'vue';
import { dateFormatSimple, getProvider } from '@/utils/util';
import { dateFormatSimple, getProvider, getDNSName } from '@/utils/util';
const open = ref(false);
const id = ref(0);
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/views/website/ssl/dns-account/create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
:value="type.value"
></el-option>
</el-select>
<span class="input-help text-red-500" v-if="account.type === 'DnsPod'">
{{ $t('ssl.deprecatedHelper') }}
</span>
</el-form-item>
<div v-if="account.type === 'AliYun'">
<el-form-item label="Access Key" prop="authorization.accessKey">
Expand All @@ -31,6 +34,14 @@
<el-input v-model.trim="account.authorization['secretKey']"></el-input>
</el-form-item>
</div>
<div v-if="account.type === 'TencentCloud'">
<el-form-item label="Secret ID" prop="authorization.secretID">
<el-input v-model.trim="account.authorization['secretID']"></el-input>
</el-form-item>
<el-form-item label="Secret Key" prop="authorization.secretKey">
<el-input v-model.trim="account.authorization['secretKey']"></el-input>
</el-form-item>
</div>
<div v-if="account.type === 'DnsPod'">
<el-form-item label="ID" prop="authorization.id">
<el-input v-model.trim="account.authorization['id']"></el-input>
Expand Down Expand Up @@ -119,6 +130,7 @@ const rules = ref<any>({
email: [Rules.requiredInput],
apiKey: [Rules.requiredInput],
apiUser: [Rules.requiredInput],
secretID: [Rules.requiredInput],
},
});
const account = ref({
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.490 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.490 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
github.com/theupdateframework/notary v0.7.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
Expand Down
Loading

0 comments on commit 64def5b

Please sign in to comment.