iwantmyname: provider deprecation (#2694)

This commit is contained in:
Ludovic Fernandez 2025-10-29 19:39:54 +01:00 committed by GitHub
commit 5dba10703f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 15 additions and 331 deletions

View file

@ -161,7 +161,7 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/ionos/">Ionos</a></td>
<td><a href="https://go-acme.github.io/lego/dns/ipv64/">IPv64</a></td>
<td><a href="https://go-acme.github.io/lego/dns/iwantmyname/">iwantmyname</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>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/acme-dns/">Joohoi&#39;s ACME-DNS</a></td>

View file

@ -1946,7 +1946,7 @@ func displayDNSHelp(w io.Writer, name string) error {
case "iwantmyname":
// generated from: providers/dns/iwantmyname/iwantmyname.toml
ew.writeln(`Configuration for iwantmyname.`)
ew.writeln(`Configuration for iwantmyname (Deprecated).`)
ew.writeln(`Code: 'iwantmyname'`)
ew.writeln(`Since: 'v4.7.0'`)
ew.writeln()

View file

@ -1,5 +1,5 @@
---
title: "iwantmyname"
title: "iwantmyname (Deprecated)"
date: 2019-03-03T16:39:46+01:00
draft: false
slug: iwantmyname
@ -13,8 +13,10 @@ dnsprovider:
<!-- providers/dns/iwantmyname/iwantmyname.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
The iwantmyname API has shut down.
https://github.com/go-acme/lego/issues/2563
Configuration for [iwantmyname](https://iwantmyname.com).
<!--more-->
@ -23,7 +25,7 @@ Configuration for [iwantmyname](https://iwantmyname.com).
- Since: v4.7.0
Here is an example bash command using the iwantmyname provider:
Here is an example bash command using the iwantmyname (Deprecated) provider:
```bash
IWANTMYNAME_USERNAME=xxxxxxxx \

View file

@ -1,66 +0,0 @@
package internal
import (
"context"
"fmt"
"net/http"
"net/url"
"time"
"github.com/go-acme/lego/v4/providers/dns/internal/errutils"
querystring "github.com/google/go-querystring/query"
)
const defaultBaseURL = "https://iwantmyname.com/basicauth/ddns"
// Client iwantmyname client.
type Client struct {
username string
password string
baseURL *url.URL
HTTPClient *http.Client
}
// NewClient creates a new Client.
func NewClient(username, password string) *Client {
baseURL, _ := url.Parse(defaultBaseURL)
return &Client{
username: username,
password: password,
baseURL: baseURL,
HTTPClient: &http.Client{Timeout: 10 * time.Second},
}
}
// SendRequest send a request (create/add/delete) to the API.
func (c *Client) SendRequest(ctx context.Context, record Record) error {
values, err := querystring.Values(record)
if err != nil {
return err
}
endpoint := c.baseURL
endpoint.RawQuery = values.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), http.NoBody)
if err != nil {
return fmt.Errorf("unable to create request: %w", err)
}
req.SetBasicAuth(c.username, c.password)
resp, err := c.HTTPClient.Do(req)
if err != nil {
return errutils.NewHTTPDoError(req, err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode/100 != 2 {
return errutils.NewUnexpectedResponseStatusCodeError(req, resp)
}
return nil
}

View file

@ -1,46 +0,0 @@
package internal
import (
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"github.com/go-acme/lego/v4/platform/tester/servermock"
"github.com/stretchr/testify/require"
)
func setupClient(server *httptest.Server) (*Client, error) {
client := NewClient("user", "secret")
client.HTTPClient = server.Client()
client.baseURL, _ = url.Parse(server.URL)
return client, nil
}
func TestClient_Do(t *testing.T) {
client := servermock.NewBuilder[*Client](setupClient,
servermock.CheckHeader().
WithBasicAuth("user", "secret"),
).
Route("POST /", http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
fmt.Println(req)
}),
servermock.CheckQueryParameter().Strict().
With("hostname", "example.com").
With("ttl", "120").
With("type", "TXT").
With("value", "data")).
Build(t)
record := Record{
Hostname: "example.com",
Type: "TXT",
Value: "data",
TTL: 120,
}
err := client.SendRequest(t.Context(), record)
require.NoError(t, err)
}

View file

@ -1,9 +0,0 @@
package internal
// Record represents a record.
type Record struct {
Hostname string `url:"hostname,omitempty"`
Type string `url:"type,omitempty"`
Value string `url:"value,omitempty"`
TTL int `url:"ttl,omitempty"`
}

View file

@ -2,17 +2,13 @@
package iwantmyname
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/iwantmyname/internal"
)
// Environment variables names.
@ -42,20 +38,12 @@ type Config struct {
// 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),
},
}
return &Config{}
}
// DNSProvider implements the challenge.Provider interface.
type DNSProvider struct {
config *Config
client *internal.Client
}
// NewDNSProvider returns a DNSProvider instance configured for iwantmyname.
@ -75,26 +63,7 @@ func NewDNSProvider() (*DNSProvider, error) {
// NewDNSProviderConfig return a DNSProvider instance configured for iwantmyname.
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("iwantmyname: the configuration of the DNS provider is nil")
}
if config.Username == "" || config.Password == "" {
return nil, errors.New("iwantmyname: credentials missing")
}
client := internal.NewClient(config.Username, config.Password)
if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}
client.HTTPClient = clientdebug.Wrap(client.HTTPClient)
return &DNSProvider{
config: config,
client: client,
}, nil
return nil, errors.New("iwantmyname: the iwantmyname API has shut down https://github.com/go-acme/lego/issues/2563")
}
// Timeout returns the timeout and interval to use when checking for DNS propagation.
@ -105,38 +74,10 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
// Present creates a TXT record using the specified parameters.
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
info := dns01.GetChallengeInfo(domain, keyAuth)
record := internal.Record{
Hostname: dns01.UnFqdn(info.EffectiveFQDN),
Type: "TXT",
Value: info.Value,
TTL: d.config.TTL,
}
err := d.client.SendRequest(context.Background(), record)
if err != nil {
return fmt.Errorf("iwantmyname: %w", err)
}
return nil
}
// CleanUp removes the TXT record matching the specified parameters.
func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
info := dns01.GetChallengeInfo(domain, keyAuth)
record := internal.Record{
Hostname: dns01.UnFqdn(info.EffectiveFQDN),
Type: "TXT",
Value: "delete",
TTL: d.config.TTL,
}
err := d.client.SendRequest(context.Background(), record)
if err != nil {
return fmt.Errorf("iwantmyname: %w", err)
}
return nil
}

View file

@ -1,5 +1,9 @@
Name = "iwantmyname"
Description = ''''''
Name = "iwantmyname (Deprecated)"
Description = '''
The iwantmyname API has shut down.
https://github.com/go-acme/lego/issues/2563
'''
URL = "https://iwantmyname.com"
Code = "iwantmyname"
Since = "v4.7.0"

View file

@ -1,142 +0,0 @@
package iwantmyname
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 credentials",
envVars: map[string]string{},
expected: "iwantmyname: some credentials information are missing: IWANTMYNAME_USERNAME,IWANTMYNAME_PASSWORD",
},
{
desc: "missing username",
envVars: map[string]string{
EnvPassword: "secret",
},
expected: "iwantmyname: some credentials information are missing: IWANTMYNAME_USERNAME",
},
{
desc: "missing password",
envVars: map[string]string{
EnvUsername: "user",
},
expected: "iwantmyname: some credentials information are missing: IWANTMYNAME_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 credentials",
expected: "iwantmyname: credentials missing",
},
{
desc: "missing username",
password: "secret",
expected: "iwantmyname: credentials missing",
},
{
desc: "missing password",
username: "user",
expected: "iwantmyname: 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)
}