diff --git a/README.md b/README.md
index cebd033c2c..48a886c81b 100644
--- a/README.md
+++ b/README.md
@@ -67,175 +67,175 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
Bindman |
Bluecat |
+ BookMyName |
Brandit (deprecated) |
Bunny |
Checkdomain |
- Civo |
+ Civo |
Cloud.ru |
CloudDNS |
Cloudflare |
- ClouDNS |
+ ClouDNS |
CloudXNS (Deprecated) |
ConoHa |
Constellix |
- Core-Networks |
+ Core-Networks |
CPanel/WHM |
Derak Cloud |
deSEC.io |
- Designate DNSaaS for Openstack |
+ Designate DNSaaS for Openstack |
Digital Ocean |
DirectAdmin |
DNS Made Easy |
- dnsHome.de |
+ dnsHome.de |
DNSimple |
DNSPod (deprecated) |
Domain Offensive (do.de) |
- Domeneshop |
+ Domeneshop |
DreamHost |
Duck DNS |
Dyn |
- Dynu |
+ Dynu |
EasyDNS |
Efficient IP |
Epik |
- Exoscale |
+ Exoscale |
External program |
freemyip.com |
G-Core |
- Gandi |
+ Gandi |
Gandi Live DNS (v5) |
Glesys |
Go Daddy |
- Google Cloud |
+ Google Cloud |
Google Domains |
Hetzner |
Hosting.de |
- Hosttech |
+ Hosttech |
HTTP request |
http.net |
Huawei Cloud |
- Hurricane Electric DNS |
+ Hurricane Electric DNS |
HyperOne |
IBM Cloud (SoftLayer) |
IIJ DNS Platform Service |
- Infoblox |
+ Infoblox |
Infomaniak |
Internet Initiative Japan |
Internet.bs |
- INWX |
+ INWX |
Ionos |
IPv64 |
iwantmyname |
- Joker |
+ Joker |
Joohoi's ACME-DNS |
Liara |
Lima-City |
- Linode (v4) |
+ Linode (v4) |
Liquid Web |
Loopia |
LuaDNS |
- Mail-in-a-Box |
+ Mail-in-a-Box |
ManageEngine CloudDNS |
Manual |
Metaname |
- mijn.host |
+ mijn.host |
Mittwald |
MyDNS.jp |
MythicBeasts |
- Name.com |
+ Name.com |
Namecheap |
Namesilo |
NearlyFreeSpeech.NET |
- Netcup |
+ Netcup |
Netlify |
Nicmanager |
NIFCloud |
- Njalla |
+ Njalla |
Nodion |
NS1 |
Open Telekom Cloud |
- Oracle Cloud |
+ Oracle Cloud |
OVH |
plesk.com |
Porkbun |
- PowerDNS |
+ PowerDNS |
Rackspace |
Rain Yun/雨云 |
RcodeZero |
- reg.ru |
+ reg.ru |
Regfish |
RFC2136 |
RimuHosting |
- Sakura Cloud |
+ Sakura Cloud |
Scaleway |
Selectel |
Selectel v2 |
- SelfHost.(de|eu) |
+ SelfHost.(de|eu) |
Servercow |
Shellrent |
Simply.com |
- Sonic |
+ Sonic |
Stackpath |
Technitium |
Tencent Cloud DNS |
- Timeweb Cloud |
+ Timeweb Cloud |
TransIP |
UKFast SafeDNS |
Ultradns |
- Variomedia |
+ Variomedia |
VegaDNS |
Vercel |
Versio.[nl|eu|uk] |
- VinylDNS |
+ VinylDNS |
VK Cloud |
Volcano Engine/火山引擎 |
Vscale |
- Vultr |
+ Vultr |
Webnames |
Websupport |
WEDOS |
- West.cn/西部数码 |
+ West.cn/西部数码 |
Yandex 360 |
Yandex Cloud |
Yandex PDD |
- Zone.ee |
+ Zone.ee |
Zonomi |
|
|
- |
diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go
index e5ae3b46d9..610fbc257e 100644
--- a/cmd/zz_gen_cmd_dnshelp.go
+++ b/cmd/zz_gen_cmd_dnshelp.go
@@ -23,6 +23,7 @@ func allDNSCodes() string {
"azuredns",
"bindman",
"bluecat",
+ "bookmyname",
"brandit",
"bunny",
"checkdomain",
@@ -391,6 +392,27 @@ func displayDNSHelp(w io.Writer, name string) error {
ew.writeln()
ew.writeln(`More information: https://go-acme.github.io/lego/dns/bluecat`)
+ case "bookmyname":
+ // generated from: providers/dns/bookmyname/bookmyname.toml
+ ew.writeln(`Configuration for BookMyName.`)
+ ew.writeln(`Code: 'bookmyname'`)
+ ew.writeln(`Since: 'v4.21.0'`)
+ ew.writeln()
+
+ ew.writeln(`Credentials:`)
+ ew.writeln(` - "BOOKMYNAME_PASSWORD": Password`)
+ ew.writeln(` - "BOOKMYNAME_USERNAME": Username`)
+ ew.writeln()
+
+ ew.writeln(`Additional Configuration:`)
+ ew.writeln(` - "BOOKMYNAME_HTTP_TIMEOUT": API request timeout`)
+ ew.writeln(` - "BOOKMYNAME_POLLING_INTERVAL": Time between DNS propagation check`)
+ ew.writeln(` - "BOOKMYNAME_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
+ ew.writeln(` - "BOOKMYNAME_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/bookmyname`)
+
case "brandit":
// generated from: providers/dns/brandit/brandit.toml
ew.writeln(`Configuration for Brandit (deprecated).`)
diff --git a/docs/content/dns/zz_gen_bookmyname.md b/docs/content/dns/zz_gen_bookmyname.md
new file mode 100644
index 0000000000..e323082d9e
--- /dev/null
+++ b/docs/content/dns/zz_gen_bookmyname.md
@@ -0,0 +1,69 @@
+---
+title: "BookMyName"
+date: 2019-03-03T16:39:46+01:00
+draft: false
+slug: bookmyname
+dnsprovider:
+ since: "v4.21.0"
+ code: "bookmyname"
+ url: "https://www.bookmyname.com/"
+---
+
+
+
+
+
+
+Configuration for [BookMyName](https://www.bookmyname.com/).
+
+
+
+
+- Code: `bookmyname`
+- Since: v4.21.0
+
+
+Here is an example bash command using the BookMyName provider:
+
+```bash
+BOOKMYNAME_USERNAME="xxx" \
+BOOKMYNAME_PASSWORD="yyy" \
+lego --email you@example.com --dns bookmyname -d '*.example.com' -d example.com run
+```
+
+
+
+
+## Credentials
+
+| Environment Variable Name | Description |
+|-----------------------|-------------|
+| `BOOKMYNAME_PASSWORD` | Password |
+| `BOOKMYNAME_USERNAME` | 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 |
+|--------------------------------|-------------|
+| `BOOKMYNAME_HTTP_TIMEOUT` | API request timeout |
+| `BOOKMYNAME_POLLING_INTERVAL` | Time between DNS propagation check |
+| `BOOKMYNAME_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
+| `BOOKMYNAME_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://fr.faqs.bookmyname.com/frfaqs/dyndns)
+
+
+
+
diff --git a/docs/data/zz_cli_help.toml b/docs/data/zz_cli_help.toml
index f6674e5e59..311300639d 100644
--- a/docs/data/zz_cli_help.toml
+++ b/docs/data/zz_cli_help.toml
@@ -145,7 +145,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, 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, manageengine, manual, metaname, mijnhost, mittwald, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, 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, stackpath, technitium, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneee, zonomi
+ acme-dns, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, bindman, bluecat, bookmyname, 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, manageengine, manual, metaname, mijnhost, mittwald, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, 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, stackpath, technitium, tencentcloud, timewebcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, volcengine, vscale, vultr, webnames, websupport, wedos, westcn, yandex, yandex360, yandexcloud, zoneee, zonomi
More information: https://go-acme.github.io/lego/dns
"""
diff --git a/providers/dns/bookmyname/bookmyname.go b/providers/dns/bookmyname/bookmyname.go
new file mode 100644
index 0000000000..8d13034731
--- /dev/null
+++ b/providers/dns/bookmyname/bookmyname.go
@@ -0,0 +1,138 @@
+// Package bookmyname implements a DNS provider for solving the DNS-01 challenge using BookMyName.
+package bookmyname
+
+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/bookmyname/internal"
+)
+
+// Environment variables names.
+const (
+ envNamespace = "BOOKMYNAME_"
+
+ 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, dns01.DefaultTTL),
+ 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 BookMyName.
+func NewDNSProvider() (*DNSProvider, error) {
+ values, err := env.Get(EnvUsername, EnvPassword)
+ if err != nil {
+ return nil, fmt.Errorf("bookmyname: %w", err)
+ }
+
+ config := NewDefaultConfig()
+ config.Username = values[EnvUsername]
+ config.Password = values[EnvPassword]
+
+ return NewDNSProviderConfig(config)
+}
+
+// NewDNSProviderConfig return a DNSProvider instance configured for BookMyName.
+func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
+ if config == nil {
+ return nil, errors.New("bookmyname: the configuration of the DNS provider is nil")
+ }
+
+ client, err := internal.NewClient(config.Username, config.Password)
+ if err != nil {
+ return nil, fmt.Errorf("bookmyname: %w", err)
+ }
+
+ if config.HTTPClient != nil {
+ client.HTTPClient = config.HTTPClient
+ }
+
+ return &DNSProvider{
+ config: config,
+ client: client,
+ }, nil
+}
+
+// Present creates a TXT record using the specified parameters.
+func (d *DNSProvider) Present(domain, token, keyAuth string) error {
+ info := dns01.GetChallengeInfo(domain, keyAuth)
+
+ record := internal.Record{
+ Hostname: info.EffectiveFQDN,
+ Type: "txt",
+ TTL: d.config.TTL,
+ Value: info.Value,
+ }
+
+ err := d.client.AddRecord(context.Background(), record)
+ if err != nil {
+ return fmt.Errorf("bookmyname: 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)
+
+ record := internal.Record{
+ Hostname: info.EffectiveFQDN,
+ Type: "txt",
+ TTL: d.config.TTL,
+ Value: info.Value,
+ }
+
+ err := d.client.RemoveRecord(context.Background(), record)
+ if err != nil {
+ return fmt.Errorf("bookmyname: add record: %w", err)
+ }
+
+ return nil
+}
+
+// Timeout returns the timeout and interval to use when checking for DNS propagation.
+// Adjusting here to cope with spikes in propagation times.
+func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
+ return d.config.PropagationTimeout, d.config.PollingInterval
+}
diff --git a/providers/dns/bookmyname/bookmyname.toml b/providers/dns/bookmyname/bookmyname.toml
new file mode 100644
index 0000000000..4e9016d5ed
--- /dev/null
+++ b/providers/dns/bookmyname/bookmyname.toml
@@ -0,0 +1,24 @@
+Name = "BookMyName"
+Description = ''''''
+URL = "https://www.bookmyname.com/"
+Code = "bookmyname"
+Since = "v4.21.0"
+
+Example = '''
+BOOKMYNAME_USERNAME="xxx" \
+BOOKMYNAME_PASSWORD="yyy" \
+lego --email you@example.com --dns bookmyname -d '*.example.com' -d example.com run
+'''
+
+[Configuration]
+ [Configuration.Credentials]
+ BOOKMYNAME_USERNAME = "Username"
+ BOOKMYNAME_PASSWORD = "Password"
+ [Configuration.Additional]
+ BOOKMYNAME_POLLING_INTERVAL = "Time between DNS propagation check"
+ BOOKMYNAME_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
+ BOOKMYNAME_TTL = "The TTL of the TXT record used for the DNS challenge"
+ BOOKMYNAME_HTTP_TIMEOUT = "API request timeout"
+
+[Links]
+ API = "https://fr.faqs.bookmyname.com/frfaqs/dyndns"
diff --git a/providers/dns/bookmyname/bookmyname_test.go b/providers/dns/bookmyname/bookmyname_test.go
new file mode 100644
index 0000000000..dd02d63d75
--- /dev/null
+++ b/providers/dns/bookmyname/bookmyname_test.go
@@ -0,0 +1,143 @@
+package bookmyname
+
+import (
+ "testing"
+
+ "github.com/go-acme/lego/v4/platform/tester"
+ "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: "user",
+ EnvPassword: "secret",
+ },
+ },
+ {
+ desc: "missing username",
+ envVars: map[string]string{
+ EnvUsername: "",
+ EnvPassword: "secret",
+ },
+ expected: "bookmyname: some credentials information are missing: BOOKMYNAME_USERNAME",
+ },
+ {
+ desc: "missing paswword",
+ envVars: map[string]string{
+ EnvUsername: "user",
+ EnvPassword: "",
+ },
+ expected: "bookmyname: some credentials information are missing: BOOKMYNAME_PASSWORD",
+ },
+ {
+ desc: "missing credentials",
+ envVars: map[string]string{},
+ expected: "bookmyname: some credentials information are missing: BOOKMYNAME_USERNAME,BOOKMYNAME_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
+ username string
+ password string
+ expected string
+ }{
+ {
+ desc: "success",
+ username: "user",
+ password: "secret",
+ },
+ {
+ desc: "missing username",
+ password: "secret",
+ expected: "bookmyname: credentials missing",
+ },
+ {
+ desc: "missing password",
+ username: "user",
+ expected: "bookmyname: credentials missing",
+ },
+ {
+ desc: "missing credentials",
+ expected: "bookmyname: credentials missing",
+ },
+ }
+
+ 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)
+ 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/bookmyname/internal/client.go b/providers/dns/bookmyname/internal/client.go
new file mode 100644
index 0000000000..08d4cccce1
--- /dev/null
+++ b/providers/dns/bookmyname/internal/client.go
@@ -0,0 +1,118 @@
+package internal
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "strings"
+ "time"
+
+ "github.com/go-acme/lego/v4/providers/dns/internal/errutils"
+ querystring "github.com/google/go-querystring/query"
+)
+
+const defaultBaseURL = "https://www.bookmyname.com/dyndns/"
+
+// Client the BookMyName API client.
+type Client struct {
+ username string
+ password string
+
+ baseURL string
+ HTTPClient *http.Client
+}
+
+// NewClient creates a new Client.
+func NewClient(username, password string) (*Client, error) {
+ if username == "" || password == "" {
+ return nil, errors.New("credentials missing")
+ }
+
+ return &Client{
+ username: username,
+ password: password,
+ baseURL: defaultBaseURL,
+ HTTPClient: &http.Client{Timeout: 10 * time.Second},
+ }, nil
+}
+
+func (c *Client) AddRecord(ctx context.Context, record Record) error {
+ endpoint, err := c.createEndpoint(record, "add")
+ if err != nil {
+ return err
+ }
+
+ err = c.do(ctx, endpoint)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (c *Client) RemoveRecord(ctx context.Context, record Record) error {
+ endpoint, err := c.createEndpoint(record, "remove")
+ if err != nil {
+ return err
+ }
+
+ err = c.do(ctx, endpoint)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (c *Client) createEndpoint(record Record, action string) (*url.URL, error) {
+ endpoint, err := url.Parse(c.baseURL)
+ if err != nil {
+ return nil, fmt.Errorf("parse URL: %w", err)
+ }
+
+ values, err := querystring.Values(record)
+ if err != nil {
+ return nil, fmt.Errorf("query parameters: %w", err)
+ }
+
+ values.Set("do", action)
+
+ endpoint.RawQuery = values.Encode()
+
+ return endpoint, nil
+}
+
+func (c *Client) do(ctx context.Context, endpoint *url.URL) error {
+ endpoint.User = url.UserPassword(c.username, c.password)
+
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), http.NoBody)
+ if err != nil {
+ return fmt.Errorf("unable to create request: %w", err)
+ }
+
+ resp, err := c.HTTPClient.Do(req)
+ if err != nil {
+ return errutils.NewHTTPDoError(req, err)
+ }
+
+ defer func() { _ = resp.Body.Close() }()
+
+ raw, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return errutils.NewReadResponseError(req, resp.StatusCode, err)
+ }
+
+ if resp.StatusCode/100 != 2 {
+ return errutils.NewUnexpectedStatusCodeError(req, resp.StatusCode, raw)
+ }
+
+ if !strings.HasPrefix(string(raw), "good: update done") && !strings.HasPrefix(string(raw), "good: remove done") {
+ return fmt.Errorf("unexpected response: %s", string(bytes.TrimSpace(raw)))
+ }
+
+ return nil
+}
diff --git a/providers/dns/bookmyname/internal/client_test.go b/providers/dns/bookmyname/internal/client_test.go
new file mode 100644
index 0000000000..dab559ceef
--- /dev/null
+++ b/providers/dns/bookmyname/internal/client_test.go
@@ -0,0 +1,113 @@
+package internal
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func setupTest(t *testing.T, filename string) *Client {
+ t.Helper()
+
+ mux := http.NewServeMux()
+ server := httptest.NewServer(mux)
+ t.Cleanup(server.Close)
+
+ mux.HandleFunc("GET /", func(rw http.ResponseWriter, req *http.Request) {
+ username, password, ok := req.BasicAuth()
+ if username != "user" || password != "secret" || !ok {
+ http.Error(rw, fmt.Sprintf("auth: user %s, password %s, malformed", username, password), http.StatusOK)
+ return
+ }
+
+ file, err := os.Open(filepath.Join("fixtures", filename))
+ if err != nil {
+ http.Error(rw, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ defer func() { _ = file.Close() }()
+
+ rw.WriteHeader(http.StatusOK)
+ _, err = io.Copy(rw, file)
+ if err != nil {
+ http.Error(rw, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ })
+
+ client, err := NewClient("user", "secret")
+ require.NoError(t, err)
+
+ client.HTTPClient = server.Client()
+ client.baseURL = server.URL
+
+ return client
+}
+
+func TestClient_AddRecord(t *testing.T) {
+ client := setupTest(t, "add_success.txt")
+
+ record := Record{
+ Hostname: "_acme-challenge.sub.example.com.",
+ Type: "txt",
+ TTL: 300,
+ Value: "test",
+ }
+
+ err := client.AddRecord(context.Background(), record)
+ require.NoError(t, err)
+}
+
+func TestClient_AddRecord_error(t *testing.T) {
+ client := setupTest(t, "error.txt")
+
+ record := Record{
+ Hostname: "_acme-challenge.sub.example.com.",
+ Type: "txt",
+ TTL: 300,
+ Value: "test",
+ }
+
+ err := client.AddRecord(context.Background(), record)
+ require.Error(t, err)
+
+ require.EqualError(t, err, "unexpected response: notfqdn: Host _acme-challenge.sub.example.com. malformed / vhn")
+}
+
+func TestClient_RemoveRecord(t *testing.T) {
+ client := setupTest(t, "remove_success.txt")
+
+ record := Record{
+ Hostname: "_acme-challenge.sub.example.com.",
+ Type: "txt",
+ TTL: 300,
+ Value: "test",
+ }
+
+ err := client.RemoveRecord(context.Background(), record)
+ require.NoError(t, err)
+}
+
+func TestClient_RemoveRecord_error(t *testing.T) {
+ client := setupTest(t, "error.txt")
+
+ record := Record{
+ Hostname: "_acme-challenge.sub.example.com.",
+ Type: "txt",
+ TTL: 300,
+ Value: "test",
+ }
+
+ err := client.RemoveRecord(context.Background(), record)
+ require.Error(t, err)
+
+ require.EqualError(t, err, "unexpected response: notfqdn: Host _acme-challenge.sub.example.com. malformed / vhn")
+}
diff --git a/providers/dns/bookmyname/internal/fixtures/add_success.txt b/providers/dns/bookmyname/internal/fixtures/add_success.txt
new file mode 100644
index 0000000000..76304fc243
--- /dev/null
+++ b/providers/dns/bookmyname/internal/fixtures/add_success.txt
@@ -0,0 +1 @@
+good: update done, cid 123, domain id 456, type txt, ip xxx
diff --git a/providers/dns/bookmyname/internal/fixtures/error.txt b/providers/dns/bookmyname/internal/fixtures/error.txt
new file mode 100644
index 0000000000..3c62ede60f
--- /dev/null
+++ b/providers/dns/bookmyname/internal/fixtures/error.txt
@@ -0,0 +1 @@
+notfqdn: Host _acme-challenge.sub.example.com. malformed / vhn
diff --git a/providers/dns/bookmyname/internal/fixtures/remove_success.txt b/providers/dns/bookmyname/internal/fixtures/remove_success.txt
new file mode 100644
index 0000000000..1e83c6dccd
--- /dev/null
+++ b/providers/dns/bookmyname/internal/fixtures/remove_success.txt
@@ -0,0 +1 @@
+good: remove done 1, cid 123, domain id 456, ttl 300, type txt, ip xxx
diff --git a/providers/dns/bookmyname/internal/types.go b/providers/dns/bookmyname/internal/types.go
new file mode 100644
index 0000000000..96dab064ac
--- /dev/null
+++ b/providers/dns/bookmyname/internal/types.go
@@ -0,0 +1,8 @@
+package internal
+
+type Record struct {
+ Hostname string `url:"hostname"`
+ Type string `url:"type"`
+ TTL int `url:"ttl"`
+ Value string `url:"value"`
+}
diff --git a/providers/dns/zz_gen_dns_providers.go b/providers/dns/zz_gen_dns_providers.go
index 053c3c4e7b..ebf999bec6 100644
--- a/providers/dns/zz_gen_dns_providers.go
+++ b/providers/dns/zz_gen_dns_providers.go
@@ -17,6 +17,7 @@ import (
"github.com/go-acme/lego/v4/providers/dns/azuredns"
"github.com/go-acme/lego/v4/providers/dns/bindman"
"github.com/go-acme/lego/v4/providers/dns/bluecat"
+ "github.com/go-acme/lego/v4/providers/dns/bookmyname"
"github.com/go-acme/lego/v4/providers/dns/brandit"
"github.com/go-acme/lego/v4/providers/dns/bunny"
"github.com/go-acme/lego/v4/providers/dns/checkdomain"
@@ -178,6 +179,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
return bindman.NewDNSProvider()
case "bluecat":
return bluecat.NewDNSProvider()
+ case "bookmyname":
+ return bookmyname.NewDNSProvider()
case "brandit":
return brandit.NewDNSProvider()
case "bunny":