forked from TrueCloudLab/lego
chore: update linter. (#1145)
This commit is contained in:
parent
e90786484a
commit
6043c9347c
131 changed files with 579 additions and 576 deletions
|
@ -34,6 +34,9 @@
|
||||||
"stylecheck",
|
"stylecheck",
|
||||||
"godox",
|
"godox",
|
||||||
"gomnd",
|
"gomnd",
|
||||||
|
"testpackage", # not relevant
|
||||||
|
"nestif", # too many false-positive
|
||||||
|
"goerr113", # not relevant
|
||||||
]
|
]
|
||||||
|
|
||||||
[issues]
|
[issues]
|
||||||
|
|
|
@ -143,7 +143,7 @@ func (a *Core) signEABContent(newAccountURL, kid string, hmac []byte) ([]byte, e
|
||||||
return []byte(eabJWS.FullSerialize()), nil
|
return []byte(eabJWS.FullSerialize()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetKeyAuthorization Gets the key authorization
|
// GetKeyAuthorization Gets the key authorization.
|
||||||
func (a *Core) GetKeyAuthorization(token string) (string, error) {
|
func (a *Core) GetKeyAuthorization(token string) (string, error) {
|
||||||
return a.jws.GetKeyAuthorization(token)
|
return a.jws.GetKeyAuthorization(token)
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (c *CertificateService) get(certURL string) ([]byte, string, error) {
|
||||||
return cert, up, err
|
return cert, up, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// getIssuerFromLink requests the issuer certificate
|
// getIssuerFromLink requests the issuer certificate.
|
||||||
func (c *CertificateService) getIssuerFromLink(up string) ([]byte, error) {
|
func (c *CertificateService) getIssuerFromLink(up string) ([]byte, error) {
|
||||||
if len(up) == 0 {
|
if len(up) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (n *Manager) Push(nonce string) {
|
||||||
n.nonces = append(n.nonces, nonce)
|
n.nonces = append(n.nonces, nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nonce implement jose.NonceSource
|
// Nonce implement jose.NonceSource.
|
||||||
func (n *Manager) Nonce() (string, error) {
|
func (n *Manager) Nonce() (string, error) {
|
||||||
if nonce, ok := n.Pop(); ok {
|
if nonce, ok := n.Pop(); ok {
|
||||||
return nonce, nil
|
return nonce, nil
|
||||||
|
|
|
@ -9,7 +9,7 @@ type service struct {
|
||||||
core *Core
|
core *Core
|
||||||
}
|
}
|
||||||
|
|
||||||
// getLink get a rel into the Link header
|
// getLink get a rel into the Link header.
|
||||||
func getLink(header http.Header, rel string) string {
|
func getLink(header http.Header, rel string) string {
|
||||||
var linkExpr = regexp.MustCompile(`<(.+?)>;\s*rel="(.+?)"`)
|
var linkExpr = regexp.MustCompile(`<(.+?)>;\s*rel="(.+?)"`)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func getLink(header http.Header, rel string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// getLocation get the value of the header Location
|
// getLocation get the value of the header Location.
|
||||||
func getLocation(resp *http.Response) string {
|
func getLocation(resp *http.Response) string {
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -35,7 +35,7 @@ func getLocation(resp *http.Response) string {
|
||||||
return resp.Header.Get("Location")
|
return resp.Header.Get("Location")
|
||||||
}
|
}
|
||||||
|
|
||||||
// getRetryAfter get the value of the header Retry-After
|
// getRetryAfter get the value of the header Retry-After.
|
||||||
func getRetryAfter(resp *http.Response) string {
|
func getRetryAfter(resp *http.Response) string {
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Errors types
|
// Errors types.
|
||||||
const (
|
const (
|
||||||
errNS = "urn:ietf:params:acme:error:"
|
errNS = "urn:ietf:params:acme:error:"
|
||||||
BadNonceErr = errNS + "badNonce"
|
BadNonceErr = errNS + "badNonce"
|
||||||
|
|
|
@ -40,7 +40,7 @@ const (
|
||||||
OCSPServerFailed = ocsp.ServerFailed
|
OCSPServerFailed = ocsp.ServerFailed
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constants for OCSP must staple
|
// Constants for OCSP must staple.
|
||||||
var (
|
var (
|
||||||
tlsFeatureExtensionOID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 24}
|
tlsFeatureExtensionOID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 24}
|
||||||
ocspMustStapleFeature = []byte{0x30, 0x03, 0x02, 0x01, 0x05}
|
ocspMustStapleFeature = []byte{0x30, 0x03, 0x02, 0x01, 0x05}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package dns01
|
||||||
|
|
||||||
import "github.com/miekg/dns"
|
import "github.com/miekg/dns"
|
||||||
|
|
||||||
// Update FQDN with CNAME if any
|
// Update FQDN with CNAME if any.
|
||||||
func updateDomainWithCName(r *dns.Msg, fqdn string) string {
|
func updateDomainWithCName(r *dns.Msg, fqdn string) string {
|
||||||
for _, rr := range r.Answer {
|
for _, rr := range r.Answer {
|
||||||
if cn, ok := rr.(*dns.CNAME); ok {
|
if cn, ok := rr.(*dns.CNAME); ok {
|
||||||
|
|
|
@ -42,7 +42,7 @@ func CondOption(condition bool, opt ChallengeOption) ChallengeOption {
|
||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Challenge implements the dns-01 challenge
|
// Challenge implements the dns-01 challenge.
|
||||||
type Challenge struct {
|
type Challenge struct {
|
||||||
core *api.Core
|
core *api.Core
|
||||||
validate ValidateFunc
|
validate ValidateFunc
|
||||||
|
@ -169,7 +169,7 @@ type sequential interface {
|
||||||
Sequential() time.Duration
|
Sequential() time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecord returns a DNS record which will fulfill the `dns-01` challenge
|
// GetRecord returns a DNS record which will fulfill the `dns-01` challenge.
|
||||||
func GetRecord(domain, keyAuth string) (fqdn string, value string) {
|
func GetRecord(domain, keyAuth string) (fqdn string, value string) {
|
||||||
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
|
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
|
||||||
// base64URL encoding without padding
|
// base64URL encoding without padding
|
||||||
|
|
|
@ -11,7 +11,7 @@ const (
|
||||||
dnsTemplate = `%s %d IN TXT "%s"`
|
dnsTemplate = `%s %d IN TXT "%s"`
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSProviderManual is an implementation of the ChallengeProvider interface
|
// DNSProviderManual is an implementation of the ChallengeProvider interface.
|
||||||
type DNSProviderManual struct{}
|
type DNSProviderManual struct{}
|
||||||
|
|
||||||
// NewDNSProviderManual returns a DNSProviderManual instance.
|
// NewDNSProviderManual returns a DNSProviderManual instance.
|
||||||
|
@ -19,7 +19,7 @@ func NewDNSProviderManual() (*DNSProviderManual, error) {
|
||||||
return &DNSProviderManual{}, nil
|
return &DNSProviderManual{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present prints instructions for manually creating the TXT record
|
// Present prints instructions for manually creating the TXT record.
|
||||||
func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
|
func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := GetRecord(domain, keyAuth)
|
fqdn, value := GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp prints instructions for manually removing the TXT record
|
// CleanUp prints instructions for manually removing the TXT record.
|
||||||
func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error {
|
func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := GetRecord(domain, keyAuth)
|
fqdn, _ := GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,10 @@ var defaultNameservers = []string{
|
||||||
"google-public-dns-b.google.com:53",
|
"google-public-dns-b.google.com:53",
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursiveNameservers are used to pre-check DNS propagation
|
// recursiveNameservers are used to pre-check DNS propagation.
|
||||||
var recursiveNameservers = getNameservers(defaultResolvConf, defaultNameservers)
|
var recursiveNameservers = getNameservers(defaultResolvConf, defaultNameservers)
|
||||||
|
|
||||||
// soaCacheEntry holds a cached SOA record (only selected fields)
|
// soaCacheEntry holds a cached SOA record (only selected fields).
|
||||||
type soaCacheEntry struct {
|
type soaCacheEntry struct {
|
||||||
zone string // zone apex (a domain name)
|
zone string // zone apex (a domain name)
|
||||||
primaryNs string // primary nameserver for the zone apex
|
primaryNs string // primary nameserver for the zone apex
|
||||||
|
@ -70,7 +70,7 @@ func AddRecursiveNameservers(nameservers []string) ChallengeOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getNameservers attempts to get systems nameservers before falling back to the defaults
|
// getNameservers attempts to get systems nameservers before falling back to the defaults.
|
||||||
func getNameservers(path string, defaults []string) []string {
|
func getNameservers(path string, defaults []string) []string {
|
||||||
config, err := dns.ClientConfigFromFile(path)
|
config, err := dns.ClientConfigFromFile(path)
|
||||||
if err != nil || len(config.Servers) == 0 {
|
if err != nil || len(config.Servers) == 0 {
|
||||||
|
@ -215,7 +215,7 @@ func fetchSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
|
||||||
return nil, fmt.Errorf("could not find the start of authority for %s%s", fqdn, formatDNSError(in, err))
|
return nil, fmt.Errorf("could not find the start of authority for %s%s", fqdn, formatDNSError(in, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// dnsMsgContainsCNAME checks for a CNAME answer in msg
|
// dnsMsgContainsCNAME checks for a CNAME answer in msg.
|
||||||
func dnsMsgContainsCNAME(msg *dns.Msg) bool {
|
func dnsMsgContainsCNAME(msg *dns.Msg) bool {
|
||||||
for _, ans := range msg.Answer {
|
for _, ans := range msg.Answer {
|
||||||
if _, ok := ans.(*dns.CNAME); ok {
|
if _, ok := ans.(*dns.CNAME); ok {
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (m *forwardedMatcher) matches(r *http.Request, domain string) bool {
|
||||||
return strings.HasPrefix(host, domain)
|
return strings.HasPrefix(host, domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsing requires some form of state machine
|
// parsing requires some form of state machine.
|
||||||
func parseForwardedHeader(s string) (elements []map[string]string, err error) {
|
func parseForwardedHeader(s string) (elements []map[string]string, err error) {
|
||||||
cur := make(map[string]string)
|
cur := make(map[string]string)
|
||||||
key := ""
|
key := ""
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
type ValidateFunc func(core *api.Core, domain string, chlng acme.Challenge) error
|
type ValidateFunc func(core *api.Core, domain string, chlng acme.Challenge) error
|
||||||
|
|
||||||
// ChallengePath returns the URL path for the `http-01` challenge
|
// ChallengePath returns the URL path for the `http-01` challenge.
|
||||||
func ChallengePath(token string) string {
|
func ChallengePath(token string) string {
|
||||||
return "/.well-known/acme-challenge/" + token
|
return "/.well-known/acme-challenge/" + token
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/go-acme/lego/v3/log"
|
"github.com/go-acme/lego/v3/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProviderServer implements ChallengeProvider for `http-01` challenge
|
// ProviderServer implements ChallengeProvider for `http-01` challenge.
|
||||||
// It may be instantiated without using the NewProviderServer function if
|
// It may be instantiated without using the NewProviderServer function if
|
||||||
// you want only to use the default values.
|
// you want only to use the default values.
|
||||||
type ProviderServer struct {
|
type ProviderServer struct {
|
||||||
|
@ -49,7 +49,7 @@ func (s *ProviderServer) GetAddress() string {
|
||||||
return net.JoinHostPort(s.iface, s.port)
|
return net.JoinHostPort(s.iface, s.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp closes the HTTP server and removes the token from `ChallengePath(token)`
|
// CleanUp closes the HTTP server and removes the token from `ChallengePath(token)`.
|
||||||
func (s *ProviderServer) CleanUp(domain, token, keyAuth string) error {
|
func (s *ProviderServer) CleanUp(domain, token, keyAuth string) error {
|
||||||
if s.listener == nil {
|
if s.listener == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -65,12 +65,12 @@ func (s *ProviderServer) CleanUp(domain, token, keyAuth string) error {
|
||||||
// When the server runs behind a proxy server, this is not the correct place to look at;
|
// When the server runs behind a proxy server, this is not the correct place to look at;
|
||||||
// Apache and NGINX have traditionally moved the original Host header into a new header named "X-Forwarded-Host".
|
// Apache and NGINX have traditionally moved the original Host header into a new header named "X-Forwarded-Host".
|
||||||
// Other webservers might use different names;
|
// Other webservers might use different names;
|
||||||
// and RFC7239 has standadized a new header named "Forwarded" (with slightly different semantics).
|
// and RFC7239 has standardized a new header named "Forwarded" (with slightly different semantics).
|
||||||
//
|
//
|
||||||
// The exact behavior depends on the value of headerName:
|
// The exact behavior depends on the value of headerName:
|
||||||
// - "" (the empty string) and "Host" will restore the default and only check the Host header
|
// - "" (the empty string) and "Host" will restore the default and only check the Host header
|
||||||
// - "Forwarded" will look for a Forwarded header, and inspect it according to https://tools.ietf.org/html/rfc7239
|
// - "Forwarded" will look for a Forwarded header, and inspect it according to https://tools.ietf.org/html/rfc7239
|
||||||
// - any other value will check the header value with the same name
|
// - any other value will check the header value with the same name.
|
||||||
func (s *ProviderServer) SetProxyHeader(headerName string) {
|
func (s *ProviderServer) SetProxyHeader(headerName string) {
|
||||||
switch h := textproto.CanonicalMIMEHeaderKey(headerName); h {
|
switch h := textproto.CanonicalMIMEHeaderKey(headerName); h {
|
||||||
case "", "Host":
|
case "", "Host":
|
||||||
|
|
|
@ -29,7 +29,7 @@ type sequential interface {
|
||||||
Sequential() (bool, time.Duration)
|
Sequential() (bool, time.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// an authz with the solver we have chosen and the index of the challenge associated with it
|
// an authz with the solver we have chosen and the index of the challenge associated with it.
|
||||||
type selectedAuthSolver struct {
|
type selectedAuthSolver struct {
|
||||||
authz acme.Authorization
|
authz acme.Authorization
|
||||||
solver solver
|
solver solver
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/go-acme/lego/v3/registration"
|
"github.com/go-acme/lego/v3/registration"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Account represents a users local saved credentials
|
// Account represents a users local saved credentials.
|
||||||
type Account struct {
|
type Account struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Registration *registration.Resource `json:"registration"`
|
Registration *registration.Resource `json:"registration"`
|
||||||
|
@ -15,7 +15,7 @@ type Account struct {
|
||||||
|
|
||||||
/** Implementation of the registration.User interface **/
|
/** Implementation of the registration.User interface **/
|
||||||
|
|
||||||
// GetEmail returns the email address for the account
|
// GetEmail returns the email address for the account.
|
||||||
func (a *Account) GetEmail() string {
|
func (a *Account) GetEmail() string {
|
||||||
return a.Email
|
return a.Email
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func (a *Account) GetPrivateKey() crypto.PrivateKey {
|
||||||
return a.key
|
return a.key
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRegistration returns the server registration
|
// GetRegistration returns the server registration.
|
||||||
func (a *Account) GetRegistration() *registration.Resource {
|
func (a *Account) GetRegistration() *registration.Resource {
|
||||||
return a.Registration
|
return a.Registration
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ func (s *CertificatesStorage) MoveToArchive(domain string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitizedDomain Make sure no funny chars are in the cert names (like wildcards ;))
|
// sanitizedDomain Make sure no funny chars are in the cert names (like wildcards ;)).
|
||||||
func sanitizedDomain(domain string) string {
|
func sanitizedDomain(domain string) string {
|
||||||
safe, err := idna.ToASCII(strings.Replace(domain, "*", "_", -1))
|
safe, err := idna.ToASCII(strings.Replace(domain, "*", "_", -1))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package cmd
|
||||||
|
|
||||||
import "github.com/urfave/cli"
|
import "github.com/urfave/cli"
|
||||||
|
|
||||||
// CreateCommands Creates all CLI commands
|
// CreateCommands Creates all CLI commands.
|
||||||
func CreateCommands() []cli.Command {
|
func CreateCommands() []cli.Command {
|
||||||
return []cli.Command{
|
return []cli.Command{
|
||||||
createRun(),
|
createRun(),
|
||||||
|
|
|
@ -60,7 +60,7 @@ func newClient(ctx *cli.Context, acc registration.User, keyType certcrypto.KeyTy
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
// getKeyType the type from which private keys should be generated
|
// getKeyType the type from which private keys should be generated.
|
||||||
func getKeyType(ctx *cli.Context) certcrypto.KeyType {
|
func getKeyType(ctx *cli.Context) certcrypto.KeyType {
|
||||||
keyType := ctx.GlobalString("key-type")
|
keyType := ctx.GlobalString("key-type")
|
||||||
switch strings.ToUpper(keyType) {
|
switch strings.ToUpper(keyType) {
|
||||||
|
|
|
@ -18,9 +18,13 @@ Configuration for [Go Daddy](https://godaddy.com).
|
||||||
|
|
||||||
- Code: `godaddy`
|
- Code: `godaddy`
|
||||||
|
|
||||||
{{% notice note %}}
|
Here is an example bash command using the Go Daddy provider:
|
||||||
_Please contribute by adding a CLI example._
|
|
||||||
{{% /notice %}}
|
```bash
|
||||||
|
GODADDY_API_KEY=xxxxxxxx \
|
||||||
|
GODADDY_API_SECRET=yyyyyyyy \
|
||||||
|
lego --dns godaddy --domains my.domain.com --email my@email.com run
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/go-acme/lego/v3/registration"
|
"github.com/go-acme/lego/v3/registration"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is the user-friendly way to ACME
|
// Client is the user-friendly way to ACME.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Certificate *certificate.Certifier
|
Certificate *certificate.Certifier
|
||||||
Challenge *resolver.SolverManager
|
Challenge *resolver.SolverManager
|
||||||
|
@ -63,12 +63,12 @@ func NewClient(config *Config) (*Client, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetToSURL returns the current ToS URL from the Directory
|
// GetToSURL returns the current ToS URL from the Directory.
|
||||||
func (c *Client) GetToSURL() string {
|
func (c *Client) GetToSURL() string {
|
||||||
return c.core.GetDirectory().Meta.TermsOfService
|
return c.core.GetDirectory().Meta.TermsOfService
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetExternalAccountRequired returns the External Account Binding requirement of the Directory
|
// GetExternalAccountRequired returns the External Account Binding requirement of the Directory.
|
||||||
func (c *Client) GetExternalAccountRequired() bool {
|
func (c *Client) GetExternalAccountRequired() bool {
|
||||||
return c.core.GetDirectory().Meta.ExternalAccountRequired
|
return c.core.GetDirectory().Meta.ExternalAccountRequired
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ type CertificateConfig struct {
|
||||||
|
|
||||||
// createDefaultHTTPClient Creates an HTTP client with a reasonable timeout value
|
// createDefaultHTTPClient Creates an HTTP client with a reasonable timeout value
|
||||||
// and potentially a custom *x509.CertPool
|
// and potentially a custom *x509.CertPool
|
||||||
// based on the caCertificatesEnvVar environment variable (see the `initCertPool` function)
|
// based on the caCertificatesEnvVar environment variable (see the `initCertPool` function).
|
||||||
func createDefaultHTTPClient() *http.Client {
|
func createDefaultHTTPClient() *http.Client {
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
|
2
platform/config/env/env.go
vendored
2
platform/config/env/env.go
vendored
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/go-acme/lego/v3/log"
|
"github.com/go-acme/lego/v3/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get environment variables
|
// Get environment variables.
|
||||||
func Get(names ...string) (map[string]string, error) {
|
func Get(names ...string) (map[string]string, error) {
|
||||||
values := map[string]string{}
|
values := map[string]string{}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ type acmeDNSClient interface {
|
||||||
RegisterAccount([]string) (goacmedns.Account, error)
|
RegisterAccount([]string) (goacmedns.Account, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface for
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// an ACME-DNS server.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client acmeDNSClient
|
client acmeDNSClient
|
||||||
storage goacmedns.Storage
|
storage goacmedns.Storage
|
||||||
|
|
|
@ -32,7 +32,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
SecretKey string
|
SecretKey string
|
||||||
|
@ -43,7 +43,7 @@ type Config struct {
|
||||||
HTTPTimeout time.Duration
|
HTTPTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
||||||
|
@ -53,14 +53,15 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *alidns.Client
|
client *alidns.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for Alibaba Cloud DNS.
|
// NewDNSProvider returns a DNSProvider instance configured for Alibaba Cloud DNS.
|
||||||
// Credentials must be passed in the environment variables: ALICLOUD_ACCESS_KEY and ALICLOUD_SECRET_KEY.
|
// Credentials must be passed in the environment variables:
|
||||||
|
// ALICLOUD_ACCESS_KEY and ALICLOUD_SECRET_KEY.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvAccessKey, EnvSecretKey)
|
values, err := env.Get(EnvAccessKey, EnvSecretKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
UserID string
|
UserID string
|
||||||
|
@ -37,7 +37,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||||
|
@ -46,7 +46,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider describes a provider for AuroraDNS
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
recordIDs map[string]string
|
recordIDs map[string]string
|
||||||
recordIDsMu sync.Mutex
|
recordIDsMu sync.Mutex
|
||||||
|
@ -102,7 +102,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a record with a secret
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes a given record that was generated by Present
|
// CleanUp removes a given record that was generated by Present.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package autodns implements a DNS provider for solving the DNS-01 challenge using auto DNS.
|
||||||
package autodns
|
package autodns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -31,6 +32,7 @@ const (
|
||||||
defaultTTL int = 600
|
defaultTTL int = 600
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Endpoint *url.URL
|
Endpoint *url.URL
|
||||||
Username string
|
Username string
|
||||||
|
@ -42,6 +44,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
endpoint, _ := url.Parse(env.GetOrDefaultString(EnvAPIEndpoint, defaultEndpoint))
|
endpoint, _ := url.Parse(env.GetOrDefaultString(EnvAPIEndpoint, defaultEndpoint))
|
||||||
|
|
||||||
|
@ -57,14 +60,13 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
// NewDNSProvider returns a DNSProvider instance configured for autoDNS.
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
// Credentials must be passed in the environment variables.
|
||||||
}
|
|
||||||
|
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvAPIUser, EnvAPIPassword)
|
values, err := env.Get(EnvAPIUser, EnvAPIPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -78,6 +80,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
return NewDNSProviderConfig(config)
|
return NewDNSProviderConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDNSProviderConfig return a DNSProvider instance configured for autoDNS.
|
||||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return nil, errors.New("autodns: config is nil")
|
return nil, errors.New("autodns: config is nil")
|
||||||
|
@ -94,7 +97,13 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config}, nil
|
return &DNSProvider{config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -113,7 +122,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record previously created
|
// CleanUp removes the TXT record previously created.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ type DataZoneResponse struct {
|
||||||
Data []*Zone `json:"data"`
|
Data []*Zone `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResourceRecord holds a resource record
|
// ResourceRecord holds a resource record.
|
||||||
type ResourceRecord struct {
|
type ResourceRecord struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
TTL int64 `json:"ttl"`
|
TTL int64 `json:"ttl"`
|
||||||
|
@ -54,7 +54,7 @@ type ResourceRecord struct {
|
||||||
Pref int32 `json:"pref,omitempty"`
|
Pref int32 `json:"pref,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zone is an autodns zone record with all for us relevant fields
|
// Zone is an autodns zone record with all for us relevant fields.
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
Name string `json:"origin"`
|
Name string `json:"origin"`
|
||||||
ResourceRecords []*ResourceRecord `json:"resourceRecords"`
|
ResourceRecords []*ResourceRecord `json:"resourceRecords"`
|
||||||
|
|
|
@ -37,7 +37,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// optional if using instance metadata service
|
// optional if using instance metadata service
|
||||||
ClientID string
|
ClientID string
|
||||||
|
@ -55,7 +55,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
||||||
|
@ -65,7 +65,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
authorizer autorest.Authorizer
|
authorizer autorest.Authorizer
|
||||||
|
@ -136,7 +136,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
@ -191,7 +191,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
@ -231,7 +231,7 @@ func (d *DNSProvider) getHostedZoneID(ctx context.Context, fqdn string) (string,
|
||||||
return to.String(zone.Name), nil
|
return to.String(zone.Name), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the relative record to the domain
|
// Returns the relative record to the domain.
|
||||||
func toRelativeRecord(domain, zone string) string {
|
func toRelativeRecord(domain, zone string) string {
|
||||||
return dns01.UnFqdn(strings.TrimSuffix(domain, zone))
|
return dns01.UnFqdn(strings.TrimSuffix(domain, zone))
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ func getAuthorizer(config *Config) (autorest.Authorizer, error) {
|
||||||
return auth.NewAuthorizerFromEnvironment()
|
return auth.NewAuthorizerFromEnvironment()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetches metadata from environment or he instance metadata service
|
// Fetches metadata from environment or he instance metadata service.
|
||||||
// borrowed from https://github.com/Microsoft/azureimds/blob/master/imdssample.go
|
// borrowed from https://github.com/Microsoft/azureimds/blob/master/imdssample.go
|
||||||
func getMetadata(config *Config, field string) (string, error) {
|
func getMetadata(config *Config, field string) (string, error) {
|
||||||
metadataEndpoint := config.MetadataEndpoint
|
metadataEndpoint := config.MetadataEndpoint
|
||||||
|
|
|
@ -23,7 +23,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
PollingInterval time.Duration
|
PollingInterval time.Duration
|
||||||
|
@ -31,7 +31,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||||
|
@ -42,8 +42,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface that uses
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// Bindman's Address Manager REST API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *client.DNSWebhookClient
|
client *client.DNSWebhookClient
|
||||||
|
|
|
@ -37,7 +37,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
UserName string
|
UserName string
|
||||||
|
@ -50,7 +50,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -62,8 +62,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface that uses
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// Bluecat's Address Manager REST API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
token string
|
token string
|
||||||
|
@ -73,7 +72,7 @@ type DNSProvider struct {
|
||||||
// Credentials must be passed in the environment variables: BLUECAT_SERVER_URL, BLUECAT_USER_NAME and BLUECAT_PASSWORD.
|
// Credentials must be passed in the environment variables: BLUECAT_SERVER_URL, BLUECAT_USER_NAME and BLUECAT_PASSWORD.
|
||||||
// BLUECAT_SERVER_URL should have the scheme, hostname, and port (if required) of the authoritative Bluecat BAM server.
|
// BLUECAT_SERVER_URL should have the scheme, hostname, and port (if required) of the authoritative Bluecat BAM server.
|
||||||
// The REST endpoint will be appended.
|
// The REST endpoint will be appended.
|
||||||
// In addition, the Configuration name and external DNS View Name must be passed in BLUECAT_CONFIG_NAME and BLUECAT_DNS_VIEW
|
// In addition, the Configuration name and external DNS View Name must be passed in BLUECAT_CONFIG_NAME and BLUECAT_DNS_VIEW.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvServerURL, EnvUserName, EnvPassword, EnvConfigName, EnvDNSView)
|
values, err := env.Get(EnvServerURL, EnvUserName, EnvPassword, EnvConfigName, EnvDNSView)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -156,7 +155,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return d.logout()
|
return d.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// JSON body for Bluecat entity requests and responses
|
// JSON body for Bluecat entity requests and responses.
|
||||||
type bluecatEntity struct {
|
type bluecatEntity struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -26,8 +26,9 @@ type entityResponse struct {
|
||||||
Properties string `json:"properties"`
|
Properties string `json:"properties"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts a new Bluecat API Session. Authenticates using customerName, userName,
|
// Starts a new Bluecat API Session.
|
||||||
// password and receives a token to be used in for subsequent requests.
|
// Authenticates using customerName, userName, password,
|
||||||
|
// and receives a token to be used in for subsequent requests.
|
||||||
func (d *DNSProvider) login() error {
|
func (d *DNSProvider) login() error {
|
||||||
queryArgs := map[string]string{
|
queryArgs := map[string]string{
|
||||||
"username": d.config.UserName,
|
"username": d.config.UserName,
|
||||||
|
@ -56,7 +57,7 @@ func (d *DNSProvider) login() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroys Bluecat Session
|
// Destroys Bluecat Session.
|
||||||
func (d *DNSProvider) logout() error {
|
func (d *DNSProvider) logout() error {
|
||||||
if len(d.token) == 0 {
|
if len(d.token) == 0 {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
@ -89,7 +90,7 @@ func (d *DNSProvider) logout() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup the entity ID of the configuration named in our properties
|
// Lookup the entity ID of the configuration named in our properties.
|
||||||
func (d *DNSProvider) lookupConfID() (uint, error) {
|
func (d *DNSProvider) lookupConfID() (uint, error) {
|
||||||
queryArgs := map[string]string{
|
queryArgs := map[string]string{
|
||||||
"parentId": strconv.Itoa(0),
|
"parentId": strconv.Itoa(0),
|
||||||
|
@ -111,7 +112,7 @@ func (d *DNSProvider) lookupConfID() (uint, error) {
|
||||||
return conf.ID, nil
|
return conf.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the DNS view with the given name within
|
// Find the DNS view with the given name within.
|
||||||
func (d *DNSProvider) lookupViewID(viewName string) (uint, error) {
|
func (d *DNSProvider) lookupViewID(viewName string) (uint, error) {
|
||||||
confID, err := d.lookupConfID()
|
confID, err := d.lookupConfID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -139,8 +140,8 @@ func (d *DNSProvider) lookupViewID(viewName string) (uint, error) {
|
||||||
return view.ID, nil
|
return view.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the entityId of the parent zone by recursing from the root view
|
// Return the entityId of the parent zone by recursing from the root view.
|
||||||
// Also return the simple name of the host
|
// Also return the simple name of the host.
|
||||||
func (d *DNSProvider) lookupParentZoneID(viewID uint, fqdn string) (uint, string, error) {
|
func (d *DNSProvider) lookupParentZoneID(viewID uint, fqdn string) (uint, string, error) {
|
||||||
parentViewID := viewID
|
parentViewID := viewID
|
||||||
name := ""
|
name := ""
|
||||||
|
@ -165,7 +166,7 @@ func (d *DNSProvider) lookupParentZoneID(viewID uint, fqdn string) (uint, string
|
||||||
return parentViewID, name, nil
|
return parentViewID, name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the DNS zone with the specified name under the parentId
|
// Get the DNS zone with the specified name under the parentId.
|
||||||
func (d *DNSProvider) getZone(parentID uint, name string) (uint, error) {
|
func (d *DNSProvider) getZone(parentID uint, name string) (uint, error) {
|
||||||
queryArgs := map[string]string{
|
queryArgs := map[string]string{
|
||||||
"parentId": strconv.FormatUint(uint64(parentID), 10),
|
"parentId": strconv.FormatUint(uint64(parentID), 10),
|
||||||
|
@ -193,7 +194,7 @@ func (d *DNSProvider) getZone(parentID uint, name string) (uint, error) {
|
||||||
return zone.ID, nil
|
return zone.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy the DNS config for the specified entity to the authoritative servers
|
// Deploy the DNS config for the specified entity to the authoritative servers.
|
||||||
func (d *DNSProvider) deploy(entityID uint) error {
|
func (d *DNSProvider) deploy(entityID uint) error {
|
||||||
queryArgs := map[string]string{
|
queryArgs := map[string]string{
|
||||||
"entityId": strconv.FormatUint(uint64(entityID), 10),
|
"entityId": strconv.FormatUint(uint64(entityID), 10),
|
||||||
|
@ -208,8 +209,8 @@ func (d *DNSProvider) deploy(entityID uint) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a REST request, using query parameters specified. The Authorization
|
// Send a REST request, using query parameters specified.
|
||||||
// header will be set if we have an active auth token
|
// The Authorization header will be set if we have an active auth token.
|
||||||
func (d *DNSProvider) sendRequest(method, resource string, payload interface{}, queryArgs map[string]string) (*http.Response, error) {
|
func (d *DNSProvider) sendRequest(method, resource string, payload interface{}, queryArgs map[string]string) (*http.Response, error) {
|
||||||
url := fmt.Sprintf("%s/Services/REST/v1/%s", d.config.BaseURL, resource)
|
url := fmt.Sprintf("%s/Services/REST/v1/%s", d.config.BaseURL, resource)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package checkdomain implements a DNS provider for solving the DNS-01 challenge using CheckDomain DNS.
|
||||||
package checkdomain
|
package checkdomain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -30,7 +31,7 @@ const (
|
||||||
defaultTTL = 300
|
defaultTTL = 300
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Endpoint *url.URL
|
Endpoint *url.URL
|
||||||
Token string
|
Token string
|
||||||
|
@ -40,7 +41,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, defaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, defaultTTL),
|
||||||
|
@ -52,8 +53,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider implements challenge.Provider for the checkdomain API
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// specified at https://developer.checkdomain.de/reference/.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ type DNSProvider struct {
|
||||||
domainIDMapping map[string]int
|
domainIDMapping map[string]int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDNSProvider returns a DNSProvider instance configured for CheckDomain.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvToken)
|
values, err := env.Get(EnvToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,7 +99,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
domainID, err := d.getDomainIDByName(domain)
|
domainID, err := d.getDomainIDByName(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -126,7 +127,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record previously created
|
// CleanUp removes the TXT record previously created.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
domainID, err := d.getDomainIDByName(domain)
|
domainID, err := d.getDomainIDByName(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -152,6 +153,8 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
return nil
|
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) {
|
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ const (
|
||||||
|
|
||||||
const domainNotFound = -1
|
const domainNotFound = -1
|
||||||
|
|
||||||
// max page limit that the checkdomain api allows
|
// max page limit that the checkdomain api allows.
|
||||||
const maxLimit = 100
|
const maxLimit = 100
|
||||||
|
|
||||||
// max integer value
|
// max integer value.
|
||||||
const maxInt = int((^uint(0)) >> 1)
|
const maxInt = int((^uint(0)) >> 1)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
@ -50,8 +50,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge. Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// that uses CloudDNS API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
config *Config
|
config *Config
|
||||||
|
@ -74,7 +73,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
return NewDNSProviderConfig(config)
|
return NewDNSProviderConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProviderConfig return a DNSProvider instance configured for CloudDNS
|
// NewDNSProviderConfig return a DNSProvider instance configured for CloudDNS.
|
||||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return nil, errors.New("clouddns: the configuration of the DNS provider is nil")
|
return nil, errors.New("clouddns: the configuration of the DNS provider is nil")
|
||||||
|
|
|
@ -18,7 +18,7 @@ const (
|
||||||
minTTL = 120
|
minTTL = 120
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AuthEmail string
|
AuthEmail string
|
||||||
AuthKey string
|
AuthKey string
|
||||||
|
@ -32,7 +32,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt("CLOUDFLARE_TTL", minTTL),
|
TTL: env.GetOrDefaultInt("CLOUDFLARE_TTL", minTTL),
|
||||||
|
@ -44,7 +44,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *metaClient
|
client *metaClient
|
||||||
config *Config
|
config *Config
|
||||||
|
@ -118,7 +118,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AuthID string
|
AuthID string
|
||||||
SubAuthID string
|
SubAuthID string
|
||||||
|
@ -37,7 +37,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
||||||
|
@ -49,7 +49,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
|
|
@ -27,7 +27,7 @@ type Zone struct {
|
||||||
Status string // is an integer, but cast as string
|
Status string // is an integer, but cast as string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TXTRecord a TXT record
|
// TXTRecord a TXT record.
|
||||||
type TXTRecord struct {
|
type TXTRecord struct {
|
||||||
ID int `json:"id,string"`
|
ID int `json:"id,string"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
@ -40,7 +40,7 @@ type TXTRecord struct {
|
||||||
|
|
||||||
type TXTRecords map[string]TXTRecord
|
type TXTRecords map[string]TXTRecord
|
||||||
|
|
||||||
// NewClient creates a ClouDNS client
|
// NewClient creates a ClouDNS client.
|
||||||
func NewClient(authID string, subAuthID string, authPassword string) (*Client, error) {
|
func NewClient(authID string, subAuthID string, authPassword string) (*Client, error) {
|
||||||
if authID == "" && subAuthID == "" {
|
if authID == "" && subAuthID == "" {
|
||||||
return nil, errors.New("credentials missing: authID or subAuthID")
|
return nil, errors.New("credentials missing: authID or subAuthID")
|
||||||
|
@ -64,7 +64,7 @@ func NewClient(authID string, subAuthID string, authPassword string) (*Client, e
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client ClouDNS client
|
// Client ClouDNS client.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
authID string
|
authID string
|
||||||
subAuthID string
|
subAuthID string
|
||||||
|
@ -73,7 +73,7 @@ type Client struct {
|
||||||
BaseURL *url.URL
|
BaseURL *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetZone Get domain name information for a FQDN
|
// GetZone Get domain name information for a FQDN.
|
||||||
func (c *Client) GetZone(authFQDN string) (*Zone, error) {
|
func (c *Client) GetZone(authFQDN string) (*Zone, error) {
|
||||||
authZone, err := dns01.FindZoneByFqdn(authFQDN)
|
authZone, err := dns01.FindZoneByFqdn(authFQDN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -109,7 +109,7 @@ func (c *Client) GetZone(authFQDN string) (*Zone, error) {
|
||||||
return nil, fmt.Errorf("zone %s not found for authFQDN %s", authZoneName, authFQDN)
|
return nil, fmt.Errorf("zone %s not found for authFQDN %s", authZoneName, authFQDN)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindTxtRecord return the TXT record a zone ID and a FQDN
|
// FindTxtRecord return the TXT record a zone ID and a FQDN.
|
||||||
func (c *Client) FindTxtRecord(zoneName, fqdn string) (*TXTRecord, error) {
|
func (c *Client) FindTxtRecord(zoneName, fqdn string) (*TXTRecord, error) {
|
||||||
host := dns01.UnFqdn(strings.TrimSuffix(dns01.UnFqdn(fqdn), zoneName))
|
host := dns01.UnFqdn(strings.TrimSuffix(dns01.UnFqdn(fqdn), zoneName))
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (c *Client) FindTxtRecord(zoneName, fqdn string) (*TXTRecord, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddTxtRecord add a TXT record
|
// AddTxtRecord add a TXT record.
|
||||||
func (c *Client) AddTxtRecord(zoneName string, fqdn, value string, ttl int) error {
|
func (c *Client) AddTxtRecord(zoneName string, fqdn, value string, ttl int) error {
|
||||||
host := dns01.UnFqdn(strings.TrimSuffix(dns01.UnFqdn(fqdn), zoneName))
|
host := dns01.UnFqdn(strings.TrimSuffix(dns01.UnFqdn(fqdn), zoneName))
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ func (c *Client) AddTxtRecord(zoneName string, fqdn, value string, ttl int) erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveTxtRecord remove a TXT record
|
// RemoveTxtRecord remove a TXT record.
|
||||||
func (c *Client) RemoveTxtRecord(recordID int, zoneName string) error {
|
func (c *Client) RemoveTxtRecord(recordID int, zoneName string) error {
|
||||||
reqURL := *c.BaseURL
|
reqURL := *c.BaseURL
|
||||||
reqURL.Path += "delete-record.json"
|
reqURL.Path += "delete-record.json"
|
||||||
|
@ -254,21 +254,23 @@ func toUnreadableBodyMessage(req *http.Request, rawBody []byte) string {
|
||||||
return fmt.Sprintf("the request %s sent a response with a body which is an invalid format: %q", req.URL, string(rawBody))
|
return fmt.Sprintf("the request %s sent a response with a body which is an invalid format: %q", req.URL, string(rawBody))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.cloudns.net/wiki/article/58/
|
// Rounds the given TTL in seconds to the next accepted value.
|
||||||
// Available TTL's:
|
// Accepted TTL values are:
|
||||||
// 60 = 1 minute
|
// - 60 = 1 minute
|
||||||
// 300 = 5 minutes
|
// - 300 = 5 minutes
|
||||||
// 900 = 15 minutes
|
// - 900 = 15 minutes
|
||||||
// 1800 = 30 minutes
|
// - 1800 = 30 minutes
|
||||||
// 3600 = 1 hour
|
// - 3600 = 1 hour
|
||||||
// 21600 = 6 hours
|
// - 21600 = 6 hours
|
||||||
// 43200 = 12 hours
|
// - 43200 = 12 hours
|
||||||
// 86400 = 1 day
|
// - 86400 = 1 day
|
||||||
// 172800 = 2 days
|
// - 172800 = 2 days
|
||||||
// 259200 = 3 days
|
// - 259200 = 3 days
|
||||||
// 604800 = 1 week
|
// - 604800 = 1 week
|
||||||
// 1209600 = 2 weeks
|
// - 1209600 = 2 weeks
|
||||||
// 2592000 = 1 month
|
// - 2592000 = 1 month
|
||||||
|
// - 2592000 = 1 month
|
||||||
|
// See https://www.cloudns.net/wiki/article/58/ for details.
|
||||||
func ttlRounder(ttl int) int {
|
func ttlRounder(ttl int) int {
|
||||||
for _, validTTL := range []int{60, 300, 900, 1800, 3600, 21600, 43200, 86400, 172800, 259200, 604800, 1209600} {
|
for _, validTTL := range []int{60, 300, 900, 1800, 3600, 21600, 43200, 86400, 172800, 259200, 604800, 1209600} {
|
||||||
if ttl <= validTTL {
|
if ttl <= validTTL {
|
||||||
|
|
|
@ -25,7 +25,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
SecretKey string
|
SecretKey string
|
||||||
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||||
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
|
|
@ -24,14 +24,14 @@ type apiResponse struct {
|
||||||
Data json.RawMessage `json:"data,omitempty"`
|
Data json.RawMessage `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data Domain information
|
// Data Domain information.
|
||||||
type Data struct {
|
type Data struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
TTL int `json:"ttl,omitempty"`
|
TTL int `json:"ttl,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TXTRecord a TXT record
|
// TXTRecord a TXT record.
|
||||||
type TXTRecord struct {
|
type TXTRecord struct {
|
||||||
ID int `json:"domain_id,omitempty"`
|
ID int `json:"domain_id,omitempty"`
|
||||||
RecordID string `json:"record_id,omitempty"`
|
RecordID string `json:"record_id,omitempty"`
|
||||||
|
@ -43,7 +43,7 @@ type TXTRecord struct {
|
||||||
TTL int `json:"ttl,string"`
|
TTL int `json:"ttl,string"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a CloudXNS client
|
// NewClient creates a CloudXNS client.
|
||||||
func NewClient(apiKey string, secretKey string) (*Client, error) {
|
func NewClient(apiKey string, secretKey string) (*Client, error) {
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
return nil, errors.New("CloudXNS: credentials missing: apiKey")
|
return nil, errors.New("CloudXNS: credentials missing: apiKey")
|
||||||
|
@ -61,7 +61,7 @@ func NewClient(apiKey string, secretKey string) (*Client, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client CloudXNS client
|
// Client CloudXNS client.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
apiKey string
|
apiKey string
|
||||||
secretKey string
|
secretKey string
|
||||||
|
@ -69,7 +69,7 @@ type Client struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDomainInformation Get domain name information for a FQDN
|
// GetDomainInformation Get domain name information for a FQDN.
|
||||||
func (c *Client) GetDomainInformation(fqdn string) (*Data, error) {
|
func (c *Client) GetDomainInformation(fqdn string) (*Data, error) {
|
||||||
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,7 +98,7 @@ func (c *Client) GetDomainInformation(fqdn string) (*Data, error) {
|
||||||
return nil, fmt.Errorf("CloudXNS: zone %s not found for domain %s", authZone, fqdn)
|
return nil, fmt.Errorf("CloudXNS: zone %s not found for domain %s", authZone, fqdn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindTxtRecord return the TXT record a zone ID and a FQDN
|
// FindTxtRecord return the TXT record a zone ID and a FQDN.
|
||||||
func (c *Client) FindTxtRecord(zoneID, fqdn string) (*TXTRecord, error) {
|
func (c *Client) FindTxtRecord(zoneID, fqdn string) (*TXTRecord, error) {
|
||||||
result, err := c.doRequest(http.MethodGet, fmt.Sprintf("record/%s?host_id=0&offset=0&row_num=2000", zoneID), nil)
|
result, err := c.doRequest(http.MethodGet, fmt.Sprintf("record/%s?host_id=0&offset=0&row_num=2000", zoneID), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -120,7 +120,7 @@ func (c *Client) FindTxtRecord(zoneID, fqdn string) (*TXTRecord, error) {
|
||||||
return nil, fmt.Errorf("CloudXNS: no existing record found for %q", fqdn)
|
return nil, fmt.Errorf("CloudXNS: no existing record found for %q", fqdn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddTxtRecord add a TXT record
|
// AddTxtRecord add a TXT record.
|
||||||
func (c *Client) AddTxtRecord(info *Data, fqdn, value string, ttl int) error {
|
func (c *Client) AddTxtRecord(info *Data, fqdn, value string, ttl int) error {
|
||||||
id, err := strconv.Atoi(info.ID)
|
id, err := strconv.Atoi(info.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -145,7 +145,7 @@ func (c *Client) AddTxtRecord(info *Data, fqdn, value string, ttl int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveTxtRecord remove a TXT record
|
// RemoveTxtRecord remove a TXT record.
|
||||||
func (c *Client) RemoveTxtRecord(recordID, zoneID string) error {
|
func (c *Client) RemoveTxtRecord(recordID, zoneID string) error {
|
||||||
_, err := c.doRequest(http.MethodDelete, fmt.Sprintf("record/%s/%s", recordID, zoneID), nil)
|
_, err := c.doRequest(http.MethodDelete, fmt.Sprintf("record/%s/%s", recordID, zoneID), nil)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Region string
|
Region string
|
||||||
TenantID string
|
TenantID string
|
||||||
|
@ -39,7 +39,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Region: env.GetOrDefaultString(EnvRegion, "tyo1"),
|
Region: env.GetOrDefaultString(EnvRegion, "tyo1"),
|
||||||
|
@ -52,14 +52,15 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for ConoHa DNS.
|
// NewDNSProvider returns a DNSProvider instance configured for ConoHa DNS.
|
||||||
// Credentials must be passed in the environment variables: CONOHA_TENANT_ID, CONOHA_API_USERNAME, CONOHA_API_PASSWORD
|
// Credentials must be passed in the environment variables:
|
||||||
|
// CONOHA_TENANT_ID, CONOHA_API_USERNAME, CONOHA_API_PASSWORD.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvTenantID, EnvAPIUsername, EnvAPIPassword)
|
values, err := env.Get(EnvTenantID, EnvAPIUsername, EnvAPIPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -129,7 +130,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp clears ConoHa DNS TXT record
|
// CleanUp clears ConoHa DNS TXT record.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
SecretKey string
|
SecretKey string
|
||||||
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||||
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
@ -95,7 +95,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ func NewTokenTransport(apiKey, secretKey string) (*TokenTransport, error) {
|
||||||
return &TokenTransport{apiKey: apiKey, secretKey: secretKey}, nil
|
return &TokenTransport{apiKey: apiKey, secretKey: secretKey}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoundTrip executes a single HTTP transaction
|
// RoundTrip executes a single HTTP transaction.
|
||||||
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
enrichedReq := &http.Request{}
|
enrichedReq := &http.Request{}
|
||||||
*enrichedReq = *req
|
*enrichedReq = *req
|
||||||
|
@ -60,12 +60,12 @@ func (t *TokenTransport) transport() http.RoundTripper {
|
||||||
return http.DefaultTransport
|
return http.DefaultTransport
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client Creates a new HTTP client
|
// Client Creates a new HTTP client.
|
||||||
func (t *TokenTransport) Client() *http.Client {
|
func (t *TokenTransport) Client() *http.Client {
|
||||||
return &http.Client{Transport: t}
|
return &http.Client{Transport: t}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap Wrap a HTTP client Transport with the TokenTransport
|
// Wrap Wrap a HTTP client Transport with the TokenTransport.
|
||||||
func (t *TokenTransport) Wrap(client *http.Client) *http.Client {
|
func (t *TokenTransport) Wrap(client *http.Client) *http.Client {
|
||||||
backup := client.Transport
|
backup := client.Transport
|
||||||
t.Transport = backup
|
t.Transport = backup
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Search filters
|
// Search filters.
|
||||||
const (
|
const (
|
||||||
StartsWith searchFilter = "startswith"
|
StartsWith searchFilter = "startswith"
|
||||||
Exact searchFilter = "exact"
|
Exact searchFilter = "exact"
|
||||||
|
|
|
@ -45,7 +45,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
|
|
@ -20,7 +20,7 @@ type Client struct {
|
||||||
token string
|
token string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creats a new Client.
|
// NewClient creates a new Client.
|
||||||
func NewClient(token string) *Client {
|
func NewClient(token string) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
HTTPClient: http.DefaultClient,
|
HTTPClient: http.DefaultClient,
|
||||||
|
|
|
@ -35,7 +35,7 @@ const (
|
||||||
EnvProjectID = envNamespaceClient + "PROJECT_ID"
|
EnvProjectID = envNamespaceClient + "PROJECT_ID"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
PollingInterval time.Duration
|
PollingInterval time.Duration
|
||||||
|
@ -43,7 +43,7 @@ type Config struct {
|
||||||
opts gophercloud.AuthOptions
|
opts gophercloud.AuthOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 10),
|
TTL: env.GetOrDefaultInt(EnvTTL, 10),
|
||||||
|
@ -52,7 +52,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider describes a provider for Designate
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *gophercloud.ServiceClient
|
client *gophercloud.ServiceClient
|
||||||
|
@ -106,7 +106,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
const defaultBaseURL = "https://api.digitalocean.com"
|
const defaultBaseURL = "https://api.digitalocean.com"
|
||||||
|
|
||||||
// txtRecordResponse represents a response from DO's API after making a TXT record
|
// txtRecordResponse represents a response from DO's API after making a TXT record.
|
||||||
type txtRecordResponse struct {
|
type txtRecordResponse struct {
|
||||||
DomainRecord record `json:"domain_record"`
|
DomainRecord record `json:"domain_record"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
AuthToken string
|
AuthToken string
|
||||||
|
@ -34,7 +34,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
BaseURL: defaultBaseURL,
|
BaseURL: defaultBaseURL,
|
||||||
|
@ -47,8 +47,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// that uses DigitalOcean's REST API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
recordIDs map[string]int
|
recordIDs map[string]int
|
||||||
|
@ -96,7 +95,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ import (
|
||||||
"github.com/go-acme/lego/v3/providers/dns/zonomi"
|
"github.com/go-acme/lego/v3/providers/dns/zonomi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDNSChallengeProviderByName Factory for DNS providers
|
// NewDNSChallengeProviderByName Factory for DNS providers.
|
||||||
func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
|
func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case "acme-dns":
|
case "acme-dns":
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AccessToken string
|
AccessToken string
|
||||||
BaseURL string
|
BaseURL string
|
||||||
|
@ -36,7 +36,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -45,14 +45,14 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *dnsimple.Client
|
client *dnsimple.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for dnsimple.
|
// NewDNSProvider returns a DNSProvider instance configured for dnsimple.
|
||||||
// Credentials must be passed in the environment variables: DNSIMPLE_OAUTH_TOKEN.
|
// Credentials must be passed in the environment variable: DNSIMPLE_OAUTH_TOKEN.
|
||||||
//
|
//
|
||||||
// See: https://developer.dnsimple.com/v2/#authentication
|
// See: https://developer.dnsimple.com/v2/#authentication
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
APIKey string
|
APIKey string
|
||||||
|
@ -40,7 +40,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -55,8 +55,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface that uses
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// DNSMadeEasy's DNS API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
@ -110,7 +109,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domainName, keyAuth)
|
fqdn, value := dns01.GetRecord(domainName, keyAuth)
|
||||||
|
|
||||||
|
@ -136,7 +135,7 @@ func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT records matching the specified parameters
|
// CleanUp removes the TXT records matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domainName, keyAuth)
|
fqdn, _ := dns01.GetRecord(domainName, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Domain holds the DNSMadeEasy API representation of a Domain
|
// Domain holds the DNSMadeEasy API representation of a Domain.
|
||||||
type Domain struct {
|
type Domain struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record holds the DNSMadeEasy API representation of a Domain Record
|
// Record holds the DNSMadeEasy API representation of a Domain Record.
|
||||||
type Record struct {
|
type Record struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
@ -33,7 +33,7 @@ type recordsResponse struct {
|
||||||
Records *[]Record `json:"data"`
|
Records *[]Record `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client DNSMadeEasy client
|
// Client DNSMadeEasy client.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
apiKey string
|
apiKey string
|
||||||
apiSecret string
|
apiSecret string
|
||||||
|
@ -41,7 +41,7 @@ type Client struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a DNSMadeEasy client
|
// NewClient creates a DNSMadeEasy client.
|
||||||
func NewClient(apiKey string, apiSecret string) (*Client, error) {
|
func NewClient(apiKey string, apiSecret string) (*Client, error) {
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
return nil, errors.New("credentials missing: API key")
|
return nil, errors.New("credentials missing: API key")
|
||||||
|
@ -58,7 +58,7 @@ func NewClient(apiKey string, apiSecret string) (*Client, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDomain gets a domain
|
// GetDomain gets a domain.
|
||||||
func (c *Client) GetDomain(authZone string) (*Domain, error) {
|
func (c *Client) GetDomain(authZone string) (*Domain, error) {
|
||||||
domainName := authZone[0 : len(authZone)-1]
|
domainName := authZone[0 : len(authZone)-1]
|
||||||
resource := fmt.Sprintf("%s%s", "/dns/managed/name?domainname=", domainName)
|
resource := fmt.Sprintf("%s%s", "/dns/managed/name?domainname=", domainName)
|
||||||
|
@ -78,7 +78,7 @@ func (c *Client) GetDomain(authZone string) (*Domain, error) {
|
||||||
return domain, nil
|
return domain, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecords gets all TXT records
|
// GetRecords gets all TXT records.
|
||||||
func (c *Client) GetRecords(domain *Domain, recordName, recordType string) (*[]Record, error) {
|
func (c *Client) GetRecords(domain *Domain, recordName, recordType string) (*[]Record, error) {
|
||||||
resource := fmt.Sprintf("%s/%d/%s%s%s%s", "/dns/managed", domain.ID, "records?recordName=", recordName, "&type=", recordType)
|
resource := fmt.Sprintf("%s/%d/%s%s%s%s", "/dns/managed", domain.ID, "records?recordName=", recordName, "&type=", recordType)
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func (c *Client) GetRecords(domain *Domain, recordName, recordType string) (*[]R
|
||||||
return records.Records, nil
|
return records.Records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRecord creates a TXT records
|
// CreateRecord creates a TXT records.
|
||||||
func (c *Client) CreateRecord(domain *Domain, record *Record) error {
|
func (c *Client) CreateRecord(domain *Domain, record *Record) error {
|
||||||
url := fmt.Sprintf("%s/%d/%s", "/dns/managed", domain.ID, "records")
|
url := fmt.Sprintf("%s/%d/%s", "/dns/managed", domain.ID, "records")
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ func (c *Client) CreateRecord(domain *Domain, record *Record) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRecord deletes a TXT records
|
// DeleteRecord deletes a TXT records.
|
||||||
func (c *Client) DeleteRecord(record Record) error {
|
func (c *Client) DeleteRecord(record Record) error {
|
||||||
resource := fmt.Sprintf("%s/%d/%s/%d", "/dns/managed", record.SourceID, "records", record.ID)
|
resource := fmt.Sprintf("%s/%d/%s/%d", "/dns/managed", record.SourceID, "records", record.ID)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
LoginToken string
|
LoginToken string
|
||||||
TTL int
|
TTL int
|
||||||
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
||||||
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *dnspod.Client
|
client *dnspod.Client
|
||||||
|
|
|
@ -23,7 +23,7 @@ const (
|
||||||
EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL"
|
EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Token string
|
Token string
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
|
@ -32,7 +32,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||||
|
@ -44,7 +44,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider adds and removes the record for the DNS challenge
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return d.updateTxtRecord(fqdn, d.config.Token, txtRecord, false)
|
return d.updateTxtRecord(fqdn, d.config.Token, txtRecord, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp clears TXT record
|
// CleanUp clears TXT record.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
return d.updateTxtRecord(fqdn, d.config.Token, "", true)
|
return d.updateTxtRecord(fqdn, d.config.Token, "", true)
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (d *DNSProvider) buildQuery(action, domain, txt string) (*url.URL, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateTxtRecord will either add or remove a TXT record.
|
// updateTxtRecord will either add or remove a TXT record.
|
||||||
// action is either cmdAddRecord or cmdRemoveRecord
|
// action is either cmdAddRecord or cmdRemoveRecord.
|
||||||
func (d *DNSProvider) updateTxtRecord(u fmt.Stringer) error {
|
func (d *DNSProvider) updateTxtRecord(u fmt.Stringer) error {
|
||||||
resp, err := d.config.HTTPClient.Get(u.String())
|
resp, err := d.config.HTTPClient.Get(u.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -24,7 +24,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
APIKey string
|
APIKey string
|
||||||
|
@ -33,7 +33,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
BaseURL: defaultBaseURL,
|
BaseURL: defaultBaseURL,
|
||||||
|
@ -45,7 +45,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider adds and removes the record for the DNS challenge
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config}, nil
|
return &DNSProvider{config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
record := dns01.UnFqdn(fqdn)
|
record := dns01.UnFqdn(fqdn)
|
||||||
|
@ -98,7 +98,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp clears DreamHost TXT record
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
record := dns01.UnFqdn(fqdn)
|
record := dns01.UnFqdn(fqdn)
|
||||||
|
|
|
@ -47,10 +47,10 @@ func (d *DNSProvider) updateTxtRecord(domain, token, txt string, clear bool) err
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DuckDNS only lets you write to your subdomain
|
// DuckDNS only lets you write to your subdomain.
|
||||||
// so it must be in format subdomain.duckdns.org
|
// It must be in format subdomain.duckdns.org,
|
||||||
// not in format subsubdomain.subdomain.duckdns.org
|
// not in format subsubdomain.subdomain.duckdns.org.
|
||||||
// so strip off everything that is not top 3 levels
|
// So strip off everything that is not top 3 levels.
|
||||||
func getMainDomain(domain string) string {
|
func getMainDomain(domain string) string {
|
||||||
domain = dns01.UnFqdn(domain)
|
domain = dns01.UnFqdn(domain)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ const (
|
||||||
EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL"
|
EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Token string
|
Token string
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
|
@ -33,7 +33,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||||
|
@ -45,7 +45,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider adds and removes the record for the DNS challenge
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return d.updateTxtRecord(domain, d.config.Token, txtRecord, false)
|
return d.updateTxtRecord(domain, d.config.Token, txtRecord, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp clears DuckDNS TXT record
|
// CleanUp clears DuckDNS TXT record.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
return d.updateTxtRecord(domain, d.config.Token, "", true)
|
return d.updateTxtRecord(domain, d.config.Token, "", true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func (d *DNSProvider) login() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroys Dyn Session
|
// Destroys Dyn Session.
|
||||||
func (d *DNSProvider) logout() error {
|
func (d *DNSProvider) logout() error {
|
||||||
if len(d.token) == 0 {
|
if len(d.token) == 0 {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
|
|
@ -26,7 +26,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
CustomerName string
|
CustomerName string
|
||||||
UserName string
|
UserName string
|
||||||
|
@ -37,7 +37,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -49,8 +49,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface that uses
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// Dyn's Managed DNS API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
token string
|
token string
|
||||||
|
@ -73,7 +72,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
return NewDNSProviderConfig(config)
|
return NewDNSProviderConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProviderConfig return a DNSProvider instance configured for Dyn DNS
|
// NewDNSProviderConfig return a DNSProvider instance configured for Dyn DNS.
|
||||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return nil, errors.New("dyn: the configuration of the DNS provider is nil")
|
return nil, errors.New("dyn: the configuration of the DNS provider is nil")
|
||||||
|
@ -86,7 +85,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config}, nil
|
return &DNSProvider{config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return d.logout()
|
return d.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||||
|
@ -48,7 +48,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
@ -95,7 +95,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ func NewTokenTransport(apiKey string) (*TokenTransport, error) {
|
||||||
return &TokenTransport{apiKey: apiKey}, nil
|
return &TokenTransport{apiKey: apiKey}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoundTrip executes a single HTTP transaction
|
// RoundTrip executes a single HTTP transaction.
|
||||||
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
enrichedReq := &http.Request{}
|
enrichedReq := &http.Request{}
|
||||||
*enrichedReq = *req
|
*enrichedReq = *req
|
||||||
|
@ -49,12 +49,12 @@ func (t *TokenTransport) transport() http.RoundTripper {
|
||||||
return http.DefaultTransport
|
return http.DefaultTransport
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client Creates a new HTTP client
|
// Client Creates a new HTTP client.
|
||||||
func (t *TokenTransport) Client() *http.Client {
|
func (t *TokenTransport) Client() *http.Client {
|
||||||
return &http.Client{Transport: t}
|
return &http.Client{Transport: t}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap Wrap a HTTP client Transport with the TokenTransport
|
// Wrap Wrap a HTTP client Transport with the TokenTransport.
|
||||||
func (t *TokenTransport) Wrap(client *http.Client) *http.Client {
|
func (t *TokenTransport) Wrap(client *http.Client) *http.Client {
|
||||||
backup := client.Transport
|
backup := client.Transport
|
||||||
t.Transport = backup
|
t.Transport = backup
|
||||||
|
|
|
@ -31,7 +31,7 @@ const (
|
||||||
EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL"
|
EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Endpoint *url.URL
|
Endpoint *url.URL
|
||||||
Token string
|
Token string
|
||||||
|
@ -43,7 +43,7 @@ type Config struct {
|
||||||
SequenceInterval time.Duration
|
SequenceInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -56,7 +56,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider describes a provider for acme-proxy
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
recordIDs map[string]string
|
recordIDs map[string]string
|
||||||
|
@ -101,7 +101,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config, recordIDs: map[string]string{}}, nil
|
return &DNSProvider{config: config, recordIDs: map[string]string{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, challenge := dns01.GetRecord(domain, keyAuth)
|
fqdn, challenge := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ type Config struct {
|
||||||
PollingInterval time.Duration
|
PollingInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||||
|
@ -40,8 +40,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider adds and removes the record for the DNS challenge by calling a
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// program with command-line parameters.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -91,7 +90,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
var args []string
|
var args []string
|
||||||
if d.config.Mode == "RAW" {
|
if d.config.Mode == "RAW" {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
APISecret string
|
APISecret string
|
||||||
|
@ -40,7 +40,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -52,7 +52,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *egoscale.Client
|
client *egoscale.Client
|
||||||
|
@ -169,7 +169,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindExistingRecordID Query Exoscale to find an existing record for this name.
|
// FindExistingRecordID Query Exoscale to find an existing record for this name.
|
||||||
// Returns nil if no record could be found
|
// Returns nil if no record could be found.
|
||||||
func (d *DNSProvider) FindExistingRecordID(zone, recordName string) (int64, error) {
|
func (d *DNSProvider) FindExistingRecordID(zone, recordName string) (int64, error) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
records, err := d.client.GetRecords(ctx, zone)
|
records, err := d.client.GetRecords(ctx, zone)
|
||||||
|
@ -184,7 +184,7 @@ func (d *DNSProvider) FindExistingRecordID(zone, recordName string) (int64, erro
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindZoneAndRecordName Extract DNS zone and DNS entry name
|
// FindZoneAndRecordName Extract DNS zone and DNS entry name.
|
||||||
func (d *DNSProvider) FindZoneAndRecordName(fqdn, domain string) (string, string, error) {
|
func (d *DNSProvider) FindZoneAndRecordName(fqdn, domain string) (string, string, error) {
|
||||||
zone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
|
zone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
edgegrid.Config
|
edgegrid.Config
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -44,13 +44,13 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProvider uses the supplied environment variables to return a DNSProvider instance:
|
// NewDNSProvider uses the supplied environment variables to return a DNSProvider instance:
|
||||||
// AKAMAI_HOST, AKAMAI_CLIENT_TOKEN, AKAMAI_CLIENT_SECRET, AKAMAI_ACCESS_TOKEN
|
// AKAMAI_HOST, AKAMAI_CLIENT_TOKEN, AKAMAI_CLIENT_SECRET, AKAMAI_ACCESS_TOKEN.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvHost, EnvClientToken, EnvClientSecret, EnvAccessToken)
|
values, err := env.Get(EnvHost, EnvClientToken, EnvClientSecret, EnvAccessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -82,7 +82,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config}, nil
|
return &DNSProvider{config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fullfil the dns-01 challenge.
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
zoneName, recordName, err := d.findZoneAndRecordName(fqdn, domain)
|
zoneName, recordName, err := d.findZoneAndRecordName(fqdn, domain)
|
||||||
|
|
|
@ -34,7 +34,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
APIKey string
|
APIKey string
|
||||||
|
@ -44,7 +44,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
@ -56,16 +56,14 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inProgressInfo contains information about an in-progress challenge
|
// inProgressInfo contains information about an in-progress challenge.
|
||||||
type inProgressInfo struct {
|
type inProgressInfo struct {
|
||||||
zoneID int // zoneID of gandi zone to restore in CleanUp
|
zoneID int // zoneID of gandi zone to restore in CleanUp
|
||||||
newZoneID int // zoneID of temporary gandi zone containing TXT record
|
newZoneID int // zoneID of temporary gandi zone containing TXT record
|
||||||
authZone string // the domain name registered at gandi with trailing "."
|
authZone string // the domain name registered at gandi with trailing "."
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// challenge.ProviderTimeout interface that uses Gandi's XML-RPC
|
|
||||||
// API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
inProgressFQDNs map[string]inProgressInfo
|
inProgressFQDNs map[string]inProgressInfo
|
||||||
inProgressAuthZones map[string]struct{}
|
inProgressAuthZones map[string]struct{}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package gandi
|
package gandi
|
||||||
|
|
||||||
// CleanUp Request->Response 1 (setZone)
|
// CleanUp Request->Response 1 (setZone).
|
||||||
const cleanup1RequestMock = `<?xml version="1.0"?>
|
const cleanupSetZoneRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.set</methodName>
|
<methodName>domain.zone.set</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -21,8 +21,8 @@ const cleanup1RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// CleanUp Request->Response 1 (setZone)
|
// CleanUp Request->Response 1 (setZone).
|
||||||
const cleanup1ResponseMock = `<?xml version='1.0'?>
|
const cleanupSetZoneResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -191,8 +191,8 @@ const cleanup1ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// CleanUp Request->Response 2 (deleteZone)
|
// CleanUp Request->Response 2 (deleteZone).
|
||||||
const cleanup2RequestMock = `<?xml version="1.0"?>
|
const cleanupDeleteZoneRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.delete</methodName>
|
<methodName>domain.zone.delete</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -207,8 +207,8 @@ const cleanup2RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// CleanUp Request->Response 2 (deleteZone)
|
// CleanUp Request->Response 2 (deleteZone).
|
||||||
const cleanup2ResponseMock = `<?xml version='1.0'?>
|
const cleanupDeleteZoneResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -218,8 +218,8 @@ const cleanup2ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// Present Request->Response 1 (getZoneID)
|
// Present Request->Response 1 (getZoneID).
|
||||||
const present1RequestMock = `<?xml version="1.0"?>
|
const presentGetZoneIDRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.info</methodName>
|
<methodName>domain.info</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -234,8 +234,8 @@ const present1RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// Present Request->Response 1 (getZoneID)
|
// Present Request->Response 1 (getZoneID).
|
||||||
const present1ResponseMock = `<?xml version='1.0'?>
|
const presentGetZoneIDResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -404,8 +404,8 @@ const present1ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// Present Request->Response 2 (cloneZone)
|
// Present Request->Response 2 (cloneZone).
|
||||||
const present2RequestMock = `<?xml version="1.0"?>
|
const presentCloneZoneRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.clone</methodName>
|
<methodName>domain.zone.clone</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -437,8 +437,8 @@ const present2RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// Present Request->Response 2 (cloneZone)
|
// Present Request->Response 2 (cloneZone).
|
||||||
const present2ResponseMock = `<?xml version='1.0'?>
|
const presentCloneZoneResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -483,8 +483,8 @@ const present2ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// Present Request->Response 3 (newZoneVersion)
|
// Present Request->Response 3 (newZoneVersion).
|
||||||
const present3RequestMock = `<?xml version="1.0"?>
|
const presentNewZoneVersionRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.version.new</methodName>
|
<methodName>domain.zone.version.new</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -499,8 +499,8 @@ const present3RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// Present Request->Response 3 (newZoneVersion)
|
// Present Request->Response 3 (newZoneVersion).
|
||||||
const present3ResponseMock = `<?xml version='1.0'?>
|
const presentNewZoneVersionResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -510,8 +510,8 @@ const present3ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// Present Request->Response 4 (addTXTRecord)
|
// Present Request->Response 4 (addTXTRecord).
|
||||||
const present4RequestMock = `<?xml version="1.0"?>
|
const presentAddTXTRecordRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.record.add</methodName>
|
<methodName>domain.zone.record.add</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -561,8 +561,8 @@ const present4RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// Present Request->Response 4 (addTXTRecord)
|
// Present Request->Response 4 (addTXTRecord).
|
||||||
const present4ResponseMock = `<?xml version='1.0'?>
|
const presentAddTXTRecordResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -593,8 +593,8 @@ const present4ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// Present Request->Response 5 (setZoneVersion)
|
// Present Request->Response 5 (setZoneVersion).
|
||||||
const present5RequestMock = `<?xml version="1.0"?>
|
const presentSetZoneVersionRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.version.set</methodName>
|
<methodName>domain.zone.version.set</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -614,8 +614,8 @@ const present5RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// Present Request->Response 5 (setZoneVersion)
|
// Present Request->Response 5 (setZoneVersion).
|
||||||
const present5ResponseMock = `<?xml version='1.0'?>
|
const presentSetZoneVersionResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
@ -625,8 +625,8 @@ const present5ResponseMock = `<?xml version='1.0'?>
|
||||||
</methodResponse>
|
</methodResponse>
|
||||||
`
|
`
|
||||||
|
|
||||||
// Present Request->Response 6 (setZone)
|
// Present Request->Response 6 (setZone).
|
||||||
const present6RequestMock = `<?xml version="1.0"?>
|
const presentSetZoneRequestMock = `<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>domain.zone.set</methodName>
|
<methodName>domain.zone.set</methodName>
|
||||||
<param>
|
<param>
|
||||||
|
@ -646,8 +646,8 @@ const present6RequestMock = `<?xml version="1.0"?>
|
||||||
</param>
|
</param>
|
||||||
</methodCall>`
|
</methodCall>`
|
||||||
|
|
||||||
// Present Request->Response 6 (setZone)
|
// Present Request->Response 6 (setZone).
|
||||||
const present6ResponseMock = `<?xml version='1.0'?>
|
const presentSetZoneResponseMock = `<?xml version='1.0'?>
|
||||||
<methodResponse>
|
<methodResponse>
|
||||||
<params>
|
<params>
|
||||||
<param>
|
<param>
|
||||||
|
|
|
@ -103,21 +103,21 @@ func TestDNSProvider(t *testing.T) {
|
||||||
// anonymizing the RPC data.
|
// anonymizing the RPC data.
|
||||||
var serverResponses = map[string]string{
|
var serverResponses = map[string]string{
|
||||||
// Present Request->Response 1 (getZoneID)
|
// Present Request->Response 1 (getZoneID)
|
||||||
present1RequestMock: present1ResponseMock,
|
presentGetZoneIDRequestMock: presentGetZoneIDResponseMock,
|
||||||
// Present Request->Response 2 (cloneZone)
|
// Present Request->Response 2 (cloneZone)
|
||||||
present2RequestMock: present2ResponseMock,
|
presentCloneZoneRequestMock: presentCloneZoneResponseMock,
|
||||||
// Present Request->Response 3 (newZoneVersion)
|
// Present Request->Response 3 (newZoneVersion)
|
||||||
present3RequestMock: present3ResponseMock,
|
presentNewZoneVersionRequestMock: presentNewZoneVersionResponseMock,
|
||||||
// Present Request->Response 4 (addTXTRecord)
|
// Present Request->Response 4 (addTXTRecord)
|
||||||
present4RequestMock: present4ResponseMock,
|
presentAddTXTRecordRequestMock: presentAddTXTRecordResponseMock,
|
||||||
// Present Request->Response 5 (setZoneVersion)
|
// Present Request->Response 5 (setZoneVersion)
|
||||||
present5RequestMock: present5ResponseMock,
|
presentSetZoneVersionRequestMock: presentSetZoneVersionResponseMock,
|
||||||
// Present Request->Response 6 (setZone)
|
// Present Request->Response 6 (setZone)
|
||||||
present6RequestMock: present6ResponseMock,
|
presentSetZoneRequestMock: presentSetZoneResponseMock,
|
||||||
// CleanUp Request->Response 1 (setZone)
|
// CleanUp Request->Response 1 (setZone)
|
||||||
cleanup1RequestMock: cleanup1ResponseMock,
|
cleanupSetZoneRequestMock: cleanupSetZoneResponseMock,
|
||||||
// CleanUp Request->Response 2 (deleteZone)
|
// CleanUp Request->Response 2 (deleteZone)
|
||||||
cleanup2RequestMock: cleanup2ResponseMock,
|
cleanupDeleteZoneRequestMock: cleanupDeleteZoneResponseMock,
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeKeyAuth := "XXXX"
|
fakeKeyAuth := "XXXX"
|
||||||
|
|
|
@ -13,13 +13,13 @@ import (
|
||||||
|
|
||||||
const apiKeyHeader = "X-Api-Key"
|
const apiKeyHeader = "X-Api-Key"
|
||||||
|
|
||||||
// types for JSON responses with only a message
|
// types for JSON responses with only a message.
|
||||||
type apiResponse struct {
|
type apiResponse struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
UUID string `json:"uuid,omitempty"`
|
UUID string `json:"uuid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record TXT record representation
|
// Record TXT record representation.
|
||||||
type Record struct {
|
type Record struct {
|
||||||
RRSetTTL int `json:"rrset_ttl"`
|
RRSetTTL int `json:"rrset_ttl"`
|
||||||
RRSetValues []string `json:"rrset_values"`
|
RRSetValues []string `json:"rrset_values"`
|
||||||
|
|
|
@ -33,13 +33,13 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// inProgressInfo contains information about an in-progress challenge
|
// inProgressInfo contains information about an in-progress challenge.
|
||||||
type inProgressInfo struct {
|
type inProgressInfo struct {
|
||||||
fieldName string
|
fieldName string
|
||||||
authZone string
|
authZone string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
APIKey string
|
APIKey string
|
||||||
|
@ -49,7 +49,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
@ -61,9 +61,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// challenge.ProviderTimeout interface that uses Gandi's LiveDNS
|
|
||||||
// API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
inProgressFQDNs map[string]inProgressInfo
|
inProgressFQDNs map[string]inProgressInfo
|
||||||
|
@ -171,9 +169,8 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timeout returns the values (20*time.Minute, 20*time.Second) which
|
// Timeout returns the timeout and interval to use when checking for DNS propagation.
|
||||||
// are used by the acme package as timeout and check interval values
|
// Adjusting here to cope with spikes in propagation times.
|
||||||
// when checking for DNS record propagation with Gandi.
|
|
||||||
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
Project string
|
Project string
|
||||||
|
@ -49,7 +49,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Debug: env.GetOrDefaultBool(EnvDebug, false),
|
Debug: env.GetOrDefaultBool(EnvDebug, false),
|
||||||
|
@ -59,7 +59,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the DNSProvider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *dns.Service
|
client *dns.Service
|
||||||
|
@ -69,7 +69,7 @@ type DNSProvider struct {
|
||||||
// By default, the project name is auto-detected by using the metadata service,
|
// By default, the project name is auto-detected by using the metadata service,
|
||||||
// it can be overridden using the GCE_PROJECT environment variable.
|
// it can be overridden using the GCE_PROJECT environment variable.
|
||||||
// A Service Account can be passed in the environment variable: GCE_SERVICE_ACCOUNT
|
// A Service Account can be passed in the environment variable: GCE_SERVICE_ACCOUNT
|
||||||
// or by specifying the keyfile location: GCE_SERVICE_ACCOUNT_FILE
|
// or by specifying the keyfile location: GCE_SERVICE_ACCOUNT_FILE.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
// Use a service account file if specified via environment variable.
|
// Use a service account file if specified via environment variable.
|
||||||
if saKey := env.GetOrFile(EnvServiceAccount); len(saKey) > 0 {
|
if saKey := env.GetOrFile(EnvServiceAccount); len(saKey) > 0 {
|
||||||
|
@ -306,7 +306,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// getHostedZone returns the managed-zone
|
// getHostedZone returns the managed-zone.
|
||||||
func (d *DNSProvider) getHostedZone(domain string) (string, error) {
|
func (d *DNSProvider) getHostedZone(domain string) (string, error) {
|
||||||
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
|
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -32,7 +32,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIUser string
|
APIUser string
|
||||||
APIKey string
|
APIKey string
|
||||||
|
@ -42,7 +42,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
@ -54,9 +54,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// challenge.ProviderTimeout interface that uses GleSYS
|
|
||||||
// API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
activeRecords map[string]int
|
activeRecords map[string]int
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNSRecord a DNS record
|
// DNSRecord a DNS record.
|
||||||
type DNSRecord struct {
|
type DNSRecord struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
|
|
|
@ -31,7 +31,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
APISecret string
|
APISecret string
|
||||||
|
@ -41,7 +41,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
@ -53,7 +53,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp sets null value in the TXT DNS record as GoDaddy has no proper DELETE record method
|
// CleanUp removes the record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@ URL = "https://godaddy.com"
|
||||||
Code = "godaddy"
|
Code = "godaddy"
|
||||||
Since = "v0.5.0"
|
Since = "v0.5.0"
|
||||||
|
|
||||||
|
Example = '''
|
||||||
|
GODADDY_API_KEY=xxxxxxxx \
|
||||||
|
GODADDY_API_SECRET=yyyyyyyy \
|
||||||
|
lego --dns godaddy --domains my.domain.com --email my@email.com run
|
||||||
|
'''
|
||||||
|
|
||||||
[Configuration]
|
[Configuration]
|
||||||
[Configuration.Credentials]
|
[Configuration.Credentials]
|
||||||
GODADDY_API_KEY = "API key"
|
GODADDY_API_KEY = "API key"
|
||||||
|
|
|
@ -48,7 +48,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
|
|
@ -25,7 +25,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
ZoneName string
|
ZoneName string
|
||||||
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
recordIDs map[string]string
|
recordIDs map[string]string
|
||||||
|
@ -56,7 +56,7 @@ type DNSProvider struct {
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for hosting.de.
|
// NewDNSProvider returns a DNSProvider instance configured for hosting.de.
|
||||||
// Credentials must be passed in the environment variables:
|
// Credentials must be passed in the environment variables:
|
||||||
// HOSTINGDE_ZONE_NAME and HOSTINGDE_API_KEY
|
// HOSTINGDE_ZONE_NAME and HOSTINGDE_API_KEY.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvAPIKey, EnvZoneName)
|
values, err := env.Get(EnvAPIKey, EnvZoneName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -96,7 +96,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ type messageRaw struct {
|
||||||
KeyAuth string `json:"keyAuth"`
|
KeyAuth string `json:"keyAuth"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Endpoint *url.URL
|
Endpoint *url.URL
|
||||||
Mode string
|
Mode string
|
||||||
|
@ -52,7 +52,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||||
|
@ -63,7 +63,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider describes a provider for acme-proxy
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
if d.config.Mode == "RAW" {
|
if d.config.Mode == "RAW" {
|
||||||
msg := &messageRaw{
|
msg := &messageRaw{
|
||||||
|
@ -136,7 +136,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
if d.config.Mode == "RAW" {
|
if d.config.Mode == "RAW" {
|
||||||
msg := &messageRaw{
|
msg := &messageRaw{
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AccessKey string
|
AccessKey string
|
||||||
SecretKey string
|
SecretKey string
|
||||||
|
@ -37,7 +37,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||||
|
@ -46,13 +46,13 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider implements the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
api *doapi.API
|
api *doapi.API
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for IIJ DO
|
// NewDNSProvider returns a DNSProvider instance configured for IIJ DNS.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvAPIAccessKey, EnvAPISecretKey, EnvDoServiceCode)
|
values, err := env.Get(EnvAPIAccessKey, EnvAPISecretKey, EnvDoServiceCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -68,7 +68,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProviderConfig takes a given config
|
// NewDNSProviderConfig takes a given config
|
||||||
// and returns a custom configured DNSProvider instance
|
// and returns a custom configured DNSProvider instance.
|
||||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
if config.SecretKey == "" || config.AccessKey == "" || config.DoServiceCode == "" {
|
if config.SecretKey == "" || config.AccessKey == "" || config.DoServiceCode == "" {
|
||||||
return nil, errors.New("iij: credentials missing")
|
return nil, errors.New("iij: credentials missing")
|
||||||
|
@ -85,7 +85,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
_, value := dns01.GetRecord(domain, keyAuth)
|
_, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
_, value := dns01.GetRecord(domain, keyAuth)
|
_, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ type Record struct {
|
||||||
Content string `json:"content,omitempty"` // Record content (not for SRV)
|
Content string `json:"content,omitempty"` // Record content (not for SRV)
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIError API error message
|
// APIError API error message.
|
||||||
type APIError struct {
|
type APIError struct {
|
||||||
Description string `json:"error"`
|
Description string `json:"error"`
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
|
|
|
@ -25,7 +25,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
@ -35,7 +35,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||||
|
@ -45,7 +45,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *goinwx.Client
|
client *goinwx.Client
|
||||||
|
@ -67,7 +67,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
return NewDNSProviderConfig(config)
|
return NewDNSProviderConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProviderConfig return a DNSProvider instance configured for Dyn DNS
|
// NewDNSProviderConfig return a DNSProvider instance configured for Dyn DNS.
|
||||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return nil, errors.New("inwx: the configuration of the DNS provider is nil")
|
return nil, errors.New("inwx: the configuration of the DNS provider is nil")
|
||||||
|
@ -86,7 +86,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config, client: client}, nil
|
return &DNSProvider{config: config, client: client}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
fqdn, _ := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
const defaultBaseURL = "https://dmapi.joker.com/request/"
|
const defaultBaseURL = "https://dmapi.joker.com/request/"
|
||||||
|
|
||||||
// Joker DMAPI Response
|
// Joker DMAPI Response.
|
||||||
type response struct {
|
type response struct {
|
||||||
Headers url.Values
|
Headers url.Values
|
||||||
Body string
|
Body string
|
||||||
|
@ -24,7 +24,7 @@ type response struct {
|
||||||
AuthSid string
|
AuthSid string
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseResponse parses HTTP response body
|
// parseResponse parses HTTP response body.
|
||||||
func parseResponse(message string) *response {
|
func parseResponse(message string) *response {
|
||||||
r := &response{Headers: url.Values{}, StatusCode: -1}
|
r := &response{Headers: url.Values{}, StatusCode: -1}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func parseResponse(message string) *response {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// login performs a login to Joker's DMAPI
|
// login performs a login to Joker's DMAPI.
|
||||||
func (d *DNSProvider) login() (*response, error) {
|
func (d *DNSProvider) login() (*response, error) {
|
||||||
if d.config.AuthSid != "" {
|
if d.config.AuthSid != "" {
|
||||||
// already logged in
|
// already logged in
|
||||||
|
@ -102,7 +102,7 @@ func (d *DNSProvider) login() (*response, error) {
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// logout closes authenticated session with Joker's DMAPI
|
// logout closes authenticated session with Joker's DMAPI.
|
||||||
func (d *DNSProvider) logout() (*response, error) {
|
func (d *DNSProvider) logout() (*response, error) {
|
||||||
if d.config.AuthSid == "" {
|
if d.config.AuthSid == "" {
|
||||||
return nil, errors.New("already logged out")
|
return nil, errors.New("already logged out")
|
||||||
|
@ -115,7 +115,7 @@ func (d *DNSProvider) logout() (*response, error) {
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// getZone returns content of DNS zone for domain
|
// getZone returns content of DNS zone for domain.
|
||||||
func (d *DNSProvider) getZone(domain string) (*response, error) {
|
func (d *DNSProvider) getZone(domain string) (*response, error) {
|
||||||
if d.config.AuthSid == "" {
|
if d.config.AuthSid == "" {
|
||||||
return nil, errors.New("must be logged in to get zone")
|
return nil, errors.New("must be logged in to get zone")
|
||||||
|
@ -124,7 +124,7 @@ func (d *DNSProvider) getZone(domain string) (*response, error) {
|
||||||
return d.postRequest("dns-zone-get", url.Values{"domain": {dns01.UnFqdn(domain)}})
|
return d.postRequest("dns-zone-get", url.Values{"domain": {dns01.UnFqdn(domain)}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// putZone uploads DNS zone to Joker DMAPI
|
// putZone uploads DNS zone to Joker DMAPI.
|
||||||
func (d *DNSProvider) putZone(domain, zone string) (*response, error) {
|
func (d *DNSProvider) putZone(domain, zone string) (*response, error) {
|
||||||
if d.config.AuthSid == "" {
|
if d.config.AuthSid == "" {
|
||||||
return nil, errors.New("must be logged in to put zone")
|
return nil, errors.New("must be logged in to put zone")
|
||||||
|
@ -133,7 +133,7 @@ func (d *DNSProvider) putZone(domain, zone string) (*response, error) {
|
||||||
return d.postRequest("dns-zone-put", url.Values{"domain": {dns01.UnFqdn(domain)}, "zone": {strings.TrimSpace(zone)}})
|
return d.postRequest("dns-zone-put", url.Values{"domain": {dns01.UnFqdn(domain)}, "zone": {strings.TrimSpace(zone)}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// postRequest performs actual HTTP request
|
// postRequest performs actual HTTP request.
|
||||||
func (d *DNSProvider) postRequest(cmd string, data url.Values) (*response, error) {
|
func (d *DNSProvider) postRequest(cmd string, data url.Values) (*response, error) {
|
||||||
uri := d.config.BaseURL + cmd
|
uri := d.config.BaseURL + cmd
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ func (d *DNSProvider) postRequest(cmd string, data url.Values) (*response, error
|
||||||
return parseResponse(string(body)), nil
|
return parseResponse(string(body)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary workaround, until it get fixed on API side
|
// Temporary workaround, until it get fixed on API side.
|
||||||
func fixTxtLines(line string) string {
|
func fixTxtLines(line string) string {
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ func fixTxtLines(line string) string {
|
||||||
return strings.Join(fields, " ")
|
return strings.Join(fields, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeTxtEntryFromZone clean-ups all TXT records with given name
|
// removeTxtEntryFromZone clean-ups all TXT records with given name.
|
||||||
func removeTxtEntryFromZone(zone, relative string) (string, bool) {
|
func removeTxtEntryFromZone(zone, relative string) (string, bool) {
|
||||||
prefix := fmt.Sprintf("%s TXT 0 ", relative)
|
prefix := fmt.Sprintf("%s TXT 0 ", relative)
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ func removeTxtEntryFromZone(zone, relative string) (string, bool) {
|
||||||
return strings.TrimSpace(strings.Join(zoneEntries, "\n")), modified
|
return strings.TrimSpace(strings.Join(zoneEntries, "\n")), modified
|
||||||
}
|
}
|
||||||
|
|
||||||
// addTxtEntryToZone returns DNS zone with added TXT record
|
// addTxtEntryToZone returns DNS zone with added TXT record.
|
||||||
func addTxtEntryToZone(zone, relative, value string, ttl int) string {
|
func addTxtEntryToZone(zone, relative, value string, ttl int) string {
|
||||||
var zoneEntries []string
|
var zoneEntries []string
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ type Config struct {
|
||||||
AuthSid string
|
AuthSid string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
BaseURL: defaultBaseURL,
|
BaseURL: defaultBaseURL,
|
||||||
|
@ -56,8 +56,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the ChallengeProviderTimeout interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// that uses Joker's DMAPI to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -190,7 +189,7 @@ func getRelative(fqdn, zone string) string {
|
||||||
return dns01.UnFqdn(strings.TrimSuffix(fqdn, dns01.ToFqdn(zone)))
|
return dns01.UnFqdn(strings.TrimSuffix(fqdn, dns01.ToFqdn(zone)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatResponseError formats error with optional details from DMAPI response
|
// formatResponseError formats error with optional details from DMAPI response.
|
||||||
func formatResponseError(response *response, err error) error {
|
func formatResponseError(response *response, err error) error {
|
||||||
if response != nil {
|
if response != nil {
|
||||||
return fmt.Errorf("joker: DMAPI error: %w Response: %v", err, response.Headers)
|
return fmt.Errorf("joker: DMAPI error: %w Response: %v", err, response.Headers)
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (c customRetryer) RetryRules(r *request.Request) time.Duration {
|
||||||
return time.Duration(delay) * time.Millisecond
|
return time.Duration(delay) * time.Millisecond
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
DNSZone string
|
DNSZone string
|
||||||
Region string
|
Region string
|
||||||
|
@ -60,7 +60,7 @@ type Config struct {
|
||||||
PollingInterval time.Duration
|
PollingInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
DNSZone: env.GetOrFile(EnvDNSZone),
|
DNSZone: env.GetOrFile(EnvDNSZone),
|
||||||
|
@ -70,7 +70,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider implements the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *lightsail.Lightsail
|
client *lightsail.Lightsail
|
||||||
config *Config
|
config *Config
|
||||||
|
@ -113,7 +113,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockResponse represents a predefined response used by a mock server
|
// MockResponse represents a predefined response used by a mock server.
|
||||||
type MockResponse struct {
|
type MockResponse struct {
|
||||||
StatusCode int
|
StatusCode int
|
||||||
Body string
|
Body string
|
||||||
|
|
|
@ -28,14 +28,14 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
PollingInterval time.Duration
|
PollingInterval time.Duration
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
|
|
@ -34,7 +34,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Token string
|
Token string
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
|
@ -43,7 +43,7 @@ type Config struct {
|
||||||
HTTPTimeout time.Duration
|
HTTPTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
|
|
@ -31,7 +31,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
Username string
|
Username string
|
||||||
|
@ -43,7 +43,7 @@ type Config struct {
|
||||||
HTTPTimeout time.Duration
|
HTTPTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
config := &Config{
|
config := &Config{
|
||||||
BaseURL: defaultBaseURL,
|
BaseURL: defaultBaseURL,
|
||||||
|
@ -56,8 +56,7 @@ func NewDefaultConfig() *Config {
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// that uses Liquid Web's REST API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *lw.API
|
client *lw.API
|
||||||
|
@ -122,7 +121,7 @@ func (d *DNSProvider) Timeout() (time.Duration, time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -146,7 +145,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
d.recordIDsMu.Lock()
|
d.recordIDsMu.Lock()
|
||||||
recordID, ok := d.recordIDs[token]
|
recordID, ok := d.recordIDs[token]
|
||||||
|
|
|
@ -25,7 +25,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MasterID string
|
MasterID string
|
||||||
Password string
|
Password string
|
||||||
|
@ -34,7 +34,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 2*time.Minute),
|
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 2*time.Minute),
|
||||||
|
@ -45,7 +45,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
_, value := dns01.GetRecord(domain, keyAuth)
|
_, value := dns01.GetRecord(domain, keyAuth)
|
||||||
err := d.doRequest(domain, value, "REGIST")
|
err := d.doRequest(domain, value, "REGIST")
|
||||||
|
@ -94,7 +94,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
_, value := dns01.GetRecord(domain, keyAuth)
|
_, value := dns01.GetRecord(domain, keyAuth)
|
||||||
err := d.doRequest(domain, value, "DELETE")
|
err := d.doRequest(domain, value, "DELETE")
|
||||||
|
|
|
@ -27,7 +27,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
UserName string
|
UserName string
|
||||||
Password string
|
Password string
|
||||||
|
@ -39,7 +39,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() (*Config, error) {
|
func NewDefaultConfig() (*Config, error) {
|
||||||
apiEndpoint, err := url.Parse(env.GetOrDefaultString(EnvAPIEndpoint, apiBaseURL))
|
apiEndpoint, err := url.Parse(env.GetOrDefaultString(EnvAPIEndpoint, apiBaseURL))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -63,8 +63,7 @@ func NewDefaultConfig() (*Config, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface that uses
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// Mythic Beasts' DNSv2 API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
token string
|
token string
|
||||||
|
@ -89,7 +88,7 @@ func NewDNSProvider() (*DNSProvider, error) {
|
||||||
return NewDNSProviderConfig(config)
|
return NewDNSProviderConfig(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProviderConfig return a DNSProvider instance configured for mythicbeasts DNSv2 API
|
// NewDNSProviderConfig return a DNSProvider instance configured for mythicbeasts DNSv2 API.
|
||||||
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return nil, errors.New("mythicbeasts: the configuration of the DNS provider is nil")
|
return nil, errors.New("mythicbeasts: the configuration of the DNS provider is nil")
|
||||||
|
@ -102,7 +101,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{config: config}, nil
|
return &DNSProvider{config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A challenge represents all the data needed to specify a dns-01 challenge
|
// A challenge represents all the data needed to specify a dns-01 challenge to lets-encrypt.
|
||||||
// to lets-encrypt.
|
|
||||||
type challenge struct {
|
type challenge struct {
|
||||||
domain string
|
domain string
|
||||||
key string
|
key string
|
||||||
|
@ -63,7 +62,7 @@ type challenge struct {
|
||||||
host string
|
host string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
BaseURL string
|
BaseURL string
|
||||||
|
@ -76,7 +75,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
baseURL := defaultBaseURL
|
baseURL := defaultBaseURL
|
||||||
if env.GetOrDefaultBool(EnvSandbox, false) {
|
if env.GetOrDefaultBool(EnvSandbox, false) {
|
||||||
|
@ -95,8 +94,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the ChallengeProviderTimeout interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
// that uses Namecheap's tool API to manage TXT records for a domain.
|
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Username string
|
Username string
|
||||||
APIToken string
|
APIToken string
|
||||||
|
@ -41,7 +41,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||||
|
@ -53,7 +53,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *namecom.NameCom
|
client *namecom.NameCom
|
||||||
config *Config
|
config *Config
|
||||||
|
@ -61,7 +61,7 @@ type DNSProvider struct {
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for namedotcom.
|
// NewDNSProvider returns a DNSProvider instance configured for namedotcom.
|
||||||
// Credentials must be passed in the environment variables:
|
// Credentials must be passed in the environment variables:
|
||||||
// NAMECOM_USERNAME and NAMECOM_API_TOKEN
|
// NAMECOM_USERNAME and NAMECOM_API_TOKEN.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvUsername, EnvAPIToken)
|
values, err := env.Get(EnvUsername, EnvAPIToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -28,7 +28,7 @@ const (
|
||||||
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
PropagationTimeout time.Duration
|
PropagationTimeout time.Duration
|
||||||
|
@ -36,7 +36,7 @@ type Config struct {
|
||||||
TTL int
|
TTL int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, defaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, defaultTTL),
|
||||||
|
@ -45,7 +45,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *namesilo.Client
|
client *namesilo.Client
|
||||||
config *Config
|
config *Config
|
||||||
|
|
|
@ -10,21 +10,21 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// defaultBaseURL for reaching the jSON-based API-Endpoint of netcup
|
// defaultBaseURL for reaching the jSON-based API-Endpoint of netcup.
|
||||||
const defaultBaseURL = "https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
|
const defaultBaseURL = "https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
|
||||||
|
|
||||||
// success response status
|
// success response status.
|
||||||
const success = "success"
|
const success = "success"
|
||||||
|
|
||||||
// Request wrapper as specified in netcup wiki
|
// Request wrapper as specified in netcup wiki
|
||||||
// needed for every request to netcup API around *Msg
|
// needed for every request to netcup API around *Msg.
|
||||||
// https://www.netcup-wiki.de/wiki/CCP_API#Anmerkungen_zu_JSON-Requests
|
// https://www.netcup-wiki.de/wiki/CCP_API#Anmerkungen_zu_JSON-Requests
|
||||||
type Request struct {
|
type Request struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
Param interface{} `json:"param"`
|
Param interface{} `json:"param"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoginRequest as specified in netcup WSDL
|
// LoginRequest as specified in netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#login
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#login
|
||||||
type LoginRequest struct {
|
type LoginRequest struct {
|
||||||
CustomerNumber string `json:"customernumber"`
|
CustomerNumber string `json:"customernumber"`
|
||||||
|
@ -33,7 +33,7 @@ type LoginRequest struct {
|
||||||
ClientRequestID string `json:"clientrequestid,omitempty"`
|
ClientRequestID string `json:"clientrequestid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogoutRequest as specified in netcup WSDL
|
// LogoutRequest as specified in netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#logout
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#logout
|
||||||
type LogoutRequest struct {
|
type LogoutRequest struct {
|
||||||
CustomerNumber string `json:"customernumber"`
|
CustomerNumber string `json:"customernumber"`
|
||||||
|
@ -42,7 +42,7 @@ type LogoutRequest struct {
|
||||||
ClientRequestID string `json:"clientrequestid,omitempty"`
|
ClientRequestID string `json:"clientrequestid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateDNSRecordsRequest as specified in netcup WSDL
|
// UpdateDNSRecordsRequest as specified in netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#updateDnsRecords
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#updateDnsRecords
|
||||||
type UpdateDNSRecordsRequest struct {
|
type UpdateDNSRecordsRequest struct {
|
||||||
DomainName string `json:"domainname"`
|
DomainName string `json:"domainname"`
|
||||||
|
@ -53,14 +53,14 @@ type UpdateDNSRecordsRequest struct {
|
||||||
DNSRecordSet DNSRecordSet `json:"dnsrecordset"`
|
DNSRecordSet DNSRecordSet `json:"dnsrecordset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSRecordSet as specified in netcup WSDL
|
// DNSRecordSet as specified in netcup WSDL.
|
||||||
// needed in UpdateDNSRecordsRequest
|
// needed in UpdateDNSRecordsRequest
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#Dnsrecordset
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#Dnsrecordset
|
||||||
type DNSRecordSet struct {
|
type DNSRecordSet struct {
|
||||||
DNSRecords []DNSRecord `json:"dnsrecords"`
|
DNSRecords []DNSRecord `json:"dnsrecords"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InfoDNSRecordsRequest as specified in netcup WSDL
|
// InfoDNSRecordsRequest as specified in netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#infoDnsRecords
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#infoDnsRecords
|
||||||
type InfoDNSRecordsRequest struct {
|
type InfoDNSRecordsRequest struct {
|
||||||
DomainName string `json:"domainname"`
|
DomainName string `json:"domainname"`
|
||||||
|
@ -70,7 +70,7 @@ type InfoDNSRecordsRequest struct {
|
||||||
ClientRequestID string `json:"clientrequestid,omitempty"`
|
ClientRequestID string `json:"clientrequestid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSRecord as specified in netcup WSDL
|
// DNSRecord as specified in netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#Dnsrecord
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#Dnsrecord
|
||||||
type DNSRecord struct {
|
type DNSRecord struct {
|
||||||
ID int `json:"id,string,omitempty"`
|
ID int `json:"id,string,omitempty"`
|
||||||
|
@ -83,7 +83,7 @@ type DNSRecord struct {
|
||||||
TTL int `json:"ttl,omitempty"`
|
TTL int `json:"ttl,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResponseMsg as specified in netcup WSDL
|
// ResponseMsg as specified in netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#Responsemessage
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php#Responsemessage
|
||||||
type ResponseMsg struct {
|
type ResponseMsg struct {
|
||||||
ServerRequestID string `json:"serverrequestid"`
|
ServerRequestID string `json:"serverrequestid"`
|
||||||
|
@ -112,7 +112,7 @@ type InfoDNSRecordsResponse struct {
|
||||||
DNSRecords []DNSRecord `json:"dnsrecords,omitempty"`
|
DNSRecords []DNSRecord `json:"dnsrecords,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client netcup DNS client
|
// Client netcup DNS client.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
customerNumber string
|
customerNumber string
|
||||||
apiKey string
|
apiKey string
|
||||||
|
@ -121,7 +121,7 @@ type Client struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a netcup DNS client
|
// NewClient creates a netcup DNS client.
|
||||||
func NewClient(customerNumber string, apiKey string, apiPassword string) (*Client, error) {
|
func NewClient(customerNumber string, apiKey string, apiPassword string) (*Client, error) {
|
||||||
if customerNumber == "" || apiKey == "" || apiPassword == "" {
|
if customerNumber == "" || apiKey == "" || apiPassword == "" {
|
||||||
return nil, errors.New("credentials missing")
|
return nil, errors.New("credentials missing")
|
||||||
|
@ -139,7 +139,7 @@ func NewClient(customerNumber string, apiKey string, apiPassword string) (*Clien
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login performs the login as specified by the netcup WSDL
|
// Login performs the login as specified by the netcup WSDL
|
||||||
// returns sessionID needed to perform remaining actions
|
// returns sessionID needed to perform remaining actions.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
||||||
func (c *Client) Login() (string, error) {
|
func (c *Client) Login() (string, error) {
|
||||||
payload := &Request{
|
payload := &Request{
|
||||||
|
@ -161,7 +161,7 @@ func (c *Client) Login() (string, error) {
|
||||||
return responseData.APISessionID, nil
|
return responseData.APISessionID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logout performs the logout with the supplied sessionID as specified by the netcup WSDL
|
// Logout performs the logout with the supplied sessionID as specified by the netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
||||||
func (c *Client) Logout(sessionID string) error {
|
func (c *Client) Logout(sessionID string) error {
|
||||||
payload := &Request{
|
payload := &Request{
|
||||||
|
@ -182,7 +182,7 @@ func (c *Client) Logout(sessionID string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateDNSRecord performs an update of the DNSRecords as specified by the netcup WSDL
|
// UpdateDNSRecord performs an update of the DNSRecords as specified by the netcup WSDL.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
||||||
func (c *Client) UpdateDNSRecord(sessionID, domainName string, records []DNSRecord) error {
|
func (c *Client) UpdateDNSRecord(sessionID, domainName string, records []DNSRecord) error {
|
||||||
payload := &Request{
|
payload := &Request{
|
||||||
|
@ -206,7 +206,7 @@ func (c *Client) UpdateDNSRecord(sessionID, domainName string, records []DNSReco
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSRecords retrieves all dns records of an DNS-Zone as specified by the netcup WSDL
|
// GetDNSRecords retrieves all dns records of an DNS-Zone as specified by the netcup WSDL
|
||||||
// returns an array of DNSRecords
|
// returns an array of DNSRecords.
|
||||||
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
// https://ccp.netcup.net/run/webservice/servers/endpoint.php
|
||||||
func (c *Client) GetDNSRecords(hostname, apiSessionID string) ([]DNSRecord, error) {
|
func (c *Client) GetDNSRecords(hostname, apiSessionID string) ([]DNSRecord, error) {
|
||||||
payload := &Request{
|
payload := &Request{
|
||||||
|
@ -230,7 +230,7 @@ func (c *Client) GetDNSRecords(hostname, apiSessionID string) ([]DNSRecord, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// doRequest marshals given body to JSON, send the request to netcup API
|
// doRequest marshals given body to JSON, send the request to netcup API
|
||||||
// and returns body of response
|
// and returns body of response.
|
||||||
func (c *Client) doRequest(payload interface{}, responseData interface{}) error {
|
func (c *Client) doRequest(payload interface{}, responseData interface{}) error {
|
||||||
body, err := json.Marshal(payload)
|
body, err := json.Marshal(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -316,7 +316,7 @@ func decodeResponseMsg(resp *http.Response) (*ResponseMsg, error) {
|
||||||
|
|
||||||
// GetDNSRecordIdx searches a given array of DNSRecords for a given DNSRecord
|
// GetDNSRecordIdx searches a given array of DNSRecords for a given DNSRecord
|
||||||
// equivalence is determined by Destination and RecortType attributes
|
// equivalence is determined by Destination and RecortType attributes
|
||||||
// returns index of given DNSRecord in given array of DNSRecords
|
// returns index of given DNSRecord in given array of DNSRecords.
|
||||||
func GetDNSRecordIdx(records []DNSRecord, record DNSRecord) (int, error) {
|
func GetDNSRecordIdx(records []DNSRecord, record DNSRecord) (int, error) {
|
||||||
for index, element := range records {
|
for index, element := range records {
|
||||||
if record.Destination == element.Destination && record.RecordType == element.RecordType {
|
if record.Destination == element.Destination && record.RecordType == element.RecordType {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Key string
|
Key string
|
||||||
Password string
|
Password string
|
||||||
|
@ -40,7 +40,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -52,7 +52,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
config *Config
|
config *Config
|
||||||
|
@ -60,7 +60,7 @@ type DNSProvider struct {
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for netcup.
|
// NewDNSProvider returns a DNSProvider instance configured for netcup.
|
||||||
// Credentials must be passed in the environment variables:
|
// Credentials must be passed in the environment variables:
|
||||||
// NETCUP_CUSTOMER_NUMBER, NETCUP_API_KEY, NETCUP_API_PASSWORD
|
// NETCUP_CUSTOMER_NUMBER, NETCUP_API_KEY, NETCUP_API_PASSWORD.
|
||||||
func NewDNSProvider() (*DNSProvider, error) {
|
func NewDNSProvider() (*DNSProvider, error) {
|
||||||
values, err := env.Get(EnvCustomerNumber, EnvAPIKey, EnvAPIPassword)
|
values, err := env.Get(EnvCustomerNumber, EnvAPIKey, EnvAPIPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -91,7 +91,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{client: client, config: config}, nil
|
return &DNSProvider{client: client, config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record to fulfill the dns-01 challenge
|
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||||
func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domainName, keyAuth)
|
fqdn, value := dns01.GetRecord(domainName, keyAuth)
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domainName, keyAuth)
|
fqdn, value := dns01.GetRecord(domainName, keyAuth)
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider is an implementation of the challenge.Provider interface.
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
config *Config
|
config *Config
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
|
|
|
@ -87,7 +87,7 @@ type ChangeInfo struct {
|
||||||
SubmittedAt string `xml:"SubmittedAt"`
|
SubmittedAt string `xml:"SubmittedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient Creates a new client of NIFCLOUD DNS
|
// NewClient Creates a new client of NIFCLOUD DNS.
|
||||||
func NewClient(accessKey string, secretKey string) (*Client, error) {
|
func NewClient(accessKey string, secretKey string) (*Client, error) {
|
||||||
if len(accessKey) == 0 || len(secretKey) == 0 {
|
if len(accessKey) == 0 || len(secretKey) == 0 {
|
||||||
return nil, errors.New("credentials missing")
|
return nil, errors.New("credentials missing")
|
||||||
|
@ -101,7 +101,7 @@ func NewClient(accessKey string, secretKey string) (*Client, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client client of NIFCLOUD DNS
|
// Client client of NIFCLOUD DNS.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
accessKey string
|
accessKey string
|
||||||
secretKey string
|
secretKey string
|
||||||
|
|
|
@ -28,7 +28,7 @@ const (
|
||||||
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is used to configure the creation of the DNSProvider
|
// Config is used to configure the creation of the DNSProvider.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
AccessKey string
|
AccessKey string
|
||||||
|
@ -39,7 +39,7 @@ type Config struct {
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||||
func NewDefaultConfig() *Config {
|
func NewDefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||||
|
@ -51,7 +51,7 @@ func NewDefaultConfig() *Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNSProvider implements the challenge.Provider interface
|
// DNSProvider implements the challenge.Provider interface.
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
client *internal.Client
|
client *internal.Client
|
||||||
config *Config
|
config *Config
|
||||||
|
@ -96,7 +96,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
||||||
return &DNSProvider{client: client, config: config}, nil
|
return &DNSProvider{client: client, config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present creates a TXT record using the specified parameters
|
// Present creates a TXT record using the specified parameters.
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the TXT record matching the specified parameters
|
// CleanUp removes the TXT record matching the specified parameters.
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue