Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pr_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ jobs:
UNIFI_HOST: ${{ secrets.UNIFI_HOST }}
UNIFI_SITE: ${{ secrets.UNIFI_SITE }}
UNIFI_SKIP_TLS_VERIFY: ${{ secrets.UNIFI_SKIP_TLS_VERIFY }}
#
TENCENTDNS_SECRET_ID: ${{ secrets.TENCENTDNS_SECRET_ID }}
TENCENTDNS_SECRET_KEY: ${{ secrets.TENCENTDNS_SECRET_KEY }}

concurrency:
group: ${{ github.workflow }}-${{ matrix.provider }}
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ changelog:
regexp: "(?i)^.*(major|new provider|feature)[(\\w)]*:+.*$"
order: 1
- title: 'Provider-specific changes:'
regexp: "(?i)((adguardhome|akamaiedgedns|alidns|autodns|axfrddns|azure_dns|azure_private_dns|bind|bunny_dns|cloudflare|cloudflareapi|cloudns|cnr|cscglobal|desec|digitalocean|dnscale|dnsimple|dnsmadeeasy|dnsoverhttps|domainnameshop|dynadot|easyname|exoscale|fortigate|gandi_v5|gcloud|gcore|gidinet|hedns|hetzner|hetzner_v2|hostingde|huaweicloud|infomaniak|internetbs|inwx|joker|linode|loopia|luadns|mikrotik|mythicbeasts|namecheap|namedotcom|netcup|netlify|ns1|opensrs|oracle|ovh|packetframe|porkbun|powerdns|realtimeregister|route53|rwth|sakuracloud|softlayer|transip|unifi|vercel|vultr).*:)+.*"
regexp: "(?i)((adguardhome|akamaiedgedns|alidns|autodns|axfrddns|azure_dns|azure_private_dns|bind|bunny_dns|cloudflare|cloudflareapi|cloudns|cnr|cscglobal|desec|digitalocean|dnscale|dnsimple|dnsmadeeasy|dnsoverhttps|domainnameshop|dynadot|easyname|exoscale|fortigate|gandi_v5|gcloud|gcore|gidinet|hedns|hetzner|hetzner_v2|hostingde|huaweicloud|infomaniak|internetbs|inwx|joker|linode|loopia|luadns|mikrotik|mythicbeasts|namecheap|namedotcom|netcup|netlify|ns1|opensrs|oracle|ovh|packetframe|porkbun|powerdns|realtimeregister|route53|rwth|sakuracloud|softlayer|transip|tencentdns|unifi|vercel|vultr).*:)+.*"
order: 2
- title: 'Documentation:'
regexp: "(?i)^.*(docs)[(\\w)]*:+.*$"
Expand Down
1 change: 1 addition & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ providers/transip @blackshadev
providers/unifi @zupolgec
providers/vercel @SukkaW
providers/vultr @pgaskin
providers/tencentdns @cylonchau
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Currently supported DNS providers:
- RWTH DNS-Admin
- Sakura Cloud
- SoftLayer
- Tencent Cloud DNS (TENCENTDNS/DNSPOD)
- TransIP
- UniFi Network
- Vercel
Expand All @@ -94,6 +95,7 @@ Currently supported Domain Registrars:
- OVH
- Porkbun
- Realtime Register
- Tencent Cloud DNS (TENCENTDNS/DNSPOD)

Stack Overflow uses this system to manage hundreds of domains
and subdomains across multiple registrars and DNS providers.
Expand Down
12 changes: 9 additions & 3 deletions documentation/provider/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Jump to a table:
| [`RWTH`](rwth.md) | ❌ | ✅ | ❌ |
| [`SAKURACLOUD`](sakuracloud.md) | ❌ | ✅ | ❌ |
| [`SOFTLAYER`](softlayer.md) | ❌ | ✅ | ❌ |
| [`TENCENTDNS`](tencentdns.md) | ❌ | ✅ | ✅ |
| [`TRANSIP`](transip.md) | ❌ | ✅ | ❌ |
| [`UNIFI`](unifi.md) | ❌ | ✅ | ❌ |
| [`VERCEL`](vercel.md) | ❌ | ✅ | ❌ |
Expand Down Expand Up @@ -147,6 +148,7 @@ Jump to a table:
| [`RWTH`](rwth.md) | ❔ | ❌ | ❌ | ✅ |
| [`SAKURACLOUD`](sakuracloud.md) | ❔ | ❌ | ✅ | ✅ |
| [`SOFTLAYER`](softlayer.md) | ❔ | ❔ | ❌ | ❔ |
| [`TENCENTDNS`](tencentdns.md) | ✅ | ✅ | ✅ | ✅ |
| [`TRANSIP`](transip.md) | ✅ | ❌ | ❌ | ✅ |
| [`UNIFI`](unifi.md) | ❌ | ❔ | ❌ | ❌ |
| [`VERCEL`](vercel.md) | ❔ | ❌ | ❌ | ❌ |
Expand Down Expand Up @@ -209,6 +211,7 @@ Jump to a table:
| [`RWTH`](rwth.md) | ❌ | ❔ | ❌ | ✅ | ❔ |
| [`SAKURACLOUD`](sakuracloud.md) | ✅ | ❌ | ❌ | ✅ | ❌ |
| [`SOFTLAYER`](softlayer.md) | ❔ | ❔ | ❌ | ❔ | ❔ |
| [`TENCENTDNS`](tencentdns.md) | ❌ | ❔ | ❔ | ✅ | ❔ |
| [`TRANSIP`](transip.md) | ✅ | ❌ | ❌ | ❌ | ❌ |
| [`UNIFI`](unifi.md) | ❌ | ❔ | ❌ | ❌ | ❔ |
| [`VERCEL`](vercel.md) | ✅ | ❌ | ❌ | ❌ | ❌ |
Expand Down Expand Up @@ -270,6 +273,7 @@ Jump to a table:
| [`RWTH`](rwth.md) | ❔ | ❌ | ✅ | ❔ |
| [`SAKURACLOUD`](sakuracloud.md) | ❌ | ❌ | ✅ | ✅ |
| [`SOFTLAYER`](softlayer.md) | ❔ | ❔ | ✅ | ❔ |
| [`TENCENTDNS`](tencentdns.md) | ❔ | ❔ | ✅ | ❔ |
| [`TRANSIP`](transip.md) | ❌ | ✅ | ✅ | ❌ |
| [`UNIFI`](unifi.md) | ❔ | ❔ | ✅ | ❔ |
| [`VERCEL`](vercel.md) | ❌ | ❌ | ✅ | ❌ |
Expand Down Expand Up @@ -372,6 +376,7 @@ Jump to a table:
| [`POWERDNS`](powerdns.md) | ✅ | ✅ | ✅ |
| [`REALTIMEREGISTER`](realtimeregister.md) | ✅ | ❔ | ❌ |
| [`SAKURACLOUD`](sakuracloud.md) | ❌ | ❌ | ❌ |
| [`TENCENTDNS`](tencentdns.md) | ❌ | ❔ | ❔ |
| [`TRANSIP`](transip.md) | ❌ | ❌ | ❌ |
| [`VERCEL`](vercel.md) | ❌ | ❌ | ❌ |

Expand Down Expand Up @@ -461,9 +466,10 @@ Providers in this category and their maintainers are:
|[`REALTIMEREGISTER`](realtimeregister.md)|@PJEilers|
|[`ROUTE53`](route53.md)|@tresni|
|[`RWTH`](rwth.md)|@MisterErwin|
|[`SAKURACLOUD`](sakuracloud.md)|@ttkzw|
|[`SOFTLAYER`](softlayer.md)|@jamielennox|
|[`TRANSIP`](transip.md)|@blackshadev|
| [`SAKURACLOUD`](sakuracloud.md) | @ttkzw |
| [`SOFTLAYER`](softlayer.md) | @jamielennox |
| [`TENCENTDNS`](tencentdns.md) | @cylonchau |
| [`TRANSIP`](transip.md) | @blackshadev |
|[`VERCEL`](vercel.md)|@SukkaW|
|[`VULTR`](vultr.md)|@pgaskin|

Expand Down
63 changes: 63 additions & 0 deletions documentation/provider/tencentdns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Configuration

{% hint style="info" %}
This provider is developed for the **Tencent Cloud API 3.0** platform.
{% endhint %}

This provider is for [Tencent Cloud DNS](https://cloud.tencent.com/product/cns) (DNSPod). To use this provider, add an entry to `creds.json` with `TYPE` set to `TENCENTDNS` along with your API credentials.

Example:

{% code title="creds.json" %}
```json
{
"tencentdns": {
"TYPE": "TENCENTDNS",
"secret_id": "YOUR_SECRET_ID",
"secret_key": "YOUR_SECRET_KEY"
}
}
```
{% endcode %}

Optionally, you can specify a `region` (defaults to `"ap-guangzhou"`):

{% code title="creds.json" %}
```json
{
"tencentdns": {
"TYPE": "TENCENTDNS",
"secret_id": "YOUR_SECRET_ID",
"secret_key": "YOUR_SECRET_KEY",
"region": "ap-guangzhou"
}
}
```
{% endcode %}

## Usage

An example configuration:

{% code title="dnsconfig.js" %}
```javascript
var REG_TENCENT = NewRegistrar("tencentdns", "TENCENTDNS");
var DSP_TENCENT = NewDnsProvider("tencentdns", "TENCENTDNS");

D("example.com", REG_TENCENT, DnsProvider(DSP_TENCENT),
A("@", "1.2.3.4"),
CNAME("www", "example.com."),
MX("@", 10, "mail.example.com."),
TXT("test", "hello world")
);
```
{% endcode %}

## Important Notes

### Features

- **MX Records**: Priority and target are handled automatically.
- **Registrar Support**: Supports updating authoritative nameservers for domains registered with Tencent Cloud.
- **Line Management**: All records are created on the "默认" (Default) line.
- **New Domains**: DNSControl will automatically create non-existent domains in your account.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ require (
github.com/nicholas-fedor/shoutrrr v0.15.0
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481
github.com/oracle/oci-go-sdk/v65 v65.114.1
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.93
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.3.78
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain v1.3.66
github.com/urfave/cli/v3 v3.8.0
github.com/vercel/terraform-provider-vercel v1.14.1
github.com/vultr/govultr/v2 v2.17.2
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.66/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.78/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.93 h1:LItHgi4vvgkfLLFLhL8FL2yOxoquKMrhaWy70vewa2g=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.93/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.3.78 h1:Wr/AVJTVlCLG+FJnp2+xveQs9zUT8pB1kfTOZ0drhv8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.3.78/go.mod h1:cLF8HFXXVj5VmAL/yRn/TEnN14fyRDi1elg1hx4f7Es=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain v1.3.66 h1:cn5pZx45fXoqKIiNbNVzrVNfky16tPL2x1Fq6kBFlgc=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain v1.3.66/go.mod h1:+qAEFuRYl5CHjLOfS55Ce/9jEgX06R6TEWsdVVM60Nc=
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/transip/gotransip/v6 v6.27.1 h1:J8DfGAxnFZxNYdIRj59D6uFm0FPOkx9tF1aCkGgXeR8=
Expand Down
6 changes: 6 additions & 0 deletions integrationTest/profiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@
"domain": "$SL_DOMAIN",
"username": "$SL_USERNAME"
},
"TENCENTDNS": {
"TYPE": "TENCENTDNS",
"secret_id": "$TENCENTDNS_SECRET_ID",
"secret_key": "$TENCENTDNS_SECRET_KEY",
"domain": "$TENCENTDNS_DOMAIN"
},
"TRANSIP": {
"AccessToken": "$TRANSIP_ACCESS_TOKEN",
"AccountName": "$TRANSIP_ACCOUNT_NAME",
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/_all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
_ "github.com/DNSControl/dnscontrol/v4/providers/rwth"
_ "github.com/DNSControl/dnscontrol/v4/providers/sakuracloud"
_ "github.com/DNSControl/dnscontrol/v4/providers/softlayer"
_ "github.com/DNSControl/dnscontrol/v4/providers/tencentdns"
_ "github.com/DNSControl/dnscontrol/v4/providers/transip"
_ "github.com/DNSControl/dnscontrol/v4/providers/unifi"
_ "github.com/DNSControl/dnscontrol/v4/providers/vercel"
Expand Down
125 changes: 125 additions & 0 deletions providers/tencentdns/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package tencentdns

import (
"fmt"

"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
dnspod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323"
domain "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/domain/v20180808"
)

type tencentCloudClient struct {
dnspodClient *dnspod.Client
domainClient *domain.Client
}

func newClient(secretId, secretKey, region string) (*tencentCloudClient, error) {
credential := common.NewCredential(secretId, secretKey)
cpf := profile.NewClientProfile()

// DNSPod client
dpc, err := dnspod.NewClient(credential, region, cpf)
if err != nil {
return nil, fmt.Errorf("failed to create dnspod client: %w", err)
}

// Domain client
dmc, err := domain.NewClient(credential, region, cpf)
if err != nil {
return nil, fmt.Errorf("failed to create domain client: %w", err)
}

return &tencentCloudClient{
dnspodClient: dpc,
domainClient: dmc,
}, nil
}

func (c *tencentCloudClient) fetchRecords(domainName string) ([]*dnspod.RecordListItem, error) {
var records []*dnspod.RecordListItem
var offset uint64 = 0
var limit uint64 = 1000

for {
request := dnspod.NewDescribeRecordListRequest()
request.Domain = common.StringPtr(domainName)
request.Offset = common.Uint64Ptr(offset)
request.Limit = common.Uint64Ptr(limit)

response, err := c.dnspodClient.DescribeRecordList(request)
if err != nil {
return nil, err
}

records = append(records, response.Response.RecordList...)

if uint64(len(records)) >= *response.Response.RecordCountInfo.TotalCount {
break
}
offset += limit
}

return records, nil
}

func (c *tencentCloudClient) getNameservers(domainName string) ([]string, error) {
request := dnspod.NewDescribeDomainRequest()
request.Domain = common.StringPtr(domainName)

response, err := c.dnspodClient.DescribeDomain(request)
if err != nil {
return nil, err
}

var nss []string
for _, ns := range response.Response.DomainInfo.DnspodNsList {
nss = append(nss, *ns)
}
return nss, nil
}

func (c *tencentCloudClient) getRegistrarNameservers(domainName string) ([]string, error) {
request := dnspod.NewDescribeDomainWhoisRequest()
request.Domain = common.StringPtr(domainName)

response, err := c.dnspodClient.DescribeDomainWhois(request)
if err != nil {
return nil, err
}

var nss []string
for _, ns := range response.Response.Info.NameServers {
nss = append(nss, *ns)
}
return nss, nil
}

func (c *tencentCloudClient) updateRegistrarNameservers(domainName string, nss []string) error {
request := domain.NewModifyDomainDNSBatchRequest()
request.Domains = common.StringPtrs([]string{domainName})
request.Dns = common.StringPtrs(nss)

_, err := c.domainClient.ModifyDomainDNSBatch(request)
return err
}

func (c *tencentCloudClient) createRecord(domainName string, request *dnspod.CreateRecordRequest) error {
request.Domain = common.StringPtr(domainName)
_, err := c.dnspodClient.CreateRecord(request)
return err
}

func (c *tencentCloudClient) modifyRecord(domainName string, request *dnspod.ModifyRecordRequest) error {
request.Domain = common.StringPtr(domainName)
_, err := c.dnspodClient.ModifyRecord(request)
return err
}

func (c *tencentCloudClient) deleteRecord(domainName string, recordId uint64) error {
request := dnspod.NewDeleteRecordRequest()
request.Domain = common.StringPtr(domainName)
request.RecordId = common.Uint64Ptr(recordId)
_, err := c.dnspodClient.DeleteRecord(request)
return err
}
18 changes: 18 additions & 0 deletions providers/tencentdns/auditrecords.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package tencentdns

import (
"github.com/DNSControl/dnscontrol/v4/models"
"github.com/DNSControl/dnscontrol/v4/pkg/rejectif"
)

// AuditRecords returns a list of errors corresponding to the records
// that aren't supported by this provider. If all records are
// supported, an empty list is returned.
func AuditRecords(records []*models.RecordConfig) []error {
a := rejectif.Auditor{}

a.Add("MX", rejectif.MxNull)
a.Add("TXT", rejectif.TxtIsEmpty)

return a.Audit(records)
}
Loading