namecheap: add sandbox support. (#1041)

This commit is contained in:
Ludovic Fernandez 2020-01-12 16:51:14 +01:00 committed by GitHub
parent bbc3013d84
commit a10027da1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 5 deletions

View file

@ -946,6 +946,7 @@ func displayDNSHelp(name string) error {
ew.writeln(` - "NAMECHEAP_HTTP_TIMEOUT": API request timeout`) ew.writeln(` - "NAMECHEAP_HTTP_TIMEOUT": API request timeout`)
ew.writeln(` - "NAMECHEAP_POLLING_INTERVAL": Time between DNS propagation check`) ew.writeln(` - "NAMECHEAP_POLLING_INTERVAL": Time between DNS propagation check`)
ew.writeln(` - "NAMECHEAP_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) ew.writeln(` - "NAMECHEAP_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
ew.writeln(` - "NAMECHEAP_SANDBOX": Activate the sandbox (boolean)`)
ew.writeln(` - "NAMECHEAP_TTL": The TTL of the TXT record used for the DNS challenge`) ew.writeln(` - "NAMECHEAP_TTL": The TTL of the TXT record used for the DNS challenge`)
ew.writeln() ew.writeln()

View file

@ -18,9 +18,13 @@ Configuration for [Namecheap](https://www.namecheap.com).
- Code: `namecheap` - Code: `namecheap`
{{% notice note %}} Here is an example bash command using the Namecheap provider:
_Please contribute by adding a CLI example._
{{% /notice %}} ```bash
NAMECHEAP_API_USER=user \
NAMECHEAP_API_KEY=key \
lego --dns namecheap --email someaccount@email.com --domains "foo.email.com" run
```
@ -43,6 +47,7 @@ More information [here](/lego/dns/#configuration-and-credentials).
| `NAMECHEAP_HTTP_TIMEOUT` | API request timeout | | `NAMECHEAP_HTTP_TIMEOUT` | API request timeout |
| `NAMECHEAP_POLLING_INTERVAL` | Time between DNS propagation check | | `NAMECHEAP_POLLING_INTERVAL` | Time between DNS propagation check |
| `NAMECHEAP_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | | `NAMECHEAP_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
| `NAMECHEAP_SANDBOX` | Activate the sandbox (boolean) |
| `NAMECHEAP_TTL` | The TTL of the TXT record used for the DNS challenge | | `NAMECHEAP_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. The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.

View file

@ -30,6 +30,7 @@ import (
const ( const (
defaultBaseURL = "https://api.namecheap.com/xml.response" defaultBaseURL = "https://api.namecheap.com/xml.response"
sandboxBaseURL = "https://api.sandbox.namecheap.com/xml.response"
getIPURL = "https://dynamicdns.park-your-domain.com/getip" getIPURL = "https://dynamicdns.park-your-domain.com/getip"
) )
@ -60,8 +61,13 @@ type Config struct {
// NewDefaultConfig returns a default configuration for the DNSProvider // NewDefaultConfig returns a default configuration for the DNSProvider
func NewDefaultConfig() *Config { func NewDefaultConfig() *Config {
baseURL := defaultBaseURL
if env.GetOrDefaultBool("NAMECHEAP_SANDBOX", false) {
baseURL = sandboxBaseURL
}
return &Config{ return &Config{
BaseURL: defaultBaseURL, BaseURL: baseURL,
Debug: env.GetOrDefaultBool("NAMECHEAP_DEBUG", false), Debug: env.GetOrDefaultBool("NAMECHEAP_DEBUG", false),
TTL: env.GetOrDefaultInt("NAMECHEAP_TTL", dns01.DefaultTTL), TTL: env.GetOrDefaultInt("NAMECHEAP_TTL", dns01.DefaultTTL),
PropagationTimeout: env.GetOrDefaultSecond("NAMECHEAP_PROPAGATION_TIMEOUT", 60*time.Minute), PropagationTimeout: env.GetOrDefaultSecond("NAMECHEAP_PROPAGATION_TIMEOUT", 60*time.Minute),

View file

@ -4,7 +4,11 @@ URL = "https://www.namecheap.com"
Code = "namecheap" Code = "namecheap"
Since = "v0.3.0" Since = "v0.3.0"
Example = '''''' Example = '''
NAMECHEAP_API_USER=user \
NAMECHEAP_API_KEY=key \
lego --dns namecheap --email someaccount@email.com --domains "foo.email.com" run
'''
[Configuration] [Configuration]
[Configuration.Credentials] [Configuration.Credentials]
@ -15,6 +19,7 @@ Example = ''''''
NAMECHEAP_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" NAMECHEAP_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
NAMECHEAP_TTL = "The TTL of the TXT record used for the DNS challenge" NAMECHEAP_TTL = "The TTL of the TXT record used for the DNS challenge"
NAMECHEAP_HTTP_TIMEOUT = "API request timeout" NAMECHEAP_HTTP_TIMEOUT = "API request timeout"
NAMECHEAP_SANDBOX = "Activate the sandbox (boolean)"
[Links] [Links]
API = "https://www.namecheap.com/support/api/methods.aspx" API = "https://www.namecheap.com/support/api/methods.aspx"