1
0
mirror of https://github.com/go-acme/lego.git synced 2025-12-23 15:01:44 +02:00

Add DNS Provider for ISPConfig (DDNS Module) (#2760)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
Simon Merschjohann
2025-12-22 03:50:29 +01:00
committed by GitHub
parent 96168f78de
commit 8b327005b3
13 changed files with 702 additions and 30 deletions

View File

@@ -169,120 +169,120 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
<td><a href="https://go-acme.github.io/lego/dns/ionoscloud/">Ionos Cloud</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/ispconfig/">ISPConfig</a></td>
<td><a href="https://go-acme.github.io/lego/dns/ispconfig/">ISPConfig 3</a></td>
<td><a href="https://go-acme.github.io/lego/dns/ispconfigddns/">ISPConfig 3 - Dynamic DNS (DDNS) Module</a></td>
<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/joker/">Joker</a></td>
<td><a href="https://go-acme.github.io/lego/dns/acme-dns/">Joohoi&#39;s ACME-DNS</a></td>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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/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>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/pdns/">PowerDNS</a></td>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/regru/">reg.ru</a></td>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/nicru/">RU CENTER</a></td>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/selectelv2/">Selectel v2</a></td>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/simply/">Simply.com</a></td>
</tr><tr>
<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>
<td><a href="https://go-acme.github.io/lego/dns/syse/">Syse</a></td>
</tr><tr>
<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>
<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/uniteddomains/">United-Domains</a></td>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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>
</tr><tr>
<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>
<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/zoneedit/">ZoneEdit</a></td>
<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 -->

View File

@@ -101,6 +101,7 @@ func allDNSCodes() string {
"ionoscloud",
"ipv64",
"ispconfig",
"ispconfigddns",
"iwantmyname",
"joker",
"keyhelp",
@@ -2086,7 +2087,7 @@ func displayDNSHelp(w io.Writer, name string) error {
case "ispconfig":
// generated from: providers/dns/ispconfig/ispconfig.toml
ew.writeln(`Configuration for ISPConfig.`)
ew.writeln(`Configuration for ISPConfig 3.`)
ew.writeln(`Code: 'ispconfig'`)
ew.writeln(`Since: 'v4.31.0'`)
ew.writeln()
@@ -2107,6 +2108,27 @@ func displayDNSHelp(w io.Writer, name string) error {
ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/ispconfig`)
case "ispconfigddns":
// generated from: providers/dns/ispconfigddns/ispconfigddns.toml
ew.writeln(`Configuration for ISPConfig 3 - Dynamic DNS (DDNS) Module.`)
ew.writeln(`Code: 'ispconfigddns'`)
ew.writeln(`Since: 'v4.31.0'`)
ew.writeln()
ew.writeln(`Credentials:`)
ew.writeln(` - "ISPCONFIG_DDNS_SERVER_URL": API server URL (ex: https://panel.example.com:8080)`)
ew.writeln(` - "ISPCONFIG_DDNS_TOKEN": DDNS API token`)
ew.writeln()
ew.writeln(`Additional Configuration:`)
ew.writeln(` - "ISPCONFIG_DDNS_HTTP_TIMEOUT": API request timeout in seconds (Default: 30)`)
ew.writeln(` - "ISPCONFIG_DDNS_POLLING_INTERVAL": Time between DNS propagation check in seconds (Default: 2)`)
ew.writeln(` - "ISPCONFIG_DDNS_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation in seconds (Default: 60)`)
ew.writeln(` - "ISPCONFIG_DDNS_TTL": The TTL of the TXT record used for the DNS challenge in seconds (Default: 3600)`)
ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/ispconfigddns`)
case "iwantmyname":
// generated from: providers/dns/iwantmyname/iwantmyname.toml
ew.writeln(`Configuration for iwantmyname (Deprecated).`)

View File

@@ -1,5 +1,5 @@
---
title: "ISPConfig"
title: "ISPConfig 3"
date: 2019-03-03T16:39:46+01:00
draft: false
slug: ispconfig
@@ -14,7 +14,7 @@ dnsprovider:
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
Configuration for [ISPConfig](https://www.ispconfig.org/).
Configuration for [ISPConfig 3](https://www.ispconfig.org/).
<!--more-->
@@ -23,7 +23,7 @@ Configuration for [ISPConfig](https://www.ispconfig.org/).
- Since: v4.31.0
Here is an example bash command using the ISPConfig provider:
Here is an example bash command using the ISPConfig 3 provider:
```bash
ISPCONFIG_SERVER_URL="https://example.com:8080/remote/json.php" \

74
docs/content/dns/zz_gen_ispconfigddns.md generated Normal file
View File

@@ -0,0 +1,74 @@
---
title: "ISPConfig 3 - Dynamic DNS (DDNS) Module"
date: 2019-03-03T16:39:46+01:00
draft: false
slug: ispconfigddns
dnsprovider:
since: "v4.31.0"
code: "ispconfigddns"
url: "https://www.ispconfig.org/"
---
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/ispconfigddns/ispconfigddns.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
Configuration for [ISPConfig 3 - Dynamic DNS (DDNS) Module](https://www.ispconfig.org/).
<!--more-->
- Code: `ispconfigddns`
- Since: v4.31.0
Here is an example bash command using the ISPConfig 3 - Dynamic DNS (DDNS) Module provider:
```bash
ISPCONFIG_DDNS_SERVER_URL="https://panel.example.com:8080" \
ISPCONFIG_DDNS_TOKEN=xxxxxx \
lego --email you@example.com --dns ispconfigddns -d '*.example.com' -d example.com run
```
## Credentials
| Environment Variable Name | Description |
|-----------------------|-------------|
| `ISPCONFIG_DDNS_SERVER_URL` | API server URL (ex: https://panel.example.com:8080) |
| `ISPCONFIG_DDNS_TOKEN` | DDNS API token |
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 |
|--------------------------------|-------------|
| `ISPCONFIG_DDNS_HTTP_TIMEOUT` | API request timeout in seconds (Default: 30) |
| `ISPCONFIG_DDNS_POLLING_INTERVAL` | Time between DNS propagation check in seconds (Default: 2) |
| `ISPCONFIG_DDNS_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation in seconds (Default: 60) |
| `ISPCONFIG_DDNS_TTL` | The TTL of the TXT record used for the DNS challenge in seconds (Default: 3600) |
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" %}}).
ISPConfig DNS provider supports leveraging the [ISPConfig 3 Dynamic DNS (DDNS) Module](https://github.com/mhofer117/ispconfig-ddns-module).
Requires the DDNS module described at https://www.ispconfig.org/ispconfig/download/
See https://www.howtoforge.com/community/threads/ispconfig-3-danymic-dns-ddns-module.87967/ for additional details.
## More information
- [API documentation](https://github.com/mhofer117/ispconfig-ddns-module/tree/master/lib/updater)
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/ispconfigddns/ispconfigddns.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, aliesa, allinkl, anexia, 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, 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, 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, anexia, 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, 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
More information: https://go-acme.github.io/lego/dns
"""

View File

@@ -1,4 +1,4 @@
Name = "ISPConfig"
Name = "ISPConfig 3"
Description = ''''''
URL = "https://www.ispconfig.org/"
Code = "ispconfig"

View File

@@ -0,0 +1,111 @@
package internal
import (
"context"
"fmt"
"io"
"net/http"
"net/url"
"time"
"github.com/go-acme/lego/v4/providers/dns/internal/errutils"
"github.com/go-acme/lego/v4/providers/dns/internal/useragent"
querystring "github.com/google/go-querystring/query"
)
const (
addAction = "add"
deleteAction = "delete"
)
type Client struct {
token string
serverURL string
HTTPClient *http.Client
}
func NewClient(serverURL, token string) (*Client, error) {
_, err := url.Parse(serverURL)
if err != nil {
return nil, fmt.Errorf("server URL: %w", err)
}
return &Client{
serverURL: serverURL,
token: token,
HTTPClient: &http.Client{Timeout: 10 * time.Second},
}, nil
}
func (c *Client) AddTXTRecord(ctx context.Context, zone, fqdn, content string) error {
return c.updateRecord(ctx, UpdateRecord{Action: addAction, Zone: zone, Type: "TXT", Record: fqdn, Data: content})
}
func (c *Client) DeleteTXTRecord(ctx context.Context, zone, fqdn, recordContent string) error {
return c.updateRecord(ctx, UpdateRecord{Action: deleteAction, Zone: zone, Type: "TXT", Record: fqdn, Data: recordContent})
}
func (c *Client) updateRecord(ctx context.Context, action UpdateRecord) error {
req, err := c.newRequest(ctx, action)
if err != nil {
return err
}
return c.do(req)
}
func (c *Client) do(req *http.Request) error {
useragent.SetHeader(req.Header)
req.SetBasicAuth("anonymous", c.token)
resp, err := c.HTTPClient.Do(req)
if err != nil {
return errutils.NewHTTPDoError(req, err)
}
defer func() { _ = resp.Body.Close() }()
// The endpoint uses the `DefaultDdnsResponseWriter`,
// and this writer uses HTTP status code to determine if the request was successful or not.
// - https://github.com/mhofer117/ispconfig-ddns-module/blob/8b011a5bb138881d9f13360a5c4fec10c0084613/lib/updater/DdnsUpdater.php#L53-L57
// - https://github.com/mhofer117/ispconfig-ddns-module/blob/master/lib/updater/response/DefaultDdnsResponseWriter.php
if resp.StatusCode/100 != 2 {
raw, _ := io.ReadAll(resp.Body)
return errutils.NewUnexpectedStatusCodeError(req, resp.StatusCode, raw)
}
return nil
}
func (c *Client) newRequest(ctx context.Context, action UpdateRecord) (*http.Request, error) {
endpoint, err := url.Parse(c.serverURL)
if err != nil {
return nil, err
}
endpoint = endpoint.JoinPath("ddns", "update.php")
values, err := querystring.Values(action)
if err != nil {
return nil, err
}
endpoint.RawQuery = values.Encode()
method := http.MethodPost
if action.Action == deleteAction {
method = http.MethodDelete
}
req, err := http.NewRequestWithContext(ctx, method, endpoint.String(), nil)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "application/json")
return req, nil
}

View File

@@ -0,0 +1,83 @@
package internal
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/go-acme/lego/v4/platform/tester/servermock"
"github.com/stretchr/testify/require"
)
func setupClient(server *httptest.Server) (*Client, error) {
client, err := NewClient(server.URL, "secret")
if err != nil {
return nil, err
}
client.HTTPClient = server.Client()
return client, nil
}
func TestClient_AddTXTRecord(t *testing.T) {
client := servermock.NewBuilder[*Client](setupClient).
Route("POST /ddns/update.php",
servermock.Noop(),
servermock.CheckHeader().
WithBasicAuth("anonymous", "secret"),
servermock.CheckQueryParameter().Strict().
With("action", "add").
With("zone", "example.com").
With("type", "TXT").
With("record", "_acme-challenge.example.com.").
With("data", "token"),
).
Build(t)
err := client.AddTXTRecord(t.Context(), "example.com", "_acme-challenge.example.com.", "token")
require.NoError(t, err)
}
func TestClient_AddTXTRecord_error(t *testing.T) {
client := servermock.NewBuilder[*Client](setupClient).
Route("POST /ddns/update.php",
servermock.RawStringResponse("Missing or invalid token.").
WithStatusCode(http.StatusUnauthorized),
).
Build(t)
err := client.AddTXTRecord(t.Context(), "example.com", "_acme-challenge.example.com.", "token")
require.EqualError(t, err, "unexpected status code: [status code: 401] body: Missing or invalid token.")
}
func TestClient_DeleteTXTRecord(t *testing.T) {
client := servermock.NewBuilder[*Client](setupClient).
Route("DELETE /ddns/update.php",
servermock.Noop(),
servermock.CheckHeader().
WithBasicAuth("anonymous", "secret"),
servermock.CheckQueryParameter().Strict().
With("action", "delete").
With("zone", "example.com").
With("type", "TXT").
With("record", "_acme-challenge.example.com.").
With("data", "token"),
).
Build(t)
err := client.DeleteTXTRecord(t.Context(), "example.com", "_acme-challenge.example.com.", "token")
require.NoError(t, err)
}
func TestClient_DeleteTXTRecord_error(t *testing.T) {
client := servermock.NewBuilder[*Client](setupClient).
Route("DELETE /ddns/update.php",
servermock.RawStringResponse("Missing or invalid token.").
WithStatusCode(http.StatusUnauthorized),
).
Build(t)
err := client.DeleteTXTRecord(t.Context(), "example.com", "_acme-challenge.example.com.", "token")
require.EqualError(t, err, "unexpected status code: [status code: 401] body: Missing or invalid token.")
}

View File

@@ -0,0 +1,9 @@
package internal
type UpdateRecord struct {
Action string `url:"action,omitempty"`
Zone string `url:"zone,omitempty"`
Type string `url:"type,omitempty"`
Record string `url:"record,omitempty"`
Data string `url:"data,omitempty"`
}

View File

@@ -0,0 +1,145 @@
// Package ispconfigddns implements a DNS provider for solving the DNS-01 challenge using ISPConfig 3 Dynamic DNS (DDNS) Module.
package ispconfigddns
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/internal/clientdebug"
"github.com/go-acme/lego/v4/providers/dns/ispconfigddns/internal"
)
// Environment variables names.
const (
envNamespace = "ISPCONFIG_DDNS_"
EnvServerURL = envNamespace + "SERVER_URL"
EnvToken = envNamespace + "TOKEN"
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 {
ServerURL string
Token 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, 3600),
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
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 ISPConfig 3 Dynamic DNS (DDNS) Module.
func NewDNSProvider() (*DNSProvider, error) {
values, err := env.Get(EnvServerURL, EnvToken)
if err != nil {
return nil, fmt.Errorf("ispconfig (DDNS module): %w", err)
}
config := NewDefaultConfig()
config.ServerURL = values[EnvServerURL]
config.Token = values[EnvToken]
return NewDNSProviderConfig(config)
}
// NewDNSProviderConfig return a DNSProvider instance configured for ISPConfig 3 Dynamic DNS (DDNS) Module.
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("ispconfig (DDNS module): the configuration of the DNS provider is nil")
}
if config.ServerURL == "" {
return nil, errors.New("ispconfig (DDNS module): missing server URL")
}
if config.Token == "" {
return nil, errors.New("ispconfig (DDNS module): missing token")
}
client, err := internal.NewClient(config.ServerURL, config.Token)
if err != nil {
return nil, fmt.Errorf("ispconfig (DDNS module): %w", err)
}
if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}
client.HTTPClient = clientdebug.Wrap(client.HTTPClient)
return &DNSProvider{
config: config,
client: client,
}, nil
}
// Timeout returns the timeout and interval to use when checking for DNS propagation.
// Adjusting here to control checking compliance to spec.
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
return d.config.PropagationTimeout, d.config.PollingInterval
}
// Present creates a TXT record to fulfill the dns-01 challenge.
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
info := dns01.GetChallengeInfo(domain, keyAuth)
zone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
if err != nil {
return fmt.Errorf("ispconfig (DDNS module): could not find zone for domain %q: %w", domain, err)
}
err = d.client.AddTXTRecord(context.Background(), dns01.UnFqdn(zone), info.EffectiveFQDN, info.Value)
if err != nil {
return fmt.Errorf("ispconfig (DDNS module): add record: %w", 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)
zone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
if err != nil {
return fmt.Errorf("ispconfig (DDNS module): could not find zone for domain %q: %w", domain, err)
}
err = d.client.DeleteTXTRecord(context.Background(), dns01.UnFqdn(zone), info.EffectiveFQDN, info.Value)
if err != nil {
return fmt.Errorf("ispconfig (DDNS module): delete record: %w", err)
}
return nil
}

View File

@@ -0,0 +1,32 @@
Name = "ISPConfig 3 - Dynamic DNS (DDNS) Module"
Description = ''''''
URL = "https://www.ispconfig.org/"
Code = "ispconfigddns"
Since = "v4.31.0"
Example = '''
ISPCONFIG_DDNS_SERVER_URL="https://panel.example.com:8080" \
ISPCONFIG_DDNS_TOKEN=xxxxxx \
lego --email you@example.com --dns ispconfigddns -d '*.example.com' -d example.com run
'''
Additional = '''
ISPConfig DNS provider supports leveraging the [ISPConfig 3 Dynamic DNS (DDNS) Module](https://github.com/mhofer117/ispconfig-ddns-module).
Requires the DDNS module described at https://www.ispconfig.org/ispconfig/download/
See https://www.howtoforge.com/community/threads/ispconfig-3-danymic-dns-ddns-module.87967/ for additional details.
'''
[Configuration]
[Configuration.Credentials]
ISPCONFIG_DDNS_SERVER_URL = "API server URL (ex: https://panel.example.com:8080)"
ISPCONFIG_DDNS_TOKEN = "DDNS API token"
[Configuration.Additional]
ISPCONFIG_DDNS_POLLING_INTERVAL = "Time between DNS propagation check in seconds (Default: 2)"
ISPCONFIG_DDNS_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation in seconds (Default: 60)"
ISPCONFIG_DDNS_TTL = "The TTL of the TXT record used for the DNS challenge in seconds (Default: 3600)"
ISPCONFIG_DDNS_HTTP_TIMEOUT = "API request timeout in seconds (Default: 30)"
[Links]
API = "https://github.com/mhofer117/ispconfig-ddns-module/tree/master/lib/updater"

View File

@@ -0,0 +1,193 @@
package ispconfigddns
import (
"net/http/httptest"
"testing"
"github.com/go-acme/lego/v4/platform/tester"
"github.com/go-acme/lego/v4/platform/tester/servermock"
"github.com/stretchr/testify/require"
)
const envDomain = envNamespace + "DOMAIN"
var envTest = tester.NewEnvTest(EnvServerURL, EnvToken).
WithDomain(envDomain)
func TestNewDNSProvider(t *testing.T) {
testCases := []struct {
desc string
envVars map[string]string
expected string
}{
{
desc: "success",
envVars: map[string]string{
EnvServerURL: "https://example.com",
EnvToken: "secret",
},
},
{
desc: "missing server URL",
envVars: map[string]string{
EnvServerURL: "",
EnvToken: "secret",
},
expected: "ispconfig (DDNS module): some credentials information are missing: ISPCONFIG_DDNS_SERVER_URL",
},
{
desc: "missing token",
envVars: map[string]string{
EnvServerURL: "https://example.com",
EnvToken: "",
},
expected: "ispconfig (DDNS module): some credentials information are missing: ISPCONFIG_DDNS_TOKEN",
},
{
desc: "missing credentials",
envVars: map[string]string{},
expected: "ispconfig (DDNS module): some credentials information are missing: ISPCONFIG_DDNS_SERVER_URL,ISPCONFIG_DDNS_TOKEN",
},
}
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
serverURL string
token string
expected string
}{
{
desc: "success",
serverURL: "https://example.com",
token: "secret",
},
{
desc: "missing server URL",
serverURL: "",
token: "secret",
expected: "ispconfig (DDNS module): missing server URL",
},
{
desc: "missing token",
serverURL: "https://example.com",
token: "",
expected: "ispconfig (DDNS module): missing token",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
config := NewDefaultConfig()
config.ServerURL = test.serverURL
config.Token = test.token
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()
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.HTTPClient = server.Client()
config.Token = "secret"
config.ServerURL = server.URL
return NewDNSProviderConfig(config)
},
servermock.CheckHeader().
WithBasicAuth("anonymous", "secret"),
)
}
func TestDNSProvider_Present(t *testing.T) {
provider := mockBuilder().
Route("POST /ddns/update.php",
servermock.DumpRequest(),
servermock.CheckQueryParameter().Strict().
With("action", "add").
With("zone", "example.com").
With("type", "TXT").
With("record", "_acme-challenge.example.com.").
With("data", "ADw2sEd82DUgXcQ9hNBZThJs7zVJkR5v9JeSbAb9mZY"),
).
Build(t)
err := provider.Present("example.com", "abc", "123d==")
require.NoError(t, err)
}
func TestDNSProvider_CleanUp(t *testing.T) {
provider := mockBuilder().
Route("DELETE /ddns/update.php",
servermock.DumpRequest(),
servermock.CheckQueryParameter().Strict().
With("action", "delete").
With("zone", "example.com").
With("type", "TXT").
With("record", "_acme-challenge.example.com.").
With("data", "ADw2sEd82DUgXcQ9hNBZThJs7zVJkR5v9JeSbAb9mZY"),
).
Build(t)
err := provider.CleanUp("example.com", "abc", "123d==")
require.NoError(t, err)
}

View File

@@ -95,6 +95,7 @@ import (
"github.com/go-acme/lego/v4/providers/dns/ionoscloud"
"github.com/go-acme/lego/v4/providers/dns/ipv64"
"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/joker"
"github.com/go-acme/lego/v4/providers/dns/keyhelp"
@@ -366,6 +367,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
return ipv64.NewDNSProvider()
case "ispconfig":
return ispconfig.NewDNSProvider()
case "ispconfigddns":
return ispconfigddns.NewDNSProvider()
case "iwantmyname":
return iwantmyname.NewDNSProvider()
case "joker":