diff --git a/README.md b/README.md index 701e1e10de..586881e8ed 100644 --- a/README.md +++ b/README.md @@ -58,36 +58,36 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns). | [Azure (deprecated)](https://go-acme.github.io/lego/dns/azure/) | [Azure DNS](https://go-acme.github.io/lego/dns/azuredns/) | [Bindman](https://go-acme.github.io/lego/dns/bindman/) | [Bluecat](https://go-acme.github.io/lego/dns/bluecat/) | | [Brandit](https://go-acme.github.io/lego/dns/brandit/) | [Bunny](https://go-acme.github.io/lego/dns/bunny/) | [Checkdomain](https://go-acme.github.io/lego/dns/checkdomain/) | [Civo](https://go-acme.github.io/lego/dns/civo/) | | [Cloud.ru](https://go-acme.github.io/lego/dns/cloudru/) | [CloudDNS](https://go-acme.github.io/lego/dns/clouddns/) | [Cloudflare](https://go-acme.github.io/lego/dns/cloudflare/) | [ClouDNS](https://go-acme.github.io/lego/dns/cloudns/) | -| [CloudXNS](https://go-acme.github.io/lego/dns/cloudxns/) | [ConoHa](https://go-acme.github.io/lego/dns/conoha/) | [Constellix](https://go-acme.github.io/lego/dns/constellix/) | [CPanel/WHM](https://go-acme.github.io/lego/dns/cpanel/) | -| [Derak Cloud](https://go-acme.github.io/lego/dns/derak/) | [deSEC.io](https://go-acme.github.io/lego/dns/desec/) | [Designate DNSaaS for Openstack](https://go-acme.github.io/lego/dns/designate/) | [Digital Ocean](https://go-acme.github.io/lego/dns/digitalocean/) | -| [DirectAdmin](https://go-acme.github.io/lego/dns/directadmin/) | [DNS Made Easy](https://go-acme.github.io/lego/dns/dnsmadeeasy/) | [dnsHome.de](https://go-acme.github.io/lego/dns/dnshomede/) | [DNSimple](https://go-acme.github.io/lego/dns/dnsimple/) | -| [DNSPod (deprecated)](https://go-acme.github.io/lego/dns/dnspod/) | [Domain Offensive (do.de)](https://go-acme.github.io/lego/dns/dode/) | [Domeneshop](https://go-acme.github.io/lego/dns/domeneshop/) | [DreamHost](https://go-acme.github.io/lego/dns/dreamhost/) | -| [Duck DNS](https://go-acme.github.io/lego/dns/duckdns/) | [Dyn](https://go-acme.github.io/lego/dns/dyn/) | [Dynu](https://go-acme.github.io/lego/dns/dynu/) | [EasyDNS](https://go-acme.github.io/lego/dns/easydns/) | -| [Efficient IP](https://go-acme.github.io/lego/dns/efficientip/) | [Epik](https://go-acme.github.io/lego/dns/epik/) | [Exoscale](https://go-acme.github.io/lego/dns/exoscale/) | [External program](https://go-acme.github.io/lego/dns/exec/) | -| [freemyip.com](https://go-acme.github.io/lego/dns/freemyip/) | [G-Core](https://go-acme.github.io/lego/dns/gcore/) | [Gandi Live DNS (v5)](https://go-acme.github.io/lego/dns/gandiv5/) | [Gandi](https://go-acme.github.io/lego/dns/gandi/) | -| [Glesys](https://go-acme.github.io/lego/dns/glesys/) | [Go Daddy](https://go-acme.github.io/lego/dns/godaddy/) | [Google Cloud](https://go-acme.github.io/lego/dns/gcloud/) | [Google Domains](https://go-acme.github.io/lego/dns/googledomains/) | -| [Hetzner](https://go-acme.github.io/lego/dns/hetzner/) | [Hosting.de](https://go-acme.github.io/lego/dns/hostingde/) | [Hosttech](https://go-acme.github.io/lego/dns/hosttech/) | [HTTP request](https://go-acme.github.io/lego/dns/httpreq/) | -| [http.net](https://go-acme.github.io/lego/dns/httpnet/) | [Huawei Cloud](https://go-acme.github.io/lego/dns/huaweicloud/) | [Hurricane Electric DNS](https://go-acme.github.io/lego/dns/hurricane/) | [HyperOne](https://go-acme.github.io/lego/dns/hyperone/) | -| [IBM Cloud (SoftLayer)](https://go-acme.github.io/lego/dns/ibmcloud/) | [IIJ DNS Platform Service](https://go-acme.github.io/lego/dns/iijdpf/) | [Infoblox](https://go-acme.github.io/lego/dns/infoblox/) | [Infomaniak](https://go-acme.github.io/lego/dns/infomaniak/) | -| [Internet Initiative Japan](https://go-acme.github.io/lego/dns/iij/) | [Internet.bs](https://go-acme.github.io/lego/dns/internetbs/) | [INWX](https://go-acme.github.io/lego/dns/inwx/) | [Ionos](https://go-acme.github.io/lego/dns/ionos/) | -| [IPv64](https://go-acme.github.io/lego/dns/ipv64/) | [iwantmyname](https://go-acme.github.io/lego/dns/iwantmyname/) | [Joker](https://go-acme.github.io/lego/dns/joker/) | [Joohoi's ACME-DNS](https://go-acme.github.io/lego/dns/acme-dns/) | -| [Liara](https://go-acme.github.io/lego/dns/liara/) | [Lima-City](https://go-acme.github.io/lego/dns/limacity/) | [Linode (v4)](https://go-acme.github.io/lego/dns/linode/) | [Liquid Web](https://go-acme.github.io/lego/dns/liquidweb/) | -| [Loopia](https://go-acme.github.io/lego/dns/loopia/) | [LuaDNS](https://go-acme.github.io/lego/dns/luadns/) | [Mail-in-a-Box](https://go-acme.github.io/lego/dns/mailinabox/) | [Manual](https://go-acme.github.io/lego/dns/manual/) | -| [Metaname](https://go-acme.github.io/lego/dns/metaname/) | [mijn.host](https://go-acme.github.io/lego/dns/mijnhost/) | [Mittwald](https://go-acme.github.io/lego/dns/mittwald/) | [MyDNS.jp](https://go-acme.github.io/lego/dns/mydnsjp/) | -| [MythicBeasts](https://go-acme.github.io/lego/dns/mythicbeasts/) | [Name.com](https://go-acme.github.io/lego/dns/namedotcom/) | [Namecheap](https://go-acme.github.io/lego/dns/namecheap/) | [Namesilo](https://go-acme.github.io/lego/dns/namesilo/) | -| [NearlyFreeSpeech.NET](https://go-acme.github.io/lego/dns/nearlyfreespeech/) | [Netcup](https://go-acme.github.io/lego/dns/netcup/) | [Netlify](https://go-acme.github.io/lego/dns/netlify/) | [Nicmanager](https://go-acme.github.io/lego/dns/nicmanager/) | -| [NIFCloud](https://go-acme.github.io/lego/dns/nifcloud/) | [Njalla](https://go-acme.github.io/lego/dns/njalla/) | [Nodion](https://go-acme.github.io/lego/dns/nodion/) | [NS1](https://go-acme.github.io/lego/dns/ns1/) | -| [Open Telekom Cloud](https://go-acme.github.io/lego/dns/otc/) | [Oracle Cloud](https://go-acme.github.io/lego/dns/oraclecloud/) | [OVH](https://go-acme.github.io/lego/dns/ovh/) | [plesk.com](https://go-acme.github.io/lego/dns/plesk/) | -| [Porkbun](https://go-acme.github.io/lego/dns/porkbun/) | [PowerDNS](https://go-acme.github.io/lego/dns/pdns/) | [Rackspace](https://go-acme.github.io/lego/dns/rackspace/) | [RcodeZero](https://go-acme.github.io/lego/dns/rcodezero/) | -| [reg.ru](https://go-acme.github.io/lego/dns/regru/) | [RFC2136](https://go-acme.github.io/lego/dns/rfc2136/) | [RimuHosting](https://go-acme.github.io/lego/dns/rimuhosting/) | [Sakura Cloud](https://go-acme.github.io/lego/dns/sakuracloud/) | -| [Scaleway](https://go-acme.github.io/lego/dns/scaleway/) | [Selectel v2](https://go-acme.github.io/lego/dns/selectelv2/) | [Selectel](https://go-acme.github.io/lego/dns/selectel/) | [SelfHost.(de/eu)](https://go-acme.github.io/lego/dns/selfhostde/) | -| [Servercow](https://go-acme.github.io/lego/dns/servercow/) | [Shellrent](https://go-acme.github.io/lego/dns/shellrent/) | [Simply.com](https://go-acme.github.io/lego/dns/simply/) | [Sonic](https://go-acme.github.io/lego/dns/sonic/) | -| [Stackpath](https://go-acme.github.io/lego/dns/stackpath/) | [Tencent Cloud DNS](https://go-acme.github.io/lego/dns/tencentcloud/) | [Timeweb Cloud](https://go-acme.github.io/lego/dns/timewebcloud/) | [TransIP](https://go-acme.github.io/lego/dns/transip/) | -| [UKFast SafeDNS](https://go-acme.github.io/lego/dns/safedns/) | [Ultradns](https://go-acme.github.io/lego/dns/ultradns/) | [Variomedia](https://go-acme.github.io/lego/dns/variomedia/) | [VegaDNS](https://go-acme.github.io/lego/dns/vegadns/) | -| [Vercel](https://go-acme.github.io/lego/dns/vercel/) | [Versio.[nl/eu/uk]](https://go-acme.github.io/lego/dns/versio/) | [VinylDNS](https://go-acme.github.io/lego/dns/vinyldns/) | [VK Cloud](https://go-acme.github.io/lego/dns/vkcloud/) | -| [Volcano Engine/火山引擎](https://go-acme.github.io/lego/dns/volcengine/) | [Vscale](https://go-acme.github.io/lego/dns/vscale/) | [Vultr](https://go-acme.github.io/lego/dns/vultr/) | [Webnames](https://go-acme.github.io/lego/dns/webnames/) | -| [Websupport](https://go-acme.github.io/lego/dns/websupport/) | [WEDOS](https://go-acme.github.io/lego/dns/wedos/) | [Yandex 360](https://go-acme.github.io/lego/dns/yandex360/) | [Yandex Cloud](https://go-acme.github.io/lego/dns/yandexcloud/) | -| [Yandex PDD](https://go-acme.github.io/lego/dns/yandex/) | [Zone.ee](https://go-acme.github.io/lego/dns/zoneee/) | [Zonomi](https://go-acme.github.io/lego/dns/zonomi/) | | +| [CloudXNS](https://go-acme.github.io/lego/dns/cloudxns/) | [ConoHa](https://go-acme.github.io/lego/dns/conoha/) | [Constellix](https://go-acme.github.io/lego/dns/constellix/) | [Core-Networks](https://go-acme.github.io/lego/dns/corenetworks/) | +| [CPanel/WHM](https://go-acme.github.io/lego/dns/cpanel/) | [Derak Cloud](https://go-acme.github.io/lego/dns/derak/) | [deSEC.io](https://go-acme.github.io/lego/dns/desec/) | [Designate DNSaaS for Openstack](https://go-acme.github.io/lego/dns/designate/) | +| [Digital Ocean](https://go-acme.github.io/lego/dns/digitalocean/) | [DirectAdmin](https://go-acme.github.io/lego/dns/directadmin/) | [DNS Made Easy](https://go-acme.github.io/lego/dns/dnsmadeeasy/) | [dnsHome.de](https://go-acme.github.io/lego/dns/dnshomede/) | +| [DNSimple](https://go-acme.github.io/lego/dns/dnsimple/) | [DNSPod (deprecated)](https://go-acme.github.io/lego/dns/dnspod/) | [Domain Offensive (do.de)](https://go-acme.github.io/lego/dns/dode/) | [Domeneshop](https://go-acme.github.io/lego/dns/domeneshop/) | +| [DreamHost](https://go-acme.github.io/lego/dns/dreamhost/) | [Duck DNS](https://go-acme.github.io/lego/dns/duckdns/) | [Dyn](https://go-acme.github.io/lego/dns/dyn/) | [Dynu](https://go-acme.github.io/lego/dns/dynu/) | +| [EasyDNS](https://go-acme.github.io/lego/dns/easydns/) | [Efficient IP](https://go-acme.github.io/lego/dns/efficientip/) | [Epik](https://go-acme.github.io/lego/dns/epik/) | [Exoscale](https://go-acme.github.io/lego/dns/exoscale/) | +| [External program](https://go-acme.github.io/lego/dns/exec/) | [freemyip.com](https://go-acme.github.io/lego/dns/freemyip/) | [G-Core](https://go-acme.github.io/lego/dns/gcore/) | [Gandi Live DNS (v5)](https://go-acme.github.io/lego/dns/gandiv5/) | +| [Gandi](https://go-acme.github.io/lego/dns/gandi/) | [Glesys](https://go-acme.github.io/lego/dns/glesys/) | [Go Daddy](https://go-acme.github.io/lego/dns/godaddy/) | [Google Cloud](https://go-acme.github.io/lego/dns/gcloud/) | +| [Google Domains](https://go-acme.github.io/lego/dns/googledomains/) | [Hetzner](https://go-acme.github.io/lego/dns/hetzner/) | [Hosting.de](https://go-acme.github.io/lego/dns/hostingde/) | [Hosttech](https://go-acme.github.io/lego/dns/hosttech/) | +| [HTTP request](https://go-acme.github.io/lego/dns/httpreq/) | [http.net](https://go-acme.github.io/lego/dns/httpnet/) | [Huawei Cloud](https://go-acme.github.io/lego/dns/huaweicloud/) | [Hurricane Electric DNS](https://go-acme.github.io/lego/dns/hurricane/) | +| [HyperOne](https://go-acme.github.io/lego/dns/hyperone/) | [IBM Cloud (SoftLayer)](https://go-acme.github.io/lego/dns/ibmcloud/) | [IIJ DNS Platform Service](https://go-acme.github.io/lego/dns/iijdpf/) | [Infoblox](https://go-acme.github.io/lego/dns/infoblox/) | +| [Infomaniak](https://go-acme.github.io/lego/dns/infomaniak/) | [Internet Initiative Japan](https://go-acme.github.io/lego/dns/iij/) | [Internet.bs](https://go-acme.github.io/lego/dns/internetbs/) | [INWX](https://go-acme.github.io/lego/dns/inwx/) | +| [Ionos](https://go-acme.github.io/lego/dns/ionos/) | [IPv64](https://go-acme.github.io/lego/dns/ipv64/) | [iwantmyname](https://go-acme.github.io/lego/dns/iwantmyname/) | [Joker](https://go-acme.github.io/lego/dns/joker/) | +| [Joohoi's ACME-DNS](https://go-acme.github.io/lego/dns/acme-dns/) | [Liara](https://go-acme.github.io/lego/dns/liara/) | [Lima-City](https://go-acme.github.io/lego/dns/limacity/) | [Linode (v4)](https://go-acme.github.io/lego/dns/linode/) | +| [Liquid Web](https://go-acme.github.io/lego/dns/liquidweb/) | [Loopia](https://go-acme.github.io/lego/dns/loopia/) | [LuaDNS](https://go-acme.github.io/lego/dns/luadns/) | [Mail-in-a-Box](https://go-acme.github.io/lego/dns/mailinabox/) | +| [Manual](https://go-acme.github.io/lego/dns/manual/) | [Metaname](https://go-acme.github.io/lego/dns/metaname/) | [mijn.host](https://go-acme.github.io/lego/dns/mijnhost/) | [Mittwald](https://go-acme.github.io/lego/dns/mittwald/) | +| [MyDNS.jp](https://go-acme.github.io/lego/dns/mydnsjp/) | [MythicBeasts](https://go-acme.github.io/lego/dns/mythicbeasts/) | [Name.com](https://go-acme.github.io/lego/dns/namedotcom/) | [Namecheap](https://go-acme.github.io/lego/dns/namecheap/) | +| [Namesilo](https://go-acme.github.io/lego/dns/namesilo/) | [NearlyFreeSpeech.NET](https://go-acme.github.io/lego/dns/nearlyfreespeech/) | [Netcup](https://go-acme.github.io/lego/dns/netcup/) | [Netlify](https://go-acme.github.io/lego/dns/netlify/) | +| [Nicmanager](https://go-acme.github.io/lego/dns/nicmanager/) | [NIFCloud](https://go-acme.github.io/lego/dns/nifcloud/) | [Njalla](https://go-acme.github.io/lego/dns/njalla/) | [Nodion](https://go-acme.github.io/lego/dns/nodion/) | +| [NS1](https://go-acme.github.io/lego/dns/ns1/) | [Open Telekom Cloud](https://go-acme.github.io/lego/dns/otc/) | [Oracle Cloud](https://go-acme.github.io/lego/dns/oraclecloud/) | [OVH](https://go-acme.github.io/lego/dns/ovh/) | +| [plesk.com](https://go-acme.github.io/lego/dns/plesk/) | [Porkbun](https://go-acme.github.io/lego/dns/porkbun/) | [PowerDNS](https://go-acme.github.io/lego/dns/pdns/) | [Rackspace](https://go-acme.github.io/lego/dns/rackspace/) | +| [RcodeZero](https://go-acme.github.io/lego/dns/rcodezero/) | [reg.ru](https://go-acme.github.io/lego/dns/regru/) | [RFC2136](https://go-acme.github.io/lego/dns/rfc2136/) | [RimuHosting](https://go-acme.github.io/lego/dns/rimuhosting/) | +| [Sakura Cloud](https://go-acme.github.io/lego/dns/sakuracloud/) | [Scaleway](https://go-acme.github.io/lego/dns/scaleway/) | [Selectel v2](https://go-acme.github.io/lego/dns/selectelv2/) | [Selectel](https://go-acme.github.io/lego/dns/selectel/) | +| [SelfHost.(de/eu)](https://go-acme.github.io/lego/dns/selfhostde/) | [Servercow](https://go-acme.github.io/lego/dns/servercow/) | [Shellrent](https://go-acme.github.io/lego/dns/shellrent/) | [Simply.com](https://go-acme.github.io/lego/dns/simply/) | +| [Sonic](https://go-acme.github.io/lego/dns/sonic/) | [Stackpath](https://go-acme.github.io/lego/dns/stackpath/) | [Tencent Cloud DNS](https://go-acme.github.io/lego/dns/tencentcloud/) | [Timeweb Cloud](https://go-acme.github.io/lego/dns/timewebcloud/) | +| [TransIP](https://go-acme.github.io/lego/dns/transip/) | [UKFast SafeDNS](https://go-acme.github.io/lego/dns/safedns/) | [Ultradns](https://go-acme.github.io/lego/dns/ultradns/) | [Variomedia](https://go-acme.github.io/lego/dns/variomedia/) | +| [VegaDNS](https://go-acme.github.io/lego/dns/vegadns/) | [Vercel](https://go-acme.github.io/lego/dns/vercel/) | [Versio.[nl/eu/uk]](https://go-acme.github.io/lego/dns/versio/) | [VinylDNS](https://go-acme.github.io/lego/dns/vinyldns/) | +| [VK Cloud](https://go-acme.github.io/lego/dns/vkcloud/) | [Volcano Engine/火山引擎](https://go-acme.github.io/lego/dns/volcengine/) | [Vscale](https://go-acme.github.io/lego/dns/vscale/) | [Vultr](https://go-acme.github.io/lego/dns/vultr/) | +| [Webnames](https://go-acme.github.io/lego/dns/webnames/) | [Websupport](https://go-acme.github.io/lego/dns/websupport/) | [WEDOS](https://go-acme.github.io/lego/dns/wedos/) | [Yandex 360](https://go-acme.github.io/lego/dns/yandex360/) | +| [Yandex Cloud](https://go-acme.github.io/lego/dns/yandexcloud/) | [Yandex PDD](https://go-acme.github.io/lego/dns/yandex/) | [Zone.ee](https://go-acme.github.io/lego/dns/zoneee/) | [Zonomi](https://go-acme.github.io/lego/dns/zonomi/) | diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go index 6516a78ee6..34dac26132 100644 --- a/cmd/zz_gen_cmd_dnshelp.go +++ b/cmd/zz_gen_cmd_dnshelp.go @@ -34,6 +34,7 @@ func allDNSCodes() string { "cloudxns", "conoha", "constellix", + "corenetworks", "cpanel", "derak", "desec", @@ -624,6 +625,28 @@ func displayDNSHelp(w io.Writer, name string) error { ew.writeln() ew.writeln(`More information: https://go-acme.github.io/lego/dns/constellix`) + case "corenetworks": + // generated from: providers/dns/corenetworks/corenetworks.toml + ew.writeln(`Configuration for Core-Networks.`) + ew.writeln(`Code: 'corenetworks'`) + ew.writeln(`Since: 'v4.20.0'`) + ew.writeln() + + ew.writeln(`Credentials:`) + ew.writeln(` - "CORENETWORKS_LOGIN": The username of the API account`) + ew.writeln(` - "CORENETWORKS_PASSWORD": The password`) + ew.writeln() + + ew.writeln(`Additional Configuration:`) + ew.writeln(` - "CORENETWORKS_HTTP_TIMEOUT": API request timeout`) + ew.writeln(` - "CORENETWORKS_POLLING_INTERVAL": Time between DNS propagation check`) + ew.writeln(` - "CORENETWORKS_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) + ew.writeln(` - "CORENETWORKS_SEQUENCE_INTERVAL": Time between sequential requests`) + ew.writeln(` - "CORENETWORKS_TTL": The TTL of the TXT record used for the DNS challenge`) + + ew.writeln() + ew.writeln(`More information: https://go-acme.github.io/lego/dns/corenetworks`) + case "cpanel": // generated from: providers/dns/cpanel/cpanel.toml ew.writeln(`Configuration for CPanel/WHM.`) diff --git a/docs/content/dns/zz_gen_corenetworks.md b/docs/content/dns/zz_gen_corenetworks.md new file mode 100644 index 0000000000..0086d31e3f --- /dev/null +++ b/docs/content/dns/zz_gen_corenetworks.md @@ -0,0 +1,70 @@ +--- +title: "Core-Networks" +date: 2019-03-03T16:39:46+01:00 +draft: false +slug: corenetworks +dnsprovider: + since: "v4.20.0" + code: "corenetworks" + url: "https://www.core-networks.de/" +--- + + + + + + +Configuration for [Core-Networks](https://www.core-networks.de/). + + + + +- Code: `corenetworks` +- Since: v4.20.0 + + +Here is an example bash command using the Core-Networks provider: + +```bash +CORENETWORKS_LOGIN="xxxx" \ +CORENETWORKS_PASSWORD="yyyy" \ +lego --email myemail@example.com --dns corenetworks --domains my.example.org run +``` + + + + +## Credentials + +| Environment Variable Name | Description | +|-----------------------|-------------| +| `CORENETWORKS_LOGIN` | The username of the API account | +| `CORENETWORKS_PASSWORD` | The password | + +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 | +|--------------------------------|-------------| +| `CORENETWORKS_HTTP_TIMEOUT` | API request timeout | +| `CORENETWORKS_POLLING_INTERVAL` | Time between DNS propagation check | +| `CORENETWORKS_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | +| `CORENETWORKS_SEQUENCE_INTERVAL` | Time between sequential requests | +| `CORENETWORKS_TTL` | The TTL of the TXT record used for the DNS challenge | + +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://beta.api.core-networks.de/doc/) + + + + diff --git a/docs/data/zz_cli_help.toml b/docs/data/zz_cli_help.toml index ac600644c8..a389c79391 100644 --- a/docs/data/zz_cli_help.toml +++ b/docs/data/zz_cli_help.toml @@ -141,7 +141,7 @@ To display the documentation for a specific DNS provider, run: $ lego dnshelp -c code Supported DNS providers: - acme-dns, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, bindman, bluecat, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, constellix, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dynu, easydns, edgedns, efficientip, epik, exec, exoscale, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manual, metaname, mijnhost, mittwald, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nifcloud, njalla, nodion, ns1, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rcodezero, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, selfhostde, servercow, shellrent, simply, sonic, stackpath, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, yandex, yandex360, yandexcloud, zoneee, zonomi + acme-dns, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, bindman, bluecat, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, constellix, corenetworks, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dynu, easydns, edgedns, efficientip, epik, exec, exoscale, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hosttech, httpnet, httpreq, huaweicloud, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manual, metaname, mijnhost, mittwald, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nifcloud, njalla, nodion, ns1, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rcodezero, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, selfhostde, servercow, shellrent, simply, sonic, stackpath, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, yandex, yandex360, yandexcloud, zoneee, zonomi More information: https://go-acme.github.io/lego/dns """ diff --git a/providers/dns/corenetworks/corenetworks.go b/providers/dns/corenetworks/corenetworks.go new file mode 100644 index 0000000000..43b2f47b9f --- /dev/null +++ b/providers/dns/corenetworks/corenetworks.go @@ -0,0 +1,181 @@ +package corenetworks + +import ( + "context" + "errors" + "fmt" + "net/http" + "time" + + "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/corenetworks/internal" +) + +// Environment variables names. +const ( + envNamespace = "CORENETWORKS_" + + EnvLogin = envNamespace + "LOGIN" + EnvPassword = envNamespace + "PASSWORD" + + EnvTTL = envNamespace + "TTL" + EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" + EnvPollingInterval = envNamespace + "POLLING_INTERVAL" + EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL" + EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT" +) + +// Config is used to configure the creation of the DNSProvider. +type Config struct { + Login string + Password string + PropagationTimeout time.Duration + PollingInterval time.Duration + SequenceInterval 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), + SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout), + 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 Core-Networks. +// Credentials must be passed in the environment variables: CORENETWORKS_LOGIN, CORENETWORKS_PASSWORD. +func NewDNSProvider() (*DNSProvider, error) { + values, err := env.Get(EnvLogin, EnvPassword) + if err != nil { + return nil, fmt.Errorf("corenetworks: %w", err) + } + + config := NewDefaultConfig() + config.Login = values[EnvLogin] + config.Password = values[EnvPassword] + + return NewDNSProviderConfig(config) +} + +// NewDNSProviderConfig return a DNSProvider instance configured for Bluecat DNS. +func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { + if config == nil { + return nil, errors.New("corenetworks: the configuration of the DNS provider is nil") + } + + if config.Login == "" || config.Password == "" { + return nil, errors.New("corenetworks: credentials missing") + } + + client := internal.NewClient(config.Login, 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 +} + +// Sequential All DNS challenges for this provider will be resolved sequentially. +// Returns the interval between each iteration. +func (d *DNSProvider) Sequential() time.Duration { + return d.config.SequenceInterval +} + +// Present creates a TXT record using the specified parameters. +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + info := dns01.GetChallengeInfo(domain, keyAuth) + + ctx, err := d.client.CreateAuthenticatedContext(context.Background()) + if err != nil { + return fmt.Errorf("create authentication token: %w", err) + } + + zone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN) + if err != nil { + return fmt.Errorf("corenetworks: could not find zone for domain %q: %w", domain, err) + } + + subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone) + if err != nil { + return fmt.Errorf("corenetworks: %w", err) + } + + record := internal.Record{ + Name: subDomain, + TTL: d.config.TTL, + Type: "TXT", + Data: info.Value, + } + + err = d.client.AddRecord(ctx, dns01.UnFqdn(zone), record) + if err != nil { + return fmt.Errorf("corenetworks: add record: %w", err) + } + + err = d.client.CommitRecords(ctx, dns01.UnFqdn(zone)) + if err != nil { + return fmt.Errorf("corenetworks: commit records: %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) + + ctx, err := d.client.CreateAuthenticatedContext(context.Background()) + if err != nil { + return fmt.Errorf("create authentication token: %w", err) + } + + zone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN) + if err != nil { + return fmt.Errorf("corenetworks: could not find zone for domain %q: %w", domain, err) + } + + subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone) + if err != nil { + return fmt.Errorf("corenetworks: %w", err) + } + + record := internal.Record{ + Name: subDomain, + TTL: d.config.TTL, + Type: "TXT", + Data: info.Value, + } + + err = d.client.DeleteRecords(ctx, dns01.UnFqdn(zone), record) + if err != nil { + return fmt.Errorf("corenetworks: delete records: %w", err) + } + + err = d.client.CommitRecords(ctx, dns01.UnFqdn(zone)) + if err != nil { + return fmt.Errorf("corenetworks: commit records: %w", err) + } + + return nil +} diff --git a/providers/dns/corenetworks/corenetworks.toml b/providers/dns/corenetworks/corenetworks.toml new file mode 100644 index 0000000000..cc8e71fd05 --- /dev/null +++ b/providers/dns/corenetworks/corenetworks.toml @@ -0,0 +1,25 @@ +Name = "Core-Networks" +Description = '''''' +URL = "https://www.core-networks.de/" +Code = "corenetworks" +Since = "v4.20.0" + +Example = ''' +CORENETWORKS_LOGIN="xxxx" \ +CORENETWORKS_PASSWORD="yyyy" \ +lego --email myemail@example.com --dns corenetworks --domains my.example.org run +''' + +[Configuration] + [Configuration.Credentials] + CORENETWORKS_LOGIN = "The username of the API account" + CORENETWORKS_PASSWORD = "The password" + [Configuration.Additional] + CORENETWORKS_POLLING_INTERVAL = "Time between DNS propagation check" + CORENETWORKS_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" + CORENETWORKS_TTL = "The TTL of the TXT record used for the DNS challenge" + CORENETWORKS_HTTP_TIMEOUT = "API request timeout" + CORENETWORKS_SEQUENCE_INTERVAL = "Time between sequential requests" + +[Links] + API = "https://beta.api.core-networks.de/doc/" diff --git a/providers/dns/corenetworks/corenetworks_test.go b/providers/dns/corenetworks/corenetworks_test.go new file mode 100644 index 0000000000..3cd80f88d7 --- /dev/null +++ b/providers/dns/corenetworks/corenetworks_test.go @@ -0,0 +1,132 @@ +package corenetworks + +import ( + "testing" + + "github.com/go-acme/lego/v4/platform/tester" + "github.com/stretchr/testify/require" +) + +const envDomain = envNamespace + "DOMAIN" + +var envTest = tester.NewEnvTest(EnvLogin, EnvPassword).WithDomain(envDomain) + +func TestNewDNSProvider(t *testing.T) { + testCases := []struct { + desc string + envVars map[string]string + expected string + }{ + { + desc: "success", + envVars: map[string]string{ + EnvLogin: "user", + EnvPassword: "secret", + }, + }, + { + desc: "missing login", + envVars: map[string]string{ + EnvPassword: "secret", + }, + expected: "corenetworks: some credentials information are missing: CORENETWORKS_LOGIN", + }, + { + desc: "missing password", + envVars: map[string]string{ + EnvLogin: "user", + }, + expected: "corenetworks: some credentials information are missing: CORENETWORKS_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) + require.NotNil(t, p.client) + } else { + require.EqualError(t, err, test.expected) + } + }) + } +} + +func TestNewDNSProviderConfig(t *testing.T) { + testCases := []struct { + desc string + login string + password string + expected string + }{ + { + desc: "success", + login: "user", + password: "secret", + }, + { + desc: "missing login", + password: "secret", + expected: "corenetworks: credentials missing", + }, + { + desc: "missing password", + login: "user", + expected: "corenetworks: credentials missing", + }, + } + + for _, test := range testCases { + t.Run(test.desc, func(t *testing.T) { + config := NewDefaultConfig() + config.Login = test.login + config.Password = test.password + + 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) +} diff --git a/providers/dns/corenetworks/internal/client.go b/providers/dns/corenetworks/internal/client.go new file mode 100644 index 0000000000..993b01f1e9 --- /dev/null +++ b/providers/dns/corenetworks/internal/client.go @@ -0,0 +1,214 @@ +package internal + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "time" + + "github.com/go-acme/lego/v4/providers/dns/internal/errutils" +) + +const defaultBaseURL = "https://beta.api.core-networks.de" + +// Client a Core-Networks client. +type Client struct { + login string + password string + + baseURL *url.URL + HTTPClient *http.Client +} + +// NewClient creates a new 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}, + } +} + +// ListZone gets a list of all DNS zones. +// https://beta.api.core-networks.de/doc/#functon_dnszones +func (c Client) ListZone(ctx context.Context) ([]Zone, error) { + endpoint := c.baseURL.JoinPath("dnszones") + + req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return nil, err + } + + var zones []Zone + err = c.do(req, &zones) + if err != nil { + return nil, err + } + + return zones, nil +} + +// GetZoneDetails provides detailed information about a DNS zone. +// https://beta.api.core-networks.de/doc/#functon_dnszones_details +func (c Client) GetZoneDetails(ctx context.Context, zone string) (*ZoneDetails, error) { + endpoint := c.baseURL.JoinPath("dnszones", zone) + + req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return nil, err + } + + var details ZoneDetails + err = c.do(req, &details) + if err != nil { + return nil, err + } + + return &details, nil +} + +// ListRecords gets a list of DNS records belonging to the zone. +// https://beta.api.core-networks.de/doc/#functon_dnszones_records +func (c Client) ListRecords(ctx context.Context, zone string) ([]Record, error) { + endpoint := c.baseURL.JoinPath("dnszones", zone, "records") + + req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return nil, err + } + + var records []Record + err = c.do(req, &records) + if err != nil { + return nil, err + } + + return records, nil +} + +// AddRecord adds a record. +// https://beta.api.core-networks.de/doc/#functon_dnszones_records_add +func (c Client) AddRecord(ctx context.Context, zone string, record Record) error { + endpoint := c.baseURL.JoinPath("dnszones", zone, "records", "/") + + if record.Name == "" { + record.Name = "@" + } + + req, err := newJSONRequest(ctx, http.MethodPost, endpoint, record) + if err != nil { + return err + } + + err = c.do(req, nil) + if err != nil { + return err + } + + return nil +} + +// DeleteRecords deletes all DNS records of a zone that match the DNS record passed. +// https://beta.api.core-networks.de/doc/#functon_dnszones_records_delete +func (c Client) DeleteRecords(ctx context.Context, zone string, record Record) error { + endpoint := c.baseURL.JoinPath("dnszones", zone, "records", "delete") + + if record.Name == "" { + record.Name = "@" + } + + req, err := newJSONRequest(ctx, http.MethodPost, endpoint, record) + if err != nil { + return err + } + + err = c.do(req, nil) + if err != nil { + return err + } + + return nil +} + +// CommitRecords sends a commit to the zone. +// https://beta.api.core-networks.de/doc/#functon_dnszones_commit +func (c Client) CommitRecords(ctx context.Context, zone string) error { + endpoint := c.baseURL.JoinPath("dnszones", zone, "records", "commit") + + req, err := newJSONRequest(ctx, http.MethodPost, endpoint, nil) + if err != nil { + return err + } + + err = c.do(req, nil) + if err != nil { + return err + } + + return nil +} + +func (c Client) do(req *http.Request, result any) error { + at := getToken(req.Context()) + if at != "" { + req.Header.Set(authorizationHeader, "Bearer "+at) + } + + resp, errD := c.HTTPClient.Do(req) + if errD != nil { + return errutils.NewHTTPDoError(req, errD) + } + + defer func() { _ = resp.Body.Close() }() + + if resp.StatusCode/100 != 2 { + return errutils.NewUnexpectedResponseStatusCodeError(req, resp) + } + + if result == nil { + return nil + } + + raw, err := io.ReadAll(resp.Body) + if err != nil { + return errutils.NewReadResponseError(req, resp.StatusCode, err) + } + + err = json.Unmarshal(raw, result) + if err != nil { + return errutils.NewUnmarshalError(req, resp.StatusCode, raw, err) + } + + return nil +} + +func newJSONRequest(ctx context.Context, method string, endpoint *url.URL, payload any) (*http.Request, error) { + buf := new(bytes.Buffer) + + if payload != nil { + err := json.NewEncoder(buf).Encode(payload) + if err != nil { + return nil, fmt.Errorf("failed to create request JSON body: %w", err) + } + } + + req, err := http.NewRequestWithContext(ctx, method, endpoint.String(), buf) + if err != nil { + return nil, fmt.Errorf("unable to create request: %w", err) + } + + req.Header.Set("Accept", "application/json") + + if payload != nil { + req.Header.Set("Content-Type", "application/json") + } + + return req, nil +} diff --git a/providers/dns/corenetworks/internal/client_test.go b/providers/dns/corenetworks/internal/client_test.go new file mode 100644 index 0000000000..0fff0d5ae9 --- /dev/null +++ b/providers/dns/corenetworks/internal/client_test.go @@ -0,0 +1,214 @@ +package internal + +import ( + "context" + "fmt" + "io" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func setupTest(t *testing.T) (*Client, *http.ServeMux) { + t.Helper() + + mux := http.NewServeMux() + server := httptest.NewServer(mux) + t.Cleanup(server.Close) + + client := NewClient("user", "secret") + client.baseURL, _ = url.Parse(server.URL) + client.HTTPClient = server.Client() + + return client, mux +} + +func testHandler(method string, statusCode int, filename string) http.HandlerFunc { + return func(rw http.ResponseWriter, req *http.Request) { + if req.Method != method { + http.Error(rw, fmt.Sprintf(`unsupported method: %s`, req.Method), http.StatusMethodNotAllowed) + return + } + + rw.WriteHeader(statusCode) + + if statusCode == http.StatusNoContent { + return + } + + file, err := os.Open(filepath.Join("fixtures", filename)) + if err != nil { + http.Error(rw, fmt.Sprintf(`message %v`, err), http.StatusInternalServerError) + return + } + + defer func() { _ = file.Close() }() + + _, err = io.Copy(rw, file) + if err != nil { + http.Error(rw, fmt.Sprintf(`message %v`, err), http.StatusInternalServerError) + return + } + } +} + +func testHandlerAuth(method string, statusCode int, filename string) http.HandlerFunc { + return func(rw http.ResponseWriter, req *http.Request) { + if req.Method != method { + http.Error(rw, fmt.Sprintf(`{"message":"unsupported method: %s"}`, req.Method), http.StatusMethodNotAllowed) + return + } + + rw.WriteHeader(statusCode) + + if statusCode == http.StatusNoContent { + return + } + + file, err := os.Open(filepath.Join("fixtures", filename)) + if err != nil { + http.Error(rw, fmt.Sprintf(`{"message":"%v"}`, err), http.StatusInternalServerError) + return + } + + defer func() { _ = file.Close() }() + + _, err = io.Copy(rw, file) + if err != nil { + http.Error(rw, fmt.Sprintf(`{"message":"%v"}`, err), http.StatusInternalServerError) + return + } + } +} + +func TestClient_CreateAuthenticationToken(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/auth/token", testHandlerAuth(http.MethodPost, http.StatusOK, "auth.json")) + + ctx := context.Background() + + token, err := client.CreateAuthenticationToken(ctx) + require.NoError(t, err) + + expected := &Token{ + Token: "authsecret", + Expires: 123, + } + assert.Equal(t, expected, token) +} + +func TestClient_ListZone(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/dnszones/", testHandler(http.MethodGet, http.StatusOK, "ListZone.json")) + + ctx := context.Background() + + zones, err := client.ListZone(ctx) + require.NoError(t, err) + + expected := []Zone{ + {Name: "example.com", Type: "master"}, + {Name: "example.net", Type: "slave"}, + } + + assert.Equal(t, expected, zones) +} + +func TestClient_GetZoneDetails(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/dnszones/example.com", testHandler(http.MethodGet, http.StatusOK, "GetZoneDetails.json")) + + ctx := context.Background() + + zone, err := client.GetZoneDetails(ctx, "example.com") + require.NoError(t, err) + + expected := &ZoneDetails{ + Active: true, + DNSSec: true, + Name: "example.com", + Type: "master", + } + + assert.Equal(t, expected, zone) +} + +func TestClient_ListRecords(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/dnszones/example.com/records/", testHandler(http.MethodGet, http.StatusOK, "ListRecords.json")) + + ctx := context.Background() + + records, err := client.ListRecords(ctx, "example.com") + require.NoError(t, err) + + expected := []Record{ + { + Name: "@", + TTL: 86400, + Type: "NS", + Data: "ns2.core-networks.eu.", + }, + { + Name: "@", + TTL: 86400, + Type: "NS", + Data: "ns3.core-networks.com.", + }, + { + Name: "@", + TTL: 86400, + Type: "NS", + Data: "ns1.core-networks.de.", + }, + } + + assert.Equal(t, expected, records) +} + +func TestClient_AddRecord(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/dnszones/example.com/records/", testHandler(http.MethodPost, http.StatusNoContent, "")) + + ctx := context.Background() + + record := Record{Name: "www", TTL: 3600, Type: "A", Data: "127.0.0.1"} + + err := client.AddRecord(ctx, "example.com", record) + require.NoError(t, err) +} + +func TestClient_DeleteRecords(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/dnszones/example.com/records/delete", testHandler(http.MethodPost, http.StatusNoContent, "")) + + ctx := context.Background() + + record := Record{Name: "www", Type: "A", Data: "127.0.0.1"} + + err := client.DeleteRecords(ctx, "example.com", record) + require.NoError(t, err) +} + +func TestClient_CommitRecords(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/dnszones/example.com/records/commit", testHandler(http.MethodPost, http.StatusNoContent, "")) + + ctx := context.Background() + + err := client.CommitRecords(ctx, "example.com") + require.NoError(t, err) +} diff --git a/providers/dns/corenetworks/internal/fixtures/GetZoneDetails.json b/providers/dns/corenetworks/internal/fixtures/GetZoneDetails.json new file mode 100644 index 0000000000..1fce07238b --- /dev/null +++ b/providers/dns/corenetworks/internal/fixtures/GetZoneDetails.json @@ -0,0 +1,8 @@ +{ + "active": true, + "dnssec": true, + "master": null, + "name": "example.com", + "tsig": null, + "type": "master" +} diff --git a/providers/dns/corenetworks/internal/fixtures/ListRecords.json b/providers/dns/corenetworks/internal/fixtures/ListRecords.json new file mode 100644 index 0000000000..a09ff9c1a2 --- /dev/null +++ b/providers/dns/corenetworks/internal/fixtures/ListRecords.json @@ -0,0 +1,20 @@ +[ + { + "name": "@", + "ttl": 86400, + "type": "NS", + "data": "ns2.core-networks.eu." + }, + { + "name": "@", + "ttl": 86400, + "type": "NS", + "data": "ns3.core-networks.com." + }, + { + "name": "@", + "ttl": 86400, + "type": "NS", + "data": "ns1.core-networks.de." + } +] diff --git a/providers/dns/corenetworks/internal/fixtures/ListZone.json b/providers/dns/corenetworks/internal/fixtures/ListZone.json new file mode 100644 index 0000000000..7263808739 --- /dev/null +++ b/providers/dns/corenetworks/internal/fixtures/ListZone.json @@ -0,0 +1,10 @@ +[ + { + "name": "example.com", + "type": "master" + }, + { + "name": "example.net", + "type": "slave" + } +] diff --git a/providers/dns/corenetworks/internal/fixtures/auth.json b/providers/dns/corenetworks/internal/fixtures/auth.json new file mode 100644 index 0000000000..399a180076 --- /dev/null +++ b/providers/dns/corenetworks/internal/fixtures/auth.json @@ -0,0 +1,4 @@ +{ + "token": "authsecret", + "expires": 123 +} diff --git a/providers/dns/corenetworks/internal/identity.go b/providers/dns/corenetworks/internal/identity.go new file mode 100644 index 0000000000..6a3b4d46ad --- /dev/null +++ b/providers/dns/corenetworks/internal/identity.go @@ -0,0 +1,49 @@ +package internal + +import ( + "context" + "net/http" +) + +const authorizationHeader = "Authorization" + +type token string + +const tokenKey token = "token" + +// CreateAuthenticationToken gets an authentication token. +// https://beta.api.core-networks.de/doc/#functon_auth_token +func (c Client) CreateAuthenticationToken(ctx context.Context) (*Token, error) { + endpoint := c.baseURL.JoinPath("auth", "token") + + req, err := newJSONRequest(ctx, http.MethodPost, endpoint, Auth{Login: c.login, Password: c.password}) + if err != nil { + return nil, err + } + + var token Token + err = c.do(req, &token) + if err != nil { + return nil, err + } + + return &token, nil +} + +func (c Client) CreateAuthenticatedContext(ctx context.Context) (context.Context, error) { + tok, err := c.CreateAuthenticationToken(ctx) + if err != nil { + return nil, err + } + + return context.WithValue(ctx, tokenKey, tok.Token), nil +} + +func getToken(ctx context.Context) string { + tok, ok := ctx.Value(tokenKey).(string) + if !ok { + return "" + } + + return tok +} diff --git a/providers/dns/corenetworks/internal/types.go b/providers/dns/corenetworks/internal/types.go new file mode 100644 index 0000000000..77b0378c25 --- /dev/null +++ b/providers/dns/corenetworks/internal/types.go @@ -0,0 +1,37 @@ +package internal + +type Auth struct { + Login string `json:"login,omitempty"` + Password string `json:"password,omitempty"` +} + +type Token struct { + Token string `json:"token,omitempty"` + Expires int `json:"expires,omitempty"` +} + +type Zone struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` +} + +type ZoneDetails struct { + Active bool `json:"active,omitempty"` + DNSSec bool `json:"dnssec,omitempty"` + Master string `json:"master,omitempty"` + Name string `json:"name,omitempty"` + TSIG *TSIGKey `json:"tsig,omitempty"` + Type string `json:"type,omitempty"` +} + +type TSIGKey struct { + Algo string `json:"algo,omitempty"` + Secret string `json:"secret,omitempty"` +} + +type Record struct { + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Type string `json:"type,omitempty"` + Data string `json:"data,omitempty"` +} diff --git a/providers/dns/zz_gen_dns_providers.go b/providers/dns/zz_gen_dns_providers.go index 5c805e770d..af6b8982a0 100644 --- a/providers/dns/zz_gen_dns_providers.go +++ b/providers/dns/zz_gen_dns_providers.go @@ -28,6 +28,7 @@ import ( "github.com/go-acme/lego/v4/providers/dns/cloudxns" "github.com/go-acme/lego/v4/providers/dns/conoha" "github.com/go-acme/lego/v4/providers/dns/constellix" + "github.com/go-acme/lego/v4/providers/dns/corenetworks" "github.com/go-acme/lego/v4/providers/dns/cpanel" "github.com/go-acme/lego/v4/providers/dns/derak" "github.com/go-acme/lego/v4/providers/dns/desec" @@ -194,6 +195,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) { return conoha.NewDNSProvider() case "constellix": return constellix.NewDNSProvider() + case "corenetworks": + return corenetworks.NewDNSProvider() case "cpanel": return cpanel.NewDNSProvider() case "derak":