Add DNS provider for Beget.com (#1879)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
cfif-31 2025-09-29 13:36:53 +04:00 committed by GitHub
commit 621d9d0d0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1133 additions and 39 deletions

View file

@ -70,193 +70,193 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/azuredns/">Azure DNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/baiducloud/">Baidu Cloud</a></td>
<td><a href="https://go-acme.github.io/lego/dns/beget/">Beget.com</a></td>
<td><a href="https://go-acme.github.io/lego/dns/binarylane/">Binary Lane</a></td>
<td><a href="https://go-acme.github.io/lego/dns/bindman/">Bindman</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/bindman/">Bindman</a></td>
<td><a href="https://go-acme.github.io/lego/dns/bluecat/">Bluecat</a></td>
<td><a href="https://go-acme.github.io/lego/dns/bookmyname/">BookMyName</a></td>
<td><a href="https://go-acme.github.io/lego/dns/brandit/">Brandit (deprecated)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/bunny/">Bunny</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/bunny/">Bunny</a></td>
<td><a href="https://go-acme.github.io/lego/dns/checkdomain/">Checkdomain</a></td>
<td><a href="https://go-acme.github.io/lego/dns/civo/">Civo</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cloudru/">Cloud.ru</a></td>
<td><a href="https://go-acme.github.io/lego/dns/clouddns/">CloudDNS</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/clouddns/">CloudDNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cloudflare/">Cloudflare</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cloudns/">ClouDNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cloudxns/">CloudXNS (Deprecated)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/conoha/">ConoHa v2</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/conoha/">ConoHa v2</a></td>
<td><a href="https://go-acme.github.io/lego/dns/conohav3/">ConoHa v3</a></td>
<td><a href="https://go-acme.github.io/lego/dns/constellix/">Constellix</a></td>
<td><a href="https://go-acme.github.io/lego/dns/corenetworks/">Core-Networks</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cpanel/">CPanel/WHM</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/cpanel/">CPanel/WHM</a></td>
<td><a href="https://go-acme.github.io/lego/dns/derak/">Derak Cloud</a></td>
<td><a href="https://go-acme.github.io/lego/dns/desec/">deSEC.io</a></td>
<td><a href="https://go-acme.github.io/lego/dns/designate/">Designate DNSaaS for Openstack</a></td>
<td><a href="https://go-acme.github.io/lego/dns/digitalocean/">Digital Ocean</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/digitalocean/">Digital Ocean</a></td>
<td><a href="https://go-acme.github.io/lego/dns/directadmin/">DirectAdmin</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dnsmadeeasy/">DNS Made Easy</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dnshomede/">dnsHome.de</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dnsimple/">DNSimple</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/dnsimple/">DNSimple</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dnspod/">DNSPod (deprecated)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dode/">Domain Offensive (do.de)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/domeneshop/">Domeneshop</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dreamhost/">DreamHost</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/dreamhost/">DreamHost</a></td>
<td><a href="https://go-acme.github.io/lego/dns/duckdns/">Duck DNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dyn/">Dyn</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dyndnsfree/">DynDnsFree.de</a></td>
<td><a href="https://go-acme.github.io/lego/dns/dynu/">Dynu</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/dynu/">Dynu</a></td>
<td><a href="https://go-acme.github.io/lego/dns/easydns/">EasyDNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/efficientip/">Efficient IP</a></td>
<td><a href="https://go-acme.github.io/lego/dns/epik/">Epik</a></td>
<td><a href="https://go-acme.github.io/lego/dns/exoscale/">Exoscale</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/exoscale/">Exoscale</a></td>
<td><a href="https://go-acme.github.io/lego/dns/exec/">External program</a></td>
<td><a href="https://go-acme.github.io/lego/dns/f5xc/">F5 XC</a></td>
<td><a href="https://go-acme.github.io/lego/dns/freemyip/">freemyip.com</a></td>
<td><a href="https://go-acme.github.io/lego/dns/gcore/">G-Core</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/gcore/">G-Core</a></td>
<td><a href="https://go-acme.github.io/lego/dns/gandi/">Gandi</a></td>
<td><a href="https://go-acme.github.io/lego/dns/gandiv5/">Gandi Live DNS (v5)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/glesys/">Glesys</a></td>
<td><a href="https://go-acme.github.io/lego/dns/godaddy/">Go Daddy</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/godaddy/">Go Daddy</a></td>
<td><a href="https://go-acme.github.io/lego/dns/gcloud/">Google Cloud</a></td>
<td><a href="https://go-acme.github.io/lego/dns/googledomains/">Google Domains</a></td>
<td><a href="https://go-acme.github.io/lego/dns/hetzner/">Hetzner</a></td>
<td><a href="https://go-acme.github.io/lego/dns/hostingde/">Hosting.de</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/hostingde/">Hosting.de</a></td>
<td><a href="https://go-acme.github.io/lego/dns/hostinger/">Hostinger</a></td>
<td><a href="https://go-acme.github.io/lego/dns/hosttech/">Hosttech</a></td>
<td><a href="https://go-acme.github.io/lego/dns/httpreq/">HTTP request</a></td>
<td><a href="https://go-acme.github.io/lego/dns/httpnet/">http.net</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/httpnet/">http.net</a></td>
<td><a href="https://go-acme.github.io/lego/dns/huaweicloud/">Huawei Cloud</a></td>
<td><a href="https://go-acme.github.io/lego/dns/hurricane/">Hurricane Electric DNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/hyperone/">HyperOne</a></td>
<td><a href="https://go-acme.github.io/lego/dns/ibmcloud/">IBM Cloud (SoftLayer)</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/ibmcloud/">IBM Cloud (SoftLayer)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/iijdpf/">IIJ DNS Platform Service</a></td>
<td><a href="https://go-acme.github.io/lego/dns/infoblox/">Infoblox</a></td>
<td><a href="https://go-acme.github.io/lego/dns/infomaniak/">Infomaniak</a></td>
<td><a href="https://go-acme.github.io/lego/dns/iij/">Internet Initiative Japan</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/iij/">Internet Initiative Japan</a></td>
<td><a href="https://go-acme.github.io/lego/dns/internetbs/">Internet.bs</a></td>
<td><a href="https://go-acme.github.io/lego/dns/inwx/">INWX</a></td>
<td><a href="https://go-acme.github.io/lego/dns/ionos/">Ionos</a></td>
<td><a href="https://go-acme.github.io/lego/dns/ipv64/">IPv64</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/ipv64/">IPv64</a></td>
<td><a href="https://go-acme.github.io/lego/dns/iwantmyname/">iwantmyname</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&#39;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/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>
<td><a href="https://go-acme.github.io/lego/dns/nifcloud/">NIFCloud</a></td>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/otc/">Open Telekom Cloud</a></td>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/stackpath/">Stackpath</a></td>
<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>
</tr><tr>
<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>
<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/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/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>
<td><a href="https://go-acme.github.io/lego/dns/vultr/">Vultr</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/vultr/">Vultr</a></td>
<td><a href="https://go-acme.github.io/lego/dns/webnames/">Webnames</a></td>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/zonomi/">Zonomi</a></td>
<td></td>
<td></td>
</tr></table>
<!-- END DNS PROVIDERS LIST -->

View file

@ -25,6 +25,7 @@ func allDNSCodes() string {
"azure",
"azuredns",
"baiducloud",
"beget",
"binarylane",
"bindman",
"bluecat",
@ -451,6 +452,27 @@ func displayDNSHelp(w io.Writer, name string) error {
ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/baiducloud`)
case "beget":
// generated from: providers/dns/beget/beget.toml
ew.writeln(`Configuration for Beget.com.`)
ew.writeln(`Code: 'beget'`)
ew.writeln(`Since: 'v4.27.0'`)
ew.writeln()
ew.writeln(`Credentials:`)
ew.writeln(` - "BEGET_PASSWORD": API password`)
ew.writeln(` - "BEGET_USERNAME": API username`)
ew.writeln()
ew.writeln(`Additional Configuration:`)
ew.writeln(` - "BEGET_HTTP_TIMEOUT": API request timeout in seconds (Default: 30)`)
ew.writeln(` - "BEGET_POLLING_INTERVAL": Time between DNS propagation check in seconds (Default: 30)`)
ew.writeln(` - "BEGET_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation in seconds (Default: 300)`)
ew.writeln(` - "BEGET_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/beget`)
case "binarylane":
// generated from: providers/dns/binarylane/binarylane.toml
ew.writeln(`Configuration for Binary Lane.`)

69
docs/content/dns/zz_gen_beget.md generated Normal file
View file

@ -0,0 +1,69 @@
---
title: "Beget.com"
date: 2019-03-03T16:39:46+01:00
draft: false
slug: beget
dnsprovider:
since: "v4.27.0"
code: "beget"
url: "https://beget.com/"
---
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/beget/beget.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
Configuration for [Beget.com](https://beget.com/).
<!--more-->
- Code: `beget`
- Since: v4.27.0
Here is an example bash command using the Beget.com provider:
```bash
BEGET_USERNAME=xxxxxx \
BEGET_PASSWORD=yyyyyy \
lego --email you@example.com --dns beget -d '*.example.com' -d example.com run
```
## Credentials
| Environment Variable Name | Description |
|-----------------------|-------------|
| `BEGET_PASSWORD` | API password |
| `BEGET_USERNAME` | API username |
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 |
|--------------------------------|-------------|
| `BEGET_HTTP_TIMEOUT` | API request timeout in seconds (Default: 30) |
| `BEGET_POLLING_INTERVAL` | Time between DNS propagation check in seconds (Default: 30) |
| `BEGET_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation in seconds (Default: 300) |
| `BEGET_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://beget.com/ru/kb/api/funkczii-upravleniya-dns)
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/beget/beget.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->

View file

@ -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, allinkl, arvancloud, auroradns, autodns, axelname, azion, azure, azuredns, baiducloud, binarylane, bindman, bluecat, bookmyname, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, conohav3, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dyndnsfree, dynu, easydns, edgedns, edgeone, efficientip, epik, exec, exoscale, f5xc, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hostinger, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, keyhelp, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manageengine, manual, metaname, metaregistrar, mijnhost, mittwald, myaddr, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nicru, nifcloud, njalla, nodion, ns1, 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, technitium, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneedit, zoneee, zonomi
acme-dns, active24, alidns, allinkl, arvancloud, auroradns, autodns, axelname, azion, azure, azuredns, baiducloud, beget, binarylane, bindman, bluecat, bookmyname, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, conohav3, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dyndnsfree, dynu, easydns, edgedns, edgeone, efficientip, epik, exec, exoscale, f5xc, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hostinger, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, keyhelp, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manageengine, manual, metaname, metaregistrar, mijnhost, mittwald, myaddr, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nicru, nifcloud, njalla, nodion, ns1, 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, technitium, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneedit, zoneee, zonomi
More information: https://go-acme.github.io/lego/dns
"""

View file

@ -0,0 +1,156 @@
// Package beget implements a DNS provider for solving the DNS-01 challenge using beget.com DNS.
package beget
import (
"context"
"errors"
"fmt"
"net/http"
"time"
"github.com/go-acme/lego/v4/challenge"
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/go-acme/lego/v4/platform/config/env"
"github.com/go-acme/lego/v4/providers/dns/beget/internal"
)
// Environment variables names.
const (
envNamespace = "BEGET_"
EnvUsername = envNamespace + "USERNAME"
EnvPassword = envNamespace + "PASSWORD"
EnvTTL = envNamespace + "TTL"
EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
)
var _ challenge.ProviderTimeout = (*DNSProvider)(nil)
// Config is used to configure the creation of the DNSProvider.
type Config struct {
Username string
Password string
PropagationTimeout time.Duration
PollingInterval time.Duration
TTL int
HTTPClient *http.Client
}
// NewDefaultConfig returns a default configuration for the DNSProvider.
func NewDefaultConfig() *Config {
return &Config{
TTL: env.GetOrDefaultInt(EnvTTL, 300),
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 5*time.Minute),
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 30*time.Second),
HTTPClient: &http.Client{
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
},
}
}
// DNSProvider implements the challenge.Provider interface.
type DNSProvider struct {
config *Config
client *internal.Client
}
// NewDNSProvider returns a DNSProvider instance configured for beget.com.
// Credentials must be passed in the environment variables:
// BEGET_USERNAME and BEGET_PASSWORD.
func NewDNSProvider() (*DNSProvider, error) {
values, err := env.Get(EnvUsername, EnvPassword)
if err != nil {
return nil, fmt.Errorf("beget: %w", err)
}
config := NewDefaultConfig()
config.Username = values[EnvUsername]
config.Password = values[EnvPassword]
return NewDNSProviderConfig(config)
}
// NewDNSProviderConfig return a DNSProvider instance configured for beget.com.
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("beget: the configuration of the DNS provider is nil")
}
if config.Username == "" || config.Password == "" {
return nil, errors.New("beget: incomplete credentials, missing username and/or password")
}
client := internal.NewClient(config.Username, config.Password)
if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}
return &DNSProvider{config: config, client: client}, 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
}
// Present creates a TXT record using the specified parameters.
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
info := dns01.GetChallengeInfo(domain, keyAuth)
records, err := d.client.GetTXTRecords(context.Background(), dns01.UnFqdn(info.EffectiveFQDN))
if err != nil {
return fmt.Errorf("beget: get TXT records: %w", err)
}
records = append(records, internal.Record{
Value: info.Value,
Data: "", // NOTE: there are 2 fields in the API for the same thing.
Priority: 10,
TTL: d.config.TTL,
})
err = d.client.ChangeTXTRecord(context.Background(), dns01.UnFqdn(info.EffectiveFQDN), records)
if err != nil {
return fmt.Errorf("beget: failed to create TXT records [domain: %s]: %w",
dns01.UnFqdn(info.EffectiveFQDN), err)
}
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)
records, err := d.client.GetTXTRecords(context.Background(), dns01.UnFqdn(info.EffectiveFQDN))
if err != nil {
return fmt.Errorf("beget: get TXT records: %w", err)
}
if len(records) == 0 {
return nil
}
var updatedRecords []internal.Record
for _, record := range records {
if record.Data == info.Value {
continue
}
updatedRecords = append(updatedRecords, record)
}
err = d.client.ChangeTXTRecord(context.Background(), dns01.UnFqdn(info.EffectiveFQDN), updatedRecords)
if err != nil {
return fmt.Errorf("beget: failed to remove TXT records [domain: %s]: %w",
dns01.UnFqdn(info.EffectiveFQDN), err)
}
return nil
}

View file

@ -0,0 +1,24 @@
Name = "Beget.com"
Description = ''''''
URL = "https://beget.com/"
Code = "beget"
Since = "v4.27.0"
Example = '''
BEGET_USERNAME=xxxxxx \
BEGET_PASSWORD=yyyyyy \
lego --email you@example.com --dns beget -d '*.example.com' -d example.com run
'''
[Configuration]
[Configuration.Credentials]
BEGET_USERNAME = "API username"
BEGET_PASSWORD = "API password"
[Configuration.Additional]
BEGET_POLLING_INTERVAL = "Time between DNS propagation check in seconds (Default: 30)"
BEGET_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation in seconds (Default: 300)"
BEGET_TTL = "The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)"
BEGET_HTTP_TIMEOUT = "API request timeout in seconds (Default: 30)"
[Links]
API = "https://beget.com/ru/kb/api/funkczii-upravleniya-dns"

View file

@ -0,0 +1,229 @@
package beget
import (
"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(EnvUsername, EnvPassword).WithDomain(envDomain)
func TestNewDNSProvider(t *testing.T) {
testCases := []struct {
desc string
envVars map[string]string
expected string
}{
{
desc: "success",
envVars: map[string]string{
EnvUsername: "123",
EnvPassword: "456",
},
},
{
desc: "missing credentials",
envVars: map[string]string{
EnvUsername: "",
EnvPassword: "",
},
expected: "beget: some credentials information are missing: BEGET_USERNAME,BEGET_PASSWORD",
},
{
desc: "missing username",
envVars: map[string]string{
EnvUsername: "",
EnvPassword: "456",
},
expected: "beget: some credentials information are missing: BEGET_USERNAME",
},
{
desc: "missing password",
envVars: map[string]string{
EnvUsername: "123",
EnvPassword: "",
},
expected: "beget: some credentials information are missing: BEGET_PASSWORD",
},
}
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)
} else {
require.EqualError(t, err, test.expected)
}
})
}
}
func TestNewDNSProviderConfig(t *testing.T) {
testCases := []struct {
desc string
username string
password string
expected string
}{
{
desc: "success",
username: "123",
password: "456",
},
{
desc: "missing credentials",
username: "",
password: "",
expected: "beget: incomplete credentials, missing username and/or password",
},
{
desc: "missing username",
username: "",
password: "456",
expected: "beget: incomplete credentials, missing username and/or password",
},
{
desc: "missing password",
username: "123",
password: "",
expected: "beget: incomplete credentials, missing username and/or password",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
config := NewDefaultConfig()
config.Username = test.username
config.Password = test.password
p, err := NewDNSProviderConfig(config)
if test.expected == "" {
require.NoError(t, err)
require.NotNil(t, p)
require.NotNil(t, p.config)
} 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()
assert.NoError(t, err)
err = provider.Present(envTest.GetDomain(), "", "123d==")
assert.NoError(t, err)
}
func TestLiveCleanUp(t *testing.T) {
if !envTest.IsLiveTest() {
t.Skip("skipping live test")
}
envTest.RestoreEnv()
provider, err := NewDNSProvider()
assert.NoError(t, err)
err = provider.CleanUp(envTest.GetDomain(), "", "123d==")
assert.NoError(t, err)
}
func mockBuilder() *servermock.Builder[*DNSProvider] {
return servermock.NewBuilder(
func(server *httptest.Server) (*DNSProvider, error) {
config := NewDefaultConfig()
config.Username = "user"
config.Password = "secret"
p, err := NewDNSProviderConfig(config)
if err != nil {
return nil, err
}
p.client.HTTPClient = server.Client()
p.client.BaseURL, _ = url.Parse(server.URL)
return p, nil
},
servermock.CheckQueryParameter().
With("login", "user").
With("passwd", "secret").
With("input_format", "json").
With("output_format", "json"),
)
}
func TestDNSProvider_Present(t *testing.T) {
provider := mockBuilder().
Route("GET /dns/getData",
servermock.ResponseFromInternal("getData-real.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"_acme-challenge.example.com"}`),
).
Route("GET /dns/changeRecords",
servermock.ResponseFromInternal("changeRecords-doc.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"_acme-challenge.example.com","records":{"TXT":[{"txtdata":"v=spf1 redirect=beget.com","ttl":300},{"value":"ADw2sEd82DUgXcQ9hNBZThJs7zVJkR5v9JeSbAb9mZY","priority":10,"ttl":300}]}}`),
).
Build(t)
err := provider.Present("example.com", "", "123d==")
require.NoError(t, err)
}
func TestDNSProvider_CleanUp(t *testing.T) {
provider := mockBuilder().
Route("GET /dns/getData",
servermock.ResponseFromInternal("getData.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"_acme-challenge.example.com"}`),
).
Route("GET /dns/changeRecords",
servermock.ResponseFromInternal("changeRecords-doc.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"_acme-challenge.example.com","records":{"TXT":[{"txtdata":"foo","ttl":300}]}}`),
).
Build(t)
err := provider.CleanUp("example.com", "", "123d==")
require.NoError(t, err)
}
func TestDNSProvider_CleanUp_empty(t *testing.T) {
provider := mockBuilder().
Route("GET /dns/getData",
servermock.ResponseFromInternal("getData_empty.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"_acme-challenge.example.com"}`),
).
Route("/",
servermock.Noop().WithStatusCode(http.StatusInternalServerError)).
Build(t)
err := provider.CleanUp("example.com", "", "123d==")
require.NoError(t, err)
}

View file

@ -0,0 +1,135 @@
package internal
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"time"
"github.com/go-acme/lego/v4/providers/dns/internal/errutils"
)
const defaultBaseURL = "https://api.beget.com/api/"
// Client the beget.com client.
type Client struct {
login string
password string
BaseURL *url.URL
HTTPClient *http.Client
}
// NewClient Creates a beget.com client.
func NewClient(login, password string) *Client {
baseURL, _ := url.Parse(defaultBaseURL)
return &Client{
login: login,
password: password,
BaseURL: baseURL,
HTTPClient: &http.Client{Timeout: 5 * time.Second},
}
}
// GetTXTRecords returns TXT records.
// https://beget.com/ru/kb/api/funkczii-upravleniya-dns#getdata
func (c *Client) GetTXTRecords(ctx context.Context, domain string) ([]Record, error) {
request := GetRecordsRequest{Fqdn: domain}
resp, err := c.doRequest(ctx, request, "dns", "getData")
if err != nil {
return nil, err
}
err = resp.HasError()
if err != nil {
return nil, err
}
result := GetRecordsResult{}
err = json.Unmarshal(resp.Answer.Result, &result)
if err != nil {
return nil, fmt.Errorf("unmarshal result: %s: %w", string(resp.Answer.Result), err)
}
return result.Records.TXT, nil
}
// ChangeTXTRecord changes TXT records.
// https://beget.com/ru/kb/api/funkczii-upravleniya-dns#changerecords
func (c *Client) ChangeTXTRecord(ctx context.Context, domain string, records []Record) error {
request := ChangeRecordsRequest{
Fqdn: domain,
Records: RecordList{TXT: records},
}
resp, err := c.doRequest(ctx, request, "dns", "changeRecords")
if err != nil {
return err
}
return resp.HasError()
}
func (c *Client) doRequest(ctx context.Context, data any, fragments ...string) (*APIResponse, error) {
endpoint := c.BaseURL.JoinPath(fragments...)
inputData, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("failed to mashall input data: %w", err)
}
query := endpoint.Query()
query.Add("input_data", string(inputData))
query.Add("login", c.login)
query.Add("passwd", c.password)
query.Add("input_format", "json")
query.Add("output_format", "json")
endpoint.RawQuery = query.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), http.NoBody)
if err != nil {
return nil, fmt.Errorf("unable to create request: %w", err)
}
resp, err := c.HTTPClient.Do(req)
if err != nil {
return nil, errutils.NewHTTPDoError(req, err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode/100 != 2 {
return nil, parseError(req, resp)
}
raw, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errutils.NewReadResponseError(req, resp.StatusCode, err)
}
var apiResp APIResponse
err = json.Unmarshal(raw, &apiResp)
if err != nil {
return nil, errutils.NewUnmarshalError(req, resp.StatusCode, raw, err)
}
return &apiResp, nil
}
func parseError(req *http.Request, resp *http.Response) error {
raw, _ := io.ReadAll(resp.Body)
var apiResp APIResponse
err := json.Unmarshal(raw, &apiResp)
if err != nil {
return errutils.NewUnexpectedStatusCodeError(req, resp.StatusCode, raw)
}
return fmt.Errorf("[status code %d] %w", resp.StatusCode, apiResp)
}

View file

@ -0,0 +1,103 @@
package internal
import (
"context"
"net/http/httptest"
"net/url"
"testing"
"github.com/go-acme/lego/v4/platform/tester/servermock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func mockBuilder() *servermock.Builder[*Client] {
return servermock.NewBuilder[*Client](
func(server *httptest.Server) (*Client, error) {
client := NewClient("user", "secret")
client.HTTPClient = server.Client()
client.BaseURL, _ = url.Parse(server.URL)
return client, nil
},
servermock.CheckQueryParameter().
With("login", "user").
With("passwd", "secret").
With("input_format", "json").
With("output_format", "json"),
)
}
func TestClient_GetTXTRecords(t *testing.T) {
client := mockBuilder().
Route("GET /dns/getData",
servermock.ResponseFromFixture("getData-real.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"example.com"}`),
).
Build(t)
data, err := client.GetTXTRecords(context.Background(), "example.com")
require.NoError(t, err)
expected := []Record{{Data: "v=spf1 redirect=beget.com", TTL: 300}}
assert.Equal(t, expected, data)
}
func TestClient_ChangeTXTRecord(t *testing.T) {
client := mockBuilder().
Route("GET /dns/changeRecords",
servermock.ResponseFromFixture("changeRecords-doc.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"sub.example.com","records":{"TXT":[{"value":"txtTXTtxt","priority":10,"ttl":300}]}}`),
).
Build(t)
records := []Record{{Value: "txtTXTtxt", TTL: 300, Priority: 10}}
err := client.ChangeTXTRecord(context.Background(), "sub.example.com", records)
require.NoError(t, err)
}
func TestClient_ChangeTXTRecord_error(t *testing.T) {
client := mockBuilder().
Route("GET /dns/changeRecords",
servermock.ResponseFromFixture("error.json")).
Build(t)
records := []Record{{Data: "txtTXTtxt", TTL: 300}}
err := client.ChangeTXTRecord(context.Background(), "sub.example.com", records)
require.Error(t, err)
require.EqualError(t, err, "API error: NO_SUCH_METHOD: No such method")
}
func TestClient_ChangeTXTRecord_answer_error(t *testing.T) {
client := mockBuilder().
Route("GET /dns/changeRecords",
servermock.ResponseFromFixture("answer_error.json")).
Build(t)
records := []Record{{Data: "txtTXTtxt", TTL: 300}}
err := client.ChangeTXTRecord(context.Background(), "sub.example.com", records)
require.Error(t, err)
require.EqualError(t, err, "API answer error: INVALID_DATA: Login length cannot be greater than 12 characters")
}
func TestClient_ChangeTXTRecord_remove(t *testing.T) {
client := mockBuilder().
Route("GET /dns/changeRecords",
servermock.ResponseFromFixture("changeRecords-doc.json"),
servermock.CheckQueryParameter().
With("input_data", `{"fqdn":"sub.example.com","records":{}}`),
).
Build(t)
err := client.ChangeTXTRecord(context.Background(), "sub.example.com", nil)
require.NoError(t, err)
}

View file

@ -0,0 +1,12 @@
{
"status": "success",
"answer": {
"status": "error",
"errors": [
{
"error_code": "INVALID_DATA",
"error_text": "Login length cannot be greater than 12 characters"
}
]
}
}

View file

@ -0,0 +1,31 @@
{
"status": "success",
"answer": {
"status": "success",
"result": {
"A": [
{
"priority": 10,
"value": "127.0.0.1"
}
],
"MX": [
{
"priority": 10,
"value": "mx1.beget.ru"
},
{
"priority": 20,
"value": "mx2.beget.ru"
}
],
"TXT": [
{
"priority": 10,
"value": "TXT record"
}
]
}
}
}

View file

@ -0,0 +1,5 @@
{
"status": "error",
"error_text": "No such method",
"error_code": "NO_SUCH_METHOD"
}

View file

@ -0,0 +1,58 @@
{
"status": "success",
"answer": {
"status": "success",
"result": {
"is_under_control": 1,
"is_beget_dns": 1,
"is_subdomain": 0,
"fqdn": "beget.ru",
"records": {
"DNS": [
{
"value": "ns1.beget.ru",
"priority": 10
},
{
"value": "ns2.beget.ru",
"priority": 20
}
],
"DNS_IP": [
{
"value": null,
"priority": 10
},
{
"value": null,
"priority": 20
}
],
"A": [
{
"value": "91.106.201.65",
"priority": "0"
}
],
"MX": [
{
"value": "mx1.beget.ru",
"priority": "10"
},
{
"value": "mx2.beget.ru",
"priority": "20"
}
],
"TXT": [
{
"value": "",
"priority": 0
}
]
},
"set_type": 1
}
}
}

View file

@ -0,0 +1,67 @@
{
"status": "success",
"answer": {
"status": "success",
"result": {
"is_under_control": true,
"is_beget_dns": true,
"is_subdomain": false,
"fqdn": "example.com",
"records": {
"MX": [
{
"ttl": 300,
"exchange": "mx2.beget.com.",
"preference": 20
},
{
"ttl": 300,
"exchange": "mx1.beget.com.",
"preference": 10
}
],
"TXT": [
{
"ttl": 300,
"txtdata": "v=spf1 redirect=beget.com"
}
],
"A": [
{
"ttl": 300,
"address": "1.2.3.4"
}
],
"DNS": [
{
"value": "ns1.beget.pro"
},
{
"value": "ns2.beget.pro"
},
{
"value": "ns1.beget.com"
},
{
"value": "ns2.beget.com"
}
],
"DNS_IP": [
{
"value": ""
},
{
"value": ""
},
{
"value": ""
},
{
"value": ""
}
]
},
"set_type": 1
}
}
}

View file

@ -0,0 +1,67 @@
{
"status": "success",
"answer": {
"status": "success",
"result": {
"is_under_control": true,
"is_beget_dns": true,
"is_subdomain": false,
"fqdn": "_acme-challenge.example.com",
"records": {
"MX": [
{
"ttl": 300,
"exchange": "mx2.beget.com.",
"preference": 20
},
{
"ttl": 300,
"exchange": "mx1.beget.com.",
"preference": 10
}
],
"TXT": [
{
"ttl": 300,
"txtdata": "foo"
}
],
"A": [
{
"ttl": 300,
"address": "1.2.3.4"
}
],
"DNS": [
{
"value": "ns1.beget.pro"
},
{
"value": "ns2.beget.pro"
},
{
"value": "ns1.beget.com"
},
{
"value": "ns2.beget.com"
}
],
"DNS_IP": [
{
"value": ""
},
{
"value": ""
},
{
"value": ""
},
{
"value": ""
}
]
},
"set_type": 1
}
}
}

View file

@ -0,0 +1,13 @@
{
"status": "success",
"answer": {
"status": "success",
"result": {
"is_under_control": true,
"is_beget_dns": true,
"is_subdomain": false,
"fqdn": "_acme-challenge.example.com",
"set_type": 1
}
}
}

View file

@ -0,0 +1,100 @@
package internal
import (
"encoding/json"
"fmt"
"strings"
)
const successResult = "success"
// APIResponse is the representation of an API response.
type APIResponse struct {
Status string `json:"status"`
Answer *Answer `json:"answer,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
ErrorText string `json:"error_text,omitempty"`
}
func (a APIResponse) Error() string {
return fmt.Sprintf("API %s: %s: %s", a.Status, a.ErrorCode, a.ErrorText)
}
// HasError returns an error is the response contains an error.
func (a APIResponse) HasError() error {
if a.Status != successResult {
return a
}
if a.Answer == nil || a.Status != successResult || a.Answer.Status != successResult {
return a.Answer
}
return nil
}
// Answer is the representation of an API response answer.
type Answer struct {
Status string `json:"status,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Errors []AnswerError `json:"errors,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
ErrorText string `json:"error_text,omitempty"`
}
type AnswerError struct {
ErrorCode string `json:"error_code,omitempty"`
ErrorText string `json:"error_text,omitempty"`
}
func (a Answer) Error() string {
parts := []string{fmt.Sprintf("API answer %s", a.Status)}
if a.ErrorCode != "" {
parts = append(parts, a.ErrorCode)
}
if a.ErrorText != "" {
parts = append(parts, a.ErrorText)
}
if len(a.Errors) > 0 {
for _, e := range a.Errors {
parts = append(parts, e.ErrorCode, e.ErrorText)
}
}
return strings.Join(parts, ": ")
}
// GetRecordsRequest data representation for data get request.
type GetRecordsRequest struct {
Fqdn string `json:"fqdn,omitempty"`
}
// ChangeRecordsRequest data representation for data change request.
type ChangeRecordsRequest struct {
Fqdn string `json:"fqdn,omitempty"`
Records RecordList `json:"records,omitempty"`
}
// RecordList List of entries (in this case only described TXT).
type RecordList struct {
TXT []Record `json:"TXT,omitempty"`
}
// Record data representation for TXT record.
type Record struct {
Value string `json:"value,omitempty"`
Data string `json:"txtdata,omitempty"`
Priority int `json:"priority,omitempty"`
TTL int `json:"ttl,omitempty"`
}
type GetRecordsResult struct {
Fqdn string `json:"fqdn"`
Records RecordList `json:"records"`
}

View file

@ -19,6 +19,7 @@ import (
"github.com/go-acme/lego/v4/providers/dns/azure"
"github.com/go-acme/lego/v4/providers/dns/azuredns"
"github.com/go-acme/lego/v4/providers/dns/baiducloud"
"github.com/go-acme/lego/v4/providers/dns/beget"
"github.com/go-acme/lego/v4/providers/dns/binarylane"
"github.com/go-acme/lego/v4/providers/dns/bindman"
"github.com/go-acme/lego/v4/providers/dns/bluecat"
@ -199,6 +200,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
return azuredns.NewDNSProvider()
case "baiducloud":
return baiducloud.NewDNSProvider()
case "beget":
return beget.NewDNSProvider()
case "binarylane":
return binarylane.NewDNSProvider()
case "bindman":