mirror of
https://github.com/go-acme/lego.git
synced 2026-01-25 05:06:16 +00:00
Add DNS provider for JDCloud (#2782)
This commit is contained in:
committed by
GitHub
parent
c5a259564f
commit
dd6ab7ca95
47
README.md
47
README.md
@@ -177,114 +177,119 @@ If your DNS provider is not supported, please open an [issue](https://github.com
|
||||
<td><a href="https://go-acme.github.io/lego/dns/ispconfigddns/">ISPConfig 3 - Dynamic DNS (DDNS) Module</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/iwantmyname/">iwantmyname (Deprecated)</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/jdcloud/">JD Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/joker/">Joker</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/acme-dns/">Joohoi's ACME-DNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/keyhelp/">KeyHelp</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/keyhelp/">KeyHelp</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/liara/">Liara</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/limacity/">Lima-City</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/linode/">Linode (v4)</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/liquidweb/">Liquid Web</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/liquidweb/">Liquid Web</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/loopia/">Loopia</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/luadns/">LuaDNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mailinabox/">Mail-in-a-Box</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/manageengine/">ManageEngine CloudDNS</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/manageengine/">ManageEngine CloudDNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/manual/">Manual</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/metaname/">Metaname</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/metaregistrar/">Metaregistrar</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mijnhost/">mijn.host</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mijnhost/">mijn.host</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mittwald/">Mittwald</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/myaddr/">myaddr.{tools,dev,io}</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mydnsjp/">MyDNS.jp</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mythicbeasts/">MythicBeasts</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/mythicbeasts/">MythicBeasts</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/namedotcom/">Name.com</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/namecheap/">Namecheap</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/namesilo/">Namesilo</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nearlyfreespeech/">NearlyFreeSpeech.NET</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nearlyfreespeech/">NearlyFreeSpeech.NET</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/neodigit/">Neodigit</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/netcup/">Netcup</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/netlify/">Netlify</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nicmanager/">Nicmanager</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nicmanager/">Nicmanager</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nifcloud/">NIFCloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/njalla/">Njalla</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nodion/">Nodion</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/ns1/">NS1</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/ns1/">NS1</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/octenium/">Octenium</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/otc/">Open Telekom Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/oraclecloud/">Oracle Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/ovh/">OVH</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/ovh/">OVH</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/plesk/">plesk.com</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/porkbun/">Porkbun</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/pdns/">PowerDNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/rackspace/">Rackspace</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/rackspace/">Rackspace</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/rainyun/">Rain Yun/雨云</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/rcodezero/">RcodeZero</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/regru/">reg.ru</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/regfish/">Regfish</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/regfish/">Regfish</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/rfc2136/">RFC2136</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/rimuhosting/">RimuHosting</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/nicru/">RU CENTER</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/sakuracloud/">Sakura Cloud</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/sakuracloud/">Sakura Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/scaleway/">Scaleway</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/selectel/">Selectel</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/selectelv2/">Selectel v2</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/selfhostde/">SelfHost.(de|eu)</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/selfhostde/">SelfHost.(de|eu)</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/servercow/">Servercow</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/shellrent/">Shellrent</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/simply/">Simply.com</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/sonic/">Sonic</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/sonic/">Sonic</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/spaceship/">Spaceship</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/stackpath/">Stackpath</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/syse/">Syse</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/technitium/">Technitium</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/technitium/">Technitium</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/tencentcloud/">Tencent Cloud DNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/edgeone/">Tencent EdgeOne</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/timewebcloud/">Timeweb Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/transip/">TransIP</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/transip/">TransIP</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/safedns/">UKFast SafeDNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/ultradns/">Ultradns</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/uniteddomains/">United-Domains</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/variomedia/">Variomedia</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/variomedia/">Variomedia</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vegadns/">VegaDNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vercel/">Vercel</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/versio/">Versio.[nl|eu|uk]</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vinyldns/">VinylDNS</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vinyldns/">VinylDNS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/virtualname/">Virtualname</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vkcloud/">VK Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/volcengine/">Volcano Engine/火山引擎</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vscale/">Vscale</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vscale/">Vscale</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/vultr/">Vultr</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/webnamesca/">webnames.ca</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/webnames/">webnames.ru</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/websupport/">Websupport</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/websupport/">Websupport</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/wedos/">WEDOS</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/westcn/">West.cn/西部数码</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/yandex360/">Yandex 360</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/yandexcloud/">Yandex Cloud</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/yandexcloud/">Yandex Cloud</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/yandex/">Yandex PDD</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/zoneee/">Zone.ee</a></td>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/zoneedit/">ZoneEdit</a></td>
|
||||
</tr><tr>
|
||||
<td><a href="https://go-acme.github.io/lego/dns/zonomi/">Zonomi</a></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr></table>
|
||||
|
||||
<!-- END DNS PROVIDERS LIST -->
|
||||
|
||||
23
cmd/zz_gen_cmd_dnshelp.go
generated
23
cmd/zz_gen_cmd_dnshelp.go
generated
@@ -105,6 +105,7 @@ func allDNSCodes() string {
|
||||
"ispconfig",
|
||||
"ispconfigddns",
|
||||
"iwantmyname",
|
||||
"jdcloud",
|
||||
"joker",
|
||||
"keyhelp",
|
||||
"liara",
|
||||
@@ -2195,6 +2196,28 @@ func displayDNSHelp(w io.Writer, name string) error {
|
||||
ew.writeln()
|
||||
ew.writeln(`More information: https://go-acme.github.io/lego/dns/iwantmyname`)
|
||||
|
||||
case "jdcloud":
|
||||
// generated from: providers/dns/jdcloud/jdcloud.toml
|
||||
ew.writeln(`Configuration for JD Cloud.`)
|
||||
ew.writeln(`Code: 'jdcloud'`)
|
||||
ew.writeln(`Since: 'v4.31.0'`)
|
||||
ew.writeln()
|
||||
|
||||
ew.writeln(`Credentials:`)
|
||||
ew.writeln(` - "JDCLOUD_ACCESS_KEY_ID": Access key ID`)
|
||||
ew.writeln(` - "JDCLOUD_ACCESS_KEY_SECRET": Access key secret`)
|
||||
ew.writeln()
|
||||
|
||||
ew.writeln(`Additional Configuration:`)
|
||||
ew.writeln(` - "JDCLOUD_HTTP_TIMEOUT": API request timeout in seconds (Default: 30)`)
|
||||
ew.writeln(` - "JDCLOUD_POLLING_INTERVAL": Time between DNS propagation check in seconds (Default: 2)`)
|
||||
ew.writeln(` - "JDCLOUD_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation in seconds (Default: 60)`)
|
||||
ew.writeln(` - "JDCLOUD_REGION_ID": Region ID (Default: cn-north-1)`)
|
||||
ew.writeln(` - "JDCLOUD_TTL": The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)`)
|
||||
|
||||
ew.writeln()
|
||||
ew.writeln(`More information: https://go-acme.github.io/lego/dns/jdcloud`)
|
||||
|
||||
case "joker":
|
||||
// generated from: providers/dns/joker/joker.toml
|
||||
ew.writeln(`Configuration for Joker.`)
|
||||
|
||||
71
docs/content/dns/zz_gen_jdcloud.md
generated
Normal file
71
docs/content/dns/zz_gen_jdcloud.md
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "JD Cloud"
|
||||
date: 2019-03-03T16:39:46+01:00
|
||||
draft: false
|
||||
slug: jdcloud
|
||||
dnsprovider:
|
||||
since: "v4.31.0"
|
||||
code: "jdcloud"
|
||||
url: "https://www.jdcloud.com/"
|
||||
---
|
||||
|
||||
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
||||
<!-- providers/dns/jdcloud/jdcloud.toml -->
|
||||
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
||||
|
||||
|
||||
Configuration for [JD Cloud](https://www.jdcloud.com/).
|
||||
|
||||
|
||||
<!--more-->
|
||||
|
||||
- Code: `jdcloud`
|
||||
- Since: v4.31.0
|
||||
|
||||
|
||||
Here is an example bash command using the JD Cloud provider:
|
||||
|
||||
```bash
|
||||
JDCLOUD_ACCESS_KEY_ID="xxx" \
|
||||
JDCLOUD_ACCESS_KEY_SECRET="yyy" \
|
||||
lego --dns jdcloud -d '*.example.com' -d example.com run
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Credentials
|
||||
|
||||
| Environment Variable Name | Description |
|
||||
|-----------------------|-------------|
|
||||
| `JDCLOUD_ACCESS_KEY_ID` | Access key ID |
|
||||
| `JDCLOUD_ACCESS_KEY_SECRET` | Access key secret |
|
||||
|
||||
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
|
||||
More information [here]({{% ref "dns#configuration-and-credentials" %}}).
|
||||
|
||||
|
||||
## Additional Configuration
|
||||
|
||||
| Environment Variable Name | Description |
|
||||
|--------------------------------|-------------|
|
||||
| `JDCLOUD_HTTP_TIMEOUT` | API request timeout in seconds (Default: 30) |
|
||||
| `JDCLOUD_POLLING_INTERVAL` | Time between DNS propagation check in seconds (Default: 2) |
|
||||
| `JDCLOUD_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation in seconds (Default: 60) |
|
||||
| `JDCLOUD_REGION_ID` | Region ID (Default: cn-north-1) |
|
||||
| `JDCLOUD_TTL` | The TTL of the TXT record used for the DNS challenge in seconds (Default: 120) |
|
||||
|
||||
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
|
||||
More information [here]({{% ref "dns#configuration-and-credentials" %}}).
|
||||
|
||||
|
||||
|
||||
|
||||
## More information
|
||||
|
||||
- [API documentation](https://docs.jdcloud.com/cn/jd-cloud-dns/api/overview)
|
||||
- [Go client](https://github.com/jdcloud-api/jdcloud-sdk-go)
|
||||
|
||||
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
||||
<!-- providers/dns/jdcloud/jdcloud.toml -->
|
||||
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
|
||||
2
docs/data/zz_cli_help.toml
generated
2
docs/data/zz_cli_help.toml
generated
@@ -152,7 +152,7 @@ To display the documentation for a specific DNS provider, run:
|
||||
$ lego dnshelp -c code
|
||||
|
||||
Supported DNS providers:
|
||||
acme-dns, active24, alidns, aliesa, allinkl, alwaysdata, anexia, arvancloud, auroradns, autodns, axelname, azion, azure, azuredns, baiducloud, beget, binarylane, bindman, bluecat, bookmyname, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, com35, conoha, conohav3, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dyndnsfree, dynu, easydns, edgecenter, edgedns, edgeone, efficientip, epik, exec, exoscale, f5xc, freemyip, gandi, gandiv5, gcloud, gcore, gigahostno, glesys, godaddy, googledomains, gravity, hetzner, hostingde, hostinger, hostingnl, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ionoscloud, ipv64, ispconfig, ispconfigddns, iwantmyname, joker, keyhelp, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manageengine, manual, metaname, metaregistrar, mijnhost, mittwald, myaddr, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, neodigit, netcup, netlify, nicmanager, nicru, nifcloud, njalla, nodion, ns1, octenium, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rainyun, rcodezero, regfish, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, selfhostde, servercow, shellrent, simply, sonic, spaceship, stackpath, syse, technitium, tencentcloud, timewebcloud, transip, ultradns, uniteddomains, variomedia, vegadns, vercel, versio, vinyldns, virtualname, vkcloud, volcengine, vscale, vultr, webnames, webnamesca, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneedit, zoneee, zonomi
|
||||
acme-dns, active24, alidns, aliesa, allinkl, alwaysdata, anexia, arvancloud, auroradns, autodns, axelname, azion, azure, azuredns, baiducloud, beget, binarylane, bindman, bluecat, bookmyname, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, com35, conoha, conohav3, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dyndnsfree, dynu, easydns, edgecenter, edgedns, edgeone, efficientip, epik, exec, exoscale, f5xc, freemyip, gandi, gandiv5, gcloud, gcore, gigahostno, glesys, godaddy, googledomains, gravity, hetzner, hostingde, hostinger, hostingnl, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ionoscloud, ipv64, ispconfig, ispconfigddns, iwantmyname, jdcloud, joker, keyhelp, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manageengine, manual, metaname, metaregistrar, mijnhost, mittwald, myaddr, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, neodigit, netcup, netlify, nicmanager, nicru, nifcloud, njalla, nodion, ns1, octenium, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rainyun, rcodezero, regfish, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, selfhostde, servercow, shellrent, simply, sonic, spaceship, stackpath, syse, technitium, tencentcloud, timewebcloud, transip, ultradns, uniteddomains, variomedia, vegadns, vercel, versio, vinyldns, virtualname, vkcloud, volcengine, vscale, vultr, webnames, webnamesca, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneedit, zoneee, zonomi
|
||||
|
||||
More information: https://go-acme.github.io/lego/dns
|
||||
"""
|
||||
|
||||
2
go.mod
2
go.mod
@@ -32,6 +32,7 @@ require (
|
||||
github.com/exoscale/egoscale/v3 v3.1.31
|
||||
github.com/go-acme/alidns-20150109/v4 v4.7.0
|
||||
github.com/go-acme/esa-20240910/v2 v2.40.3
|
||||
github.com/go-acme/jdcloud-sdk-go v1.64.0
|
||||
github.com/go-acme/tencentclouddnspod v1.1.25
|
||||
github.com/go-acme/tencentedgdeone v1.1.48
|
||||
github.com/go-jose/go-jose/v4 v4.1.3
|
||||
@@ -154,6 +155,7 @@ require (
|
||||
github.com/go-resty/resty/v2 v2.17.0 // indirect
|
||||
github.com/goccy/go-yaml v1.9.8 // indirect
|
||||
github.com/gofrs/flock v0.13.0 // indirect
|
||||
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
|
||||
4
go.sum
4
go.sum
@@ -317,6 +317,8 @@ github.com/go-acme/alidns-20150109/v4 v4.7.0 h1:PqJ/wR0JTpL4v0Owu1uM7bPQ1Yww0eQL
|
||||
github.com/go-acme/alidns-20150109/v4 v4.7.0/go.mod h1:btQvB6xZoN6ykKB74cPhiR+uvhrEE2AFVXm6RDmCHm0=
|
||||
github.com/go-acme/esa-20240910/v2 v2.40.3 h1:xXOMRex148wKEHbv7Izn73/HdAxSmz5GOaF4HdnqN+M=
|
||||
github.com/go-acme/esa-20240910/v2 v2.40.3/go.mod h1:ZYdN9EN9ikn26SNapxCVjZ65pHT/1qm4fzuJ7QGVX6g=
|
||||
github.com/go-acme/jdcloud-sdk-go v1.64.0 h1:AW9j5khk8tRYbpBJPxKmqdwIqgLs2Fz3HUK3hn2YXjs=
|
||||
github.com/go-acme/jdcloud-sdk-go v1.64.0/go.mod h1:qc/m8HNX1Zgd7GAv2DSEinup8fwy3Ted3/VVx7LB5bU=
|
||||
github.com/go-acme/tencentclouddnspod v1.1.25 h1:7H3ZKshkaHzCXfRpAHVB5nvxeDDl2XLeNZfrNHiZj/s=
|
||||
github.com/go-acme/tencentclouddnspod v1.1.25/go.mod h1:XXfzp0AYV7UAUsHKT6R0KAUJFhqAUXmWGF07Elpa5cE=
|
||||
github.com/go-acme/tencentedgdeone v1.1.48 h1:WLyLBsRVhSLFmtbEFXk0naLODSQn7X6J0Fc/qR8xVUk=
|
||||
@@ -374,6 +376,8 @@ github.com/goccy/go-yaml v1.9.8/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXK
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
|
||||
github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
|
||||
15
providers/dns/jdcloud/fixtures/create_record-request.json
Normal file
15
providers/dns/jdcloud/fixtures/create_record-request.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"domainId": "20",
|
||||
"regionId": "cn-north-1",
|
||||
"req": {
|
||||
"hostRecord": "_acme-challenge",
|
||||
"hostValue": "ADw2sEd82DUgXcQ9hNBZThJs7zVJkR5v9JeSbAb9mZY",
|
||||
"jcloudRes": null,
|
||||
"mxPriority": null,
|
||||
"port": null,
|
||||
"ttl": 120,
|
||||
"type": "TXT",
|
||||
"viewValue": -1,
|
||||
"weight": null
|
||||
}
|
||||
}
|
||||
25
providers/dns/jdcloud/fixtures/create_record.json
Normal file
25
providers/dns/jdcloud/fixtures/create_record.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"requestId": "azerty",
|
||||
"error": {
|
||||
"code": 0,
|
||||
"status": "",
|
||||
"message": ""
|
||||
},
|
||||
"result": {
|
||||
"dataList": {
|
||||
"id": 123,
|
||||
"hostRecord": "_acme-challenge",
|
||||
"hostValue": "ADw2sEd82DUgXcQ9hNBZThJs7zVJkR5v9JeSbAb9mZY",
|
||||
"jcloudRes": false,
|
||||
"mxPriority": 0,
|
||||
"port": 0,
|
||||
"ttl": 120,
|
||||
"type": "TXT",
|
||||
"weight": 0,
|
||||
"viewValue": [
|
||||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
9
providers/dns/jdcloud/fixtures/delete_record.json
Normal file
9
providers/dns/jdcloud/fixtures/delete_record.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"requestId": "azerty",
|
||||
"error": {
|
||||
"code": 0,
|
||||
"status": "",
|
||||
"message": ""
|
||||
},
|
||||
"result": {}
|
||||
}
|
||||
55
providers/dns/jdcloud/fixtures/describe_domains_page1.json
Normal file
55
providers/dns/jdcloud/fixtures/describe_domains_page1.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"requestId": "azerty",
|
||||
"error": {
|
||||
"code": 0,
|
||||
"status": "",
|
||||
"message": ""
|
||||
},
|
||||
"result": {
|
||||
"dataList": [
|
||||
{
|
||||
"id": 1,
|
||||
"domainName": "1.example"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"domainName": "2.example"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"domainName": "3.example"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"domainName": "4.example"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"domainName": "5.example"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"domainName": "6.example"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"domainName": "7.example"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"domainName": "8.example"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"domainName": "9.example"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"domainName": "10.example"
|
||||
}
|
||||
],
|
||||
"currentCount": 10,
|
||||
"totalCount": 20,
|
||||
"totalPage": 2
|
||||
}
|
||||
}
|
||||
55
providers/dns/jdcloud/fixtures/describe_domains_page2.json
Normal file
55
providers/dns/jdcloud/fixtures/describe_domains_page2.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"requestId": "azerty",
|
||||
"error": {
|
||||
"code": 0,
|
||||
"status": "",
|
||||
"message": ""
|
||||
},
|
||||
"result": {
|
||||
"dataList": [
|
||||
{
|
||||
"id": 11,
|
||||
"domainName": "11.example"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"domainName": "12.example"
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"domainName": "13.example"
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"domainName": "14.example"
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"domainName": "15.example"
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"domainName": "16.example"
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"domainName": "17.example"
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"domainName": "18.example"
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"domainName": "19.example"
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"domainName": "example.com"
|
||||
}
|
||||
],
|
||||
"currentCount": 10,
|
||||
"totalCount": 20,
|
||||
"totalPage": 2
|
||||
}
|
||||
}
|
||||
217
providers/dns/jdcloud/jdcloud.go
Normal file
217
providers/dns/jdcloud/jdcloud.go
Normal file
@@ -0,0 +1,217 @@
|
||||
// Package jdcloud implements a DNS provider for solving the DNS-01 challenge using JD Cloud.
|
||||
package jdcloud
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/jdcloud-sdk-go/core"
|
||||
"github.com/go-acme/jdcloud-sdk-go/services/domainservice/apis"
|
||||
jdcclient "github.com/go-acme/jdcloud-sdk-go/services/domainservice/client"
|
||||
domainservice "github.com/go-acme/jdcloud-sdk-go/services/domainservice/models"
|
||||
"github.com/go-acme/lego/v4/challenge/dns01"
|
||||
"github.com/go-acme/lego/v4/platform/config/env"
|
||||
)
|
||||
|
||||
// Environment variables names.
|
||||
const (
|
||||
envNamespace = "JDCLOUD_"
|
||||
|
||||
EnvAccessKeyID = envNamespace + "ACCESS_KEY_ID"
|
||||
EnvAccessKeySecret = envNamespace + "ACCESS_KEY_SECRET"
|
||||
EnvRegionID = envNamespace + "REGION_ID"
|
||||
|
||||
EnvTTL = envNamespace + "TTL"
|
||||
EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
|
||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||
)
|
||||
|
||||
// Config is used to configure the creation of the DNSProvider.
|
||||
type Config struct {
|
||||
AccessKeyID string
|
||||
AccessKeySecret string
|
||||
RegionID string
|
||||
|
||||
PropagationTimeout time.Duration
|
||||
PollingInterval time.Duration
|
||||
TTL int
|
||||
HTTPTimeout time.Duration
|
||||
}
|
||||
|
||||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPTimeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
}
|
||||
}
|
||||
|
||||
// DNSProvider implements the challenge.Provider interface.
|
||||
type DNSProvider struct {
|
||||
config *Config
|
||||
client *jdcclient.DomainserviceClient
|
||||
|
||||
recordIDs map[string]int
|
||||
domainIDs map[string]int
|
||||
recordIDsMu sync.Mutex
|
||||
}
|
||||
|
||||
// NewDNSProvider returns a DNSProvider instance configured for JD Cloud.
|
||||
func NewDNSProvider() (*DNSProvider, error) {
|
||||
values, err := env.Get(EnvAccessKeyID, EnvAccessKeySecret)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("jdcloud: %w", err)
|
||||
}
|
||||
|
||||
config := NewDefaultConfig()
|
||||
config.AccessKeyID = values[EnvAccessKeyID]
|
||||
config.AccessKeySecret = values[EnvAccessKeySecret]
|
||||
|
||||
// https://docs.jdcloud.com/en/common-declaration/api/introduction#Region%20Code
|
||||
config.RegionID = env.GetOrDefaultString(EnvRegionID, "cn-north-1")
|
||||
|
||||
return NewDNSProviderConfig(config)
|
||||
}
|
||||
|
||||
// NewDNSProviderConfig return a DNSProvider instance configured for JD Cloud.
|
||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||
if config == nil {
|
||||
return nil, errors.New("jdcloud: the configuration of the DNS provider is nil")
|
||||
}
|
||||
|
||||
if config.AccessKeyID == "" || config.AccessKeySecret == "" {
|
||||
return nil, errors.New("jdcloud: missing credentials")
|
||||
}
|
||||
|
||||
cred := core.NewCredentials(config.AccessKeyID, config.AccessKeySecret)
|
||||
|
||||
client := jdcclient.NewDomainserviceClient(cred)
|
||||
client.DisableLogger()
|
||||
client.Config.SetTimeout(config.HTTPTimeout)
|
||||
|
||||
return &DNSProvider{
|
||||
config: config,
|
||||
client: client,
|
||||
recordIDs: make(map[string]int),
|
||||
domainIDs: make(map[string]int),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
info := dns01.GetChallengeInfo(domain, keyAuth)
|
||||
|
||||
authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jdcloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jdcloud: %w", err)
|
||||
}
|
||||
|
||||
zone, err := d.findZone(dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("jdcloud: %w", err)
|
||||
}
|
||||
|
||||
// https://docs.jdcloud.com/cn/jd-cloud-dns/api/createresourcerecord
|
||||
crrr := apis.NewCreateResourceRecordRequestWithAllParams(
|
||||
d.config.RegionID,
|
||||
strconv.Itoa(zone.Id),
|
||||
&domainservice.AddRR{
|
||||
HostRecord: subDomain,
|
||||
HostValue: info.Value,
|
||||
Ttl: d.config.TTL,
|
||||
Type: "TXT",
|
||||
ViewValue: -1,
|
||||
},
|
||||
)
|
||||
|
||||
record, err := jdcclient.CreateResourceRecord(d.client, crrr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jdcloud: create resource record: %w", err)
|
||||
}
|
||||
|
||||
d.recordIDsMu.Lock()
|
||||
d.domainIDs[token] = zone.Id
|
||||
d.recordIDs[token] = record.Result.DataList.Id
|
||||
d.recordIDsMu.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
info := dns01.GetChallengeInfo(domain, keyAuth)
|
||||
|
||||
d.recordIDsMu.Lock()
|
||||
recordID, recordOK := d.recordIDs[token]
|
||||
domainID, domainOK := d.domainIDs[token]
|
||||
d.recordIDsMu.Unlock()
|
||||
|
||||
if !recordOK {
|
||||
return fmt.Errorf("jdcloud: unknown record ID for '%s' '%s'", info.EffectiveFQDN, token)
|
||||
}
|
||||
|
||||
if !domainOK {
|
||||
return fmt.Errorf("jdcloud: unknown domain ID for '%s' '%s'", info.EffectiveFQDN, token)
|
||||
}
|
||||
|
||||
// https://docs.jdcloud.com/cn/jd-cloud-dns/api/deleteresourcerecord
|
||||
drrr := apis.NewDeleteResourceRecordRequestWithAllParams(
|
||||
d.config.RegionID,
|
||||
strconv.Itoa(domainID),
|
||||
strconv.Itoa(recordID),
|
||||
)
|
||||
|
||||
_, err := jdcclient.DeleteResourceRecord(d.client, drrr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jdcloud: delete resource record: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Timeout returns the timeout and interval to use when checking for DNS propagation.
|
||||
// Adjusting here to cope with spikes in propagation times.
|
||||
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||
}
|
||||
|
||||
func (d *DNSProvider) findZone(zone string) (*domainservice.DomainInfo, error) {
|
||||
// https://docs.jdcloud.com/cn/jd-cloud-dns/api/describedomains
|
||||
ddr := apis.NewDescribeDomainsRequestWithoutParam()
|
||||
ddr.SetRegionId(d.config.RegionID)
|
||||
ddr.SetPageNumber(1)
|
||||
ddr.SetPageSize(10)
|
||||
ddr.SetDomainName(zone)
|
||||
|
||||
for {
|
||||
response, err := jdcclient.DescribeDomains(d.client, ddr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("describe domains: %w", err)
|
||||
}
|
||||
|
||||
for _, d := range response.Result.DataList {
|
||||
if d.DomainName == zone {
|
||||
return &d, nil
|
||||
}
|
||||
}
|
||||
|
||||
if len(response.Result.DataList) < ddr.PageSize || response.Result.TotalPage <= ddr.PageNumber {
|
||||
break
|
||||
}
|
||||
|
||||
ddr.SetPageNumber(ddr.PageNumber + 1)
|
||||
}
|
||||
|
||||
return nil, errors.New("zone not found")
|
||||
}
|
||||
27
providers/dns/jdcloud/jdcloud.toml
Normal file
27
providers/dns/jdcloud/jdcloud.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
Name = "JD Cloud"
|
||||
Description = ''''''
|
||||
URL = "https://www.jdcloud.com/"
|
||||
Code = "jdcloud"
|
||||
Since = "v4.31.0"
|
||||
|
||||
Example = '''
|
||||
JDCLOUD_ACCESS_KEY_ID="xxx" \
|
||||
JDCLOUD_ACCESS_KEY_SECRET="yyy" \
|
||||
lego --dns jdcloud -d '*.example.com' -d example.com run
|
||||
'''
|
||||
|
||||
[Configuration]
|
||||
[Configuration.Credentials]
|
||||
JDCLOUD_ACCESS_KEY_ID = "Access key ID"
|
||||
JDCLOUD_ACCESS_KEY_SECRET = "Access key secret"
|
||||
[Configuration.Additional]
|
||||
JDCLOUD_REGION_ID = "Region ID (Default: cn-north-1)"
|
||||
JDCLOUD_POLLING_INTERVAL = "Time between DNS propagation check in seconds (Default: 2)"
|
||||
JDCLOUD_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation in seconds (Default: 60)"
|
||||
JDCLOUD_TTL = "The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)"
|
||||
JDCLOUD_HTTP_TIMEOUT = "API request timeout in seconds (Default: 30)"
|
||||
|
||||
[Links]
|
||||
API = "https://docs.jdcloud.com/cn/jd-cloud-dns/api/overview"
|
||||
Common = "https://docs.jdcloud.com/en/common-declaration/api/introduction"
|
||||
GoClient = "https://github.com/jdcloud-api/jdcloud-sdk-go"
|
||||
242
providers/dns/jdcloud/jdcloud_test.go
Normal file
242
providers/dns/jdcloud/jdcloud_test.go
Normal file
@@ -0,0 +1,242 @@
|
||||
package jdcloud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/go-acme/lego/v4/platform/tester"
|
||||
"github.com/go-acme/lego/v4/platform/tester/servermock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const envDomain = envNamespace + "DOMAIN"
|
||||
|
||||
var envTest = tester.NewEnvTest(
|
||||
EnvAccessKeyID,
|
||||
EnvAccessKeySecret,
|
||||
EnvRegionID,
|
||||
).WithDomain(envDomain)
|
||||
|
||||
func TestNewDNSProvider(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
envVars map[string]string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
envVars: map[string]string{
|
||||
EnvAccessKeyID: "abc123",
|
||||
EnvAccessKeySecret: "secret",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "missing access key ID",
|
||||
envVars: map[string]string{
|
||||
EnvAccessKeyID: "",
|
||||
EnvAccessKeySecret: "secret",
|
||||
},
|
||||
expected: "jdcloud: some credentials information are missing: JDCLOUD_ACCESS_KEY_ID",
|
||||
},
|
||||
{
|
||||
desc: "missing access key secret",
|
||||
envVars: map[string]string{
|
||||
EnvAccessKeyID: "abc123",
|
||||
EnvAccessKeySecret: "",
|
||||
},
|
||||
expected: "jdcloud: some credentials information are missing: JDCLOUD_ACCESS_KEY_SECRET",
|
||||
},
|
||||
{
|
||||
desc: "missing credentials",
|
||||
envVars: map[string]string{},
|
||||
expected: "jdcloud: some credentials information are missing: JDCLOUD_ACCESS_KEY_ID,JDCLOUD_ACCESS_KEY_SECRET",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
defer envTest.RestoreEnv()
|
||||
|
||||
envTest.ClearEnv()
|
||||
|
||||
envTest.Apply(test.envVars)
|
||||
|
||||
p, err := NewDNSProvider()
|
||||
|
||||
if test.expected == "" {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, p)
|
||||
require.NotNil(t, p.config)
|
||||
require.NotNil(t, p.client)
|
||||
} else {
|
||||
require.EqualError(t, err, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewDNSProviderConfig(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
accessKeyID string
|
||||
accessKeySecret string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
accessKeyID: "abc123",
|
||||
accessKeySecret: "secret",
|
||||
},
|
||||
{
|
||||
desc: "missing access key ID",
|
||||
accessKeySecret: "secret",
|
||||
expected: "jdcloud: missing credentials",
|
||||
},
|
||||
{
|
||||
desc: "missing access key secret",
|
||||
accessKeyID: "abc123",
|
||||
expected: "jdcloud: missing credentials",
|
||||
},
|
||||
{
|
||||
desc: "missing credentials",
|
||||
expected: "jdcloud: missing credentials",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
config := NewDefaultConfig()
|
||||
config.AccessKeyID = test.accessKeyID
|
||||
config.AccessKeySecret = test.accessKeySecret
|
||||
config.RegionID = "cn-north-1"
|
||||
|
||||
p, err := NewDNSProviderConfig(config)
|
||||
|
||||
if test.expected == "" {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, p)
|
||||
require.NotNil(t, p.config)
|
||||
require.NotNil(t, p.client)
|
||||
} else {
|
||||
require.EqualError(t, err, test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLivePresent(t *testing.T) {
|
||||
if !envTest.IsLiveTest() {
|
||||
t.Skip("skipping live test")
|
||||
}
|
||||
|
||||
envTest.RestoreEnv()
|
||||
|
||||
provider, err := NewDNSProvider()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = provider.Present(envTest.GetDomain(), "", "123d==")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestLiveCleanUp(t *testing.T) {
|
||||
if !envTest.IsLiveTest() {
|
||||
t.Skip("skipping live test")
|
||||
}
|
||||
|
||||
envTest.RestoreEnv()
|
||||
|
||||
provider, err := NewDNSProvider()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = provider.CleanUp(envTest.GetDomain(), "", "123d==")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func mockBuilder() *servermock.Builder[*DNSProvider] {
|
||||
return servermock.NewBuilder(
|
||||
func(server *httptest.Server) (*DNSProvider, error) {
|
||||
config := NewDefaultConfig()
|
||||
config.AccessKeyID = "abc123"
|
||||
config.AccessKeySecret = "secret"
|
||||
config.RegionID = "cn-north-1"
|
||||
|
||||
p, err := NewDNSProviderConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
serverURL, _ := url.Parse(server.URL)
|
||||
|
||||
p.client.Config.SetEndpoint(net.JoinHostPort(serverURL.Hostname(), serverURL.Port()))
|
||||
p.client.Config.SetScheme(serverURL.Scheme)
|
||||
p.client.Config.SetTimeout(server.Client().Timeout)
|
||||
|
||||
return p, nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestDNSProvider_Present(t *testing.T) {
|
||||
provider := mockBuilder().
|
||||
Route("GET /v2/regions/cn-north-1/domain",
|
||||
http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
pageNumber := req.URL.Query().Get("pageNumber")
|
||||
|
||||
servermock.ResponseFromFixture(
|
||||
fmt.Sprintf("describe_domains_page%s.json", pageNumber),
|
||||
).ServeHTTP(rw, req)
|
||||
}),
|
||||
servermock.CheckQueryParameter().Strict().
|
||||
With("domainName", "example.com").
|
||||
WithRegexp("pageNumber", `(1|2)`).
|
||||
With("pageSize", "10"),
|
||||
servermock.CheckHeader().
|
||||
WithRegexp("Authorization",
|
||||
`JDCLOUD2-HMAC-SHA256 Credential=abc123/\d{8}/cn-north-1/domainservice/jdcloud2_request, SignedHeaders=content-type;host;x-jdcloud-date;x-jdcloud-nonce, Signature=\w+`).
|
||||
WithRegexp("X-Jdcloud-Date", `\d{8}T\d{6}Z`).
|
||||
WithRegexp("X-Jdcloud-Nonce", `[\w-]+`),
|
||||
).
|
||||
Route("POST /v2/regions/cn-north-1/domain/20/ResourceRecord",
|
||||
servermock.ResponseFromFixture("create_record.json"),
|
||||
servermock.CheckRequestJSONBodyFromFixture("create_record-request.json"),
|
||||
servermock.CheckHeader().
|
||||
WithRegexp("Authorization",
|
||||
`JDCLOUD2-HMAC-SHA256 Credential=abc123/\d{8}/cn-north-1/domainservice/jdcloud2_request, SignedHeaders=content-type;host;x-jdcloud-date;x-jdcloud-nonce, Signature=\w+`).
|
||||
WithRegexp("X-Jdcloud-Date", `\d{8}T\d{6}Z`).
|
||||
WithRegexp("X-Jdcloud-Nonce", `[\w-]+`),
|
||||
).
|
||||
Build(t)
|
||||
|
||||
err := provider.Present("example.com", "abc", "123d==")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, provider.domainIDs, 1)
|
||||
require.Len(t, provider.recordIDs, 1)
|
||||
|
||||
assert.Equal(t, 20, provider.domainIDs["abc"])
|
||||
assert.Equal(t, 123, provider.recordIDs["abc"])
|
||||
}
|
||||
|
||||
func TestDNSProvider_CleanUp(t *testing.T) {
|
||||
provider := mockBuilder().
|
||||
Route("DELETE /v2/regions/cn-north-1/domain/20/ResourceRecord/123",
|
||||
servermock.ResponseFromFixture("delete_record.json"),
|
||||
servermock.CheckHeader().
|
||||
WithRegexp("Authorization",
|
||||
`JDCLOUD2-HMAC-SHA256 Credential=abc123/\d{8}/cn-north-1/domainservice/jdcloud2_request, SignedHeaders=content-type;host;x-jdcloud-date;x-jdcloud-nonce, Signature=\w+`).
|
||||
WithRegexp("X-Jdcloud-Date", `\d{8}T\d{6}Z`).
|
||||
WithRegexp("X-Jdcloud-Nonce", `[\w-]+`),
|
||||
).
|
||||
Build(t)
|
||||
|
||||
provider.domainIDs["abc"] = 20
|
||||
provider.recordIDs["abc"] = 123
|
||||
|
||||
err := provider.CleanUp("example.com", "abc", "123d==")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
3
providers/dns/zz_gen_dns_providers.go
generated
3
providers/dns/zz_gen_dns_providers.go
generated
@@ -99,6 +99,7 @@ import (
|
||||
"github.com/go-acme/lego/v4/providers/dns/ispconfig"
|
||||
"github.com/go-acme/lego/v4/providers/dns/ispconfigddns"
|
||||
"github.com/go-acme/lego/v4/providers/dns/iwantmyname"
|
||||
"github.com/go-acme/lego/v4/providers/dns/jdcloud"
|
||||
"github.com/go-acme/lego/v4/providers/dns/joker"
|
||||
"github.com/go-acme/lego/v4/providers/dns/keyhelp"
|
||||
"github.com/go-acme/lego/v4/providers/dns/liara"
|
||||
@@ -377,6 +378,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
|
||||
return ispconfigddns.NewDNSProvider()
|
||||
case "iwantmyname":
|
||||
return iwantmyname.NewDNSProvider()
|
||||
case "jdcloud":
|
||||
return jdcloud.NewDNSProvider()
|
||||
case "joker":
|
||||
return joker.NewDNSProvider()
|
||||
case "keyhelp":
|
||||
|
||||
Reference in New Issue
Block a user