Skip to content

Commit

Permalink
cloudxns: provider deprecation (#2324)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Nov 6, 2024
1 parent af7e2ed commit 67230e2
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 787 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns).
<td><a href="https://go-acme.github.io/lego/dns/cloudflare/">Cloudflare</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cloudns/">ClouDNS</a></td>
</tr><tr>
<td><a href="https://go-acme.github.io/lego/dns/cloudxns/">CloudXNS</a></td>
<td><a href="https://go-acme.github.io/lego/dns/cloudxns/">CloudXNS (Deprecated)</a></td>
<td><a href="https://go-acme.github.io/lego/dns/conoha/">ConoHa</a></td>
<td><a href="https://go-acme.github.io/lego/dns/constellix/">Constellix</a></td>
<td><a href="https://go-acme.github.io/lego/dns/corenetworks/">Core-Networks</a></td>
Expand Down
2 changes: 1 addition & 1 deletion cmd/zz_gen_cmd_dnshelp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions docs/content/dns/zz_gen_cloudxns.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
title: "CloudXNS"
title: "CloudXNS (Deprecated)"
date: 2019-03-03T16:39:46+01:00
draft: false
slug: cloudxns
dnsprovider:
since: "v0.5.0"
code: "cloudxns"
url: "https://www.cloudxns.net/"
url: "https://github.com/go-acme/lego/issues/2323"
---

<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/cloudxns/cloudxns.toml -->
<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->

The CloudXNS DNS provider has shut down.

Configuration for [CloudXNS](https://www.cloudxns.net/).


<!--more-->
Expand All @@ -23,7 +23,7 @@ Configuration for [CloudXNS](https://www.cloudxns.net/).
- Since: v0.5.0


Here is an example bash command using the CloudXNS provider:
Here is an example bash command using the CloudXNS (Deprecated) provider:

```bash
CLOUDXNS_API_KEY=xxxx \
Expand Down Expand Up @@ -60,9 +60,6 @@ More information [here]({{% ref "dns#configuration-and-credentials" %}}).



## More information

- [API documentation](https://www.cloudxns.net/Public/Doc/CloudXNS_api2.0_doc_zh-cn.zip)

<!-- THIS DOCUMENTATION IS AUTO-GENERATED. PLEASE DO NOT EDIT. -->
<!-- providers/dns/cloudxns/cloudxns.toml -->
Expand Down
87 changes: 8 additions & 79 deletions providers/dns/cloudxns/cloudxns.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
package cloudxns

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/cloudxns/internal"
)

// Environment variables names.
Expand Down Expand Up @@ -38,101 +34,34 @@ type Config struct {

// NewDefaultConfig returns a default configuration for the DNSProvider.
func NewDefaultConfig() *Config {
return &Config{
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
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
}
type DNSProvider struct{}

// NewDNSProvider returns a DNSProvider instance configured for CloudXNS.
// Credentials must be passed in the environment variables:
// CLOUDXNS_API_KEY and CLOUDXNS_SECRET_KEY.
func NewDNSProvider() (*DNSProvider, error) {
values, err := env.Get(EnvAPIKey, EnvSecretKey)
if err != nil {
return nil, fmt.Errorf("cloudxns: %w", err)
}

config := NewDefaultConfig()
config.APIKey = values[EnvAPIKey]
config.SecretKey = values[EnvSecretKey]

return NewDNSProviderConfig(config)
return NewDNSProviderConfig(&Config{})
}

// NewDNSProviderConfig return a DNSProvider instance configured for CloudXNS.
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("cloudxns: the configuration of the DNS provider is nil")
}

client, err := internal.NewClient(config.APIKey, config.SecretKey)
if err != nil {
return nil, fmt.Errorf("cloudxns: %w", err)
}

if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}

return &DNSProvider{client: client, config: config}, nil
func NewDNSProviderConfig(_ *Config) (*DNSProvider, error) {
return nil, errors.New("cloudxns: provider has shut down")
}

// Present creates a TXT record to fulfill the dns-01 challenge.
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
challengeInfo := dns01.GetChallengeInfo(domain, keyAuth)

ctx := context.Background()

info, err := d.client.GetDomainInformation(ctx, challengeInfo.EffectiveFQDN)
if err != nil {
return fmt.Errorf("cloudxns: %w", err)
}

err = d.client.AddTxtRecord(ctx, info, challengeInfo.EffectiveFQDN, challengeInfo.Value, d.config.TTL)
if err != nil {
return fmt.Errorf("cloudxns: %w", err)
}

func (d *DNSProvider) Present(_, _, _ string) error {
return nil
}

// CleanUp removes the TXT record matching the specified parameters.
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
challengeInfo := dns01.GetChallengeInfo(domain, keyAuth)

ctx := context.Background()

info, err := d.client.GetDomainInformation(ctx, challengeInfo.EffectiveFQDN)
if err != nil {
return fmt.Errorf("cloudxns: %w", err)
}

record, err := d.client.FindTxtRecord(ctx, info.ID, challengeInfo.EffectiveFQDN)
if err != nil {
return fmt.Errorf("cloudxns: %w", err)
}

err = d.client.RemoveTxtRecord(ctx, record.RecordID, info.ID)
if err != nil {
return fmt.Errorf("cloudxns: %w", err)
}

func (d *DNSProvider) CleanUp(_, _, _ string) error {
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
return dns01.DefaultPropagationTimeout, dns01.DefaultPollingInterval
}
11 changes: 5 additions & 6 deletions providers/dns/cloudxns/cloudxns.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Name = "CloudXNS"
Description = """"""
URL = "https://www.cloudxns.net/"
Name = "CloudXNS (Deprecated)"
Description = '''
The CloudXNS DNS provider has shut down.
'''
URL = "https://github.com/go-acme/lego/issues/2323"
Code = "cloudxns"
Since = "v0.5.0"

Expand All @@ -19,6 +21,3 @@ lego --email you@example.com --dns cloudxns --domains my.example.org run
CLOUDXNS_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
CLOUDXNS_TTL = "The TTL of the TXT record used for the DNS challenge"
CLOUDXNS_HTTP_TIMEOUT = "API request timeout"

[Links]
API = "https://www.cloudxns.net/Public/Doc/CloudXNS_api2.0_doc_zh-cn.zip"
152 changes: 0 additions & 152 deletions providers/dns/cloudxns/cloudxns_test.go

This file was deleted.

Loading

0 comments on commit 67230e2

Please sign in to comment.