mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
chore: delete old dns01 and rename dnsnew to dns01
This commit is contained in:
parent
52f09c1c2b
commit
8ff6f0b0fc
261 changed files with 1632 additions and 3788 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
//go:build !windows
|
||||
|
||||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import "time"
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
//go:build windows
|
||||
|
||||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import "time"
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package dns01
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// Update FQDN with CNAME if any.
|
||||
func updateDomainWithCName(r *dns.Msg, fqdn string) string {
|
||||
for _, rr := range r.Answer {
|
||||
if cn, ok := rr.(*dns.CNAME); ok {
|
||||
if strings.EqualFold(cn.Hdr.Name, fqdn) {
|
||||
return cn.Target
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fqdn
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/go-acme/lego/v5/platform/wait"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -31,36 +30,20 @@ const (
|
|||
|
||||
type ValidateFunc func(ctx context.Context, core *api.Core, domain string, chlng acme.Challenge) error
|
||||
|
||||
type ChallengeOption func(*Challenge) error
|
||||
|
||||
// CondOption Conditional challenge option.
|
||||
func CondOption(condition bool, opt ChallengeOption) ChallengeOption {
|
||||
if !condition {
|
||||
// NoOp options
|
||||
return func(*Challenge) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Challenge implements the dns-01 challenge.
|
||||
type Challenge struct {
|
||||
core *api.Core
|
||||
validate ValidateFunc
|
||||
provider challenge.Provider
|
||||
preCheck preCheck
|
||||
dnsTimeout time.Duration
|
||||
core *api.Core
|
||||
validate ValidateFunc
|
||||
provider challenge.Provider
|
||||
preCheck preCheck
|
||||
}
|
||||
|
||||
func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Provider, opts ...ChallengeOption) *Challenge {
|
||||
chlg := &Challenge{
|
||||
core: core,
|
||||
validate: validate,
|
||||
provider: provider,
|
||||
preCheck: newPreCheck(),
|
||||
dnsTimeout: 10 * time.Second,
|
||||
core: core,
|
||||
validate: validate,
|
||||
provider: provider,
|
||||
preCheck: newPreCheck(),
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
|
|
@ -74,7 +57,7 @@ func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Prov
|
|||
}
|
||||
|
||||
// PreSolve just submits the txt record to the dns provider.
|
||||
// It does not validate record propagation, or do anything at all with the acme server.
|
||||
// It does not validate record propagation or do anything at all with the ACME server.
|
||||
func (c *Challenge) PreSolve(ctx context.Context, authz acme.Authorization) error {
|
||||
domain := challenge.GetTargetedDomain(authz)
|
||||
log.Info("acme: Preparing to solve DNS-01.", "domain", domain)
|
||||
|
|
@ -117,7 +100,7 @@ func (c *Challenge) Solve(ctx context.Context, authz acme.Authorization) error {
|
|||
return err
|
||||
}
|
||||
|
||||
info := GetChallengeInfo(authz.Identifier.Value, keyAuth)
|
||||
info := GetChallengeInfo(ctx, authz.Identifier.Value, keyAuth)
|
||||
|
||||
var timeout, interval time.Duration
|
||||
|
||||
|
|
@ -128,12 +111,13 @@ func (c *Challenge) Solve(ctx context.Context, authz acme.Authorization) error {
|
|||
timeout, interval = DefaultPropagationTimeout, DefaultPollingInterval
|
||||
}
|
||||
|
||||
log.Info("acme: Checking DNS record propagation.", "domain", domain, "nameservers", strings.Join(recursiveNameservers, ","))
|
||||
log.Info("acme: Checking DNS record propagation.",
|
||||
"domain", domain, "nameservers", strings.Join(DefaultClient().recursiveNameservers, ","))
|
||||
|
||||
time.Sleep(interval)
|
||||
|
||||
err = wait.For("propagation", timeout, interval, func() (bool, error) {
|
||||
stop, errP := c.preCheck.call(domain, info.EffectiveFQDN, info.Value)
|
||||
stop, errP := c.preCheck.call(ctx, domain, info.EffectiveFQDN, info.Value)
|
||||
if !stop || errP != nil {
|
||||
log.Info("acme: Waiting for DNS record propagation.", "domain", domain)
|
||||
}
|
||||
|
|
@ -178,15 +162,6 @@ type sequential interface {
|
|||
Sequential() time.Duration
|
||||
}
|
||||
|
||||
// GetRecord returns a DNS record which will fulfill the `dns-01` challenge.
|
||||
//
|
||||
// Deprecated: use GetChallengeInfo instead.
|
||||
func GetRecord(domain, keyAuth string) (fqdn, value string) {
|
||||
info := GetChallengeInfo(domain, keyAuth)
|
||||
|
||||
return info.EffectiveFQDN, info.Value
|
||||
}
|
||||
|
||||
// ChallengeInfo contains the information use to create the TXT record.
|
||||
type ChallengeInfo struct {
|
||||
// FQDN is the full-qualified challenge domain (i.e. `_acme-challenge.[domain].`)
|
||||
|
|
@ -200,7 +175,7 @@ type ChallengeInfo struct {
|
|||
}
|
||||
|
||||
// GetChallengeInfo returns information used to create a DNS record which will fulfill the `dns-01` challenge.
|
||||
func GetChallengeInfo(domain, keyAuth string) ChallengeInfo {
|
||||
func GetChallengeInfo(ctx context.Context, domain, keyAuth string) ChallengeInfo {
|
||||
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
|
||||
// base64URL encoding without padding
|
||||
value := base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size])
|
||||
|
|
@ -209,38 +184,17 @@ func GetChallengeInfo(domain, keyAuth string) ChallengeInfo {
|
|||
|
||||
return ChallengeInfo{
|
||||
Value: value,
|
||||
FQDN: getChallengeFQDN(domain, false),
|
||||
EffectiveFQDN: getChallengeFQDN(domain, !ok),
|
||||
FQDN: getChallengeFQDN(ctx, domain, false),
|
||||
EffectiveFQDN: getChallengeFQDN(ctx, domain, !ok),
|
||||
}
|
||||
}
|
||||
|
||||
func getChallengeFQDN(domain string, followCNAME bool) string {
|
||||
func getChallengeFQDN(ctx context.Context, domain string, followCNAME bool) string {
|
||||
fqdn := fmt.Sprintf("_acme-challenge.%s.", domain)
|
||||
|
||||
if !followCNAME {
|
||||
return fqdn
|
||||
}
|
||||
|
||||
// recursion counter so it doesn't spin out of control
|
||||
for range 50 {
|
||||
// Keep following CNAMEs
|
||||
r, err := dnsQuery(fqdn, dns.TypeCNAME, recursiveNameservers, true)
|
||||
|
||||
if err != nil || r.Rcode != dns.RcodeSuccess {
|
||||
// No more CNAME records to follow, exit
|
||||
break
|
||||
}
|
||||
|
||||
// Check if the domain has CNAME then use that
|
||||
cname := updateDomainWithCName(r, fqdn)
|
||||
if cname == fqdn {
|
||||
break
|
||||
}
|
||||
|
||||
log.Info("Found CNAME entry.", "fqdn", fqdn, "cname", cname)
|
||||
|
||||
fqdn = cname
|
||||
}
|
||||
|
||||
return fqdn
|
||||
return DefaultClient().lookupCNAME(ctx, fqdn)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
package dns01
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
dnsTemplate = `%s %d IN TXT %q`
|
||||
)
|
||||
|
||||
// DNSProviderManual is an implementation of the ChallengeProvider interface.
|
||||
// TODO(ldez): move this to providers/dns/manual
|
||||
//
|
||||
// Deprecated: Use the manual.DNSProvider instead.
|
||||
type DNSProviderManual struct{}
|
||||
|
||||
// NewDNSProviderManual returns a DNSProviderManual instance.
|
||||
//
|
||||
// Deprecated: Use the manual.NewDNSProvider instead.
|
||||
func NewDNSProviderManual() (*DNSProviderManual, error) {
|
||||
return &DNSProviderManual{}, nil
|
||||
}
|
||||
|
||||
// Present prints instructions for manually creating the TXT record.
|
||||
func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
|
||||
info := GetChallengeInfo(domain, keyAuth)
|
||||
|
||||
authZone, err := FindZoneByFqdn(info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("manual: could not find zone: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("lego: Please create the following TXT record in your %s zone:\n", authZone)
|
||||
fmt.Printf(dnsTemplate+"\n", info.EffectiveFQDN, DefaultTTL, info.Value)
|
||||
fmt.Printf("lego: Press 'Enter' when you are done\n")
|
||||
|
||||
_, err = bufio.NewReader(os.Stdin).ReadBytes('\n')
|
||||
if err != nil {
|
||||
return fmt.Errorf("manual: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CleanUp prints instructions for manually removing the TXT record.
|
||||
func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error {
|
||||
info := GetChallengeInfo(domain, keyAuth)
|
||||
|
||||
authZone, err := FindZoneByFqdn(info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("manual: could not find zone: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("lego: You can now remove this TXT record from your %s zone:\n", authZone)
|
||||
fmt.Printf(dnsTemplate+"\n", info.EffectiveFQDN, DefaultTTL, "...")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sequential All DNS challenges for this provider will be resolved sequentially.
|
||||
// Returns the interval between each iteration.
|
||||
func (d *DNSProviderManual) Sequential() time.Duration {
|
||||
return DefaultPropagationTimeout
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dnsnew
|
||||
package dns01
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
@ -52,13 +52,13 @@ func TestChallenge_PreSolve(t *testing.T) {
|
|||
{
|
||||
desc: "success",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{},
|
||||
},
|
||||
{
|
||||
desc: "validate fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return errors.New("OOPS") },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: nil,
|
||||
cleanUp: nil,
|
||||
|
|
@ -67,7 +67,9 @@ func TestChallenge_PreSolve(t *testing.T) {
|
|||
{
|
||||
desc: "preCheck fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return false, errors.New("OOPS") },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) {
|
||||
return false, errors.New("OOPS")
|
||||
},
|
||||
provider: &providerTimeoutMock{
|
||||
timeout: 2 * time.Second,
|
||||
interval: 500 * time.Millisecond,
|
||||
|
|
@ -76,7 +78,7 @@ func TestChallenge_PreSolve(t *testing.T) {
|
|||
{
|
||||
desc: "present fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: errors.New("OOPS"),
|
||||
},
|
||||
|
|
@ -85,7 +87,7 @@ func TestChallenge_PreSolve(t *testing.T) {
|
|||
{
|
||||
desc: "cleanUp fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
cleanUp: errors.New("OOPS"),
|
||||
},
|
||||
|
|
@ -116,7 +118,7 @@ func TestChallenge_PreSolve(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestChallenge_Solve(t *testing.T) {
|
||||
useAsNameserver(t, dnsmock.NewServer().
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.Noop).
|
||||
Build(t))
|
||||
|
||||
|
|
@ -138,13 +140,13 @@ func TestChallenge_Solve(t *testing.T) {
|
|||
{
|
||||
desc: "success",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{},
|
||||
},
|
||||
{
|
||||
desc: "validate fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return errors.New("OOPS") },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: nil,
|
||||
cleanUp: nil,
|
||||
|
|
@ -154,7 +156,9 @@ func TestChallenge_Solve(t *testing.T) {
|
|||
{
|
||||
desc: "preCheck fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return false, errors.New("OOPS") },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) {
|
||||
return false, errors.New("OOPS")
|
||||
},
|
||||
provider: &providerTimeoutMock{
|
||||
timeout: 2 * time.Second,
|
||||
interval: 500 * time.Millisecond,
|
||||
|
|
@ -164,7 +168,7 @@ func TestChallenge_Solve(t *testing.T) {
|
|||
{
|
||||
desc: "present fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: errors.New("OOPS"),
|
||||
},
|
||||
|
|
@ -172,7 +176,7 @@ func TestChallenge_Solve(t *testing.T) {
|
|||
{
|
||||
desc: "cleanUp fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
cleanUp: errors.New("OOPS"),
|
||||
},
|
||||
|
|
@ -226,13 +230,13 @@ func TestChallenge_CleanUp(t *testing.T) {
|
|||
{
|
||||
desc: "success",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{},
|
||||
},
|
||||
{
|
||||
desc: "validate fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return errors.New("OOPS") },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: nil,
|
||||
cleanUp: nil,
|
||||
|
|
@ -241,7 +245,9 @@ func TestChallenge_CleanUp(t *testing.T) {
|
|||
{
|
||||
desc: "preCheck fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return false, errors.New("OOPS") },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) {
|
||||
return false, errors.New("OOPS")
|
||||
},
|
||||
provider: &providerTimeoutMock{
|
||||
timeout: 2 * time.Second,
|
||||
interval: 500 * time.Millisecond,
|
||||
|
|
@ -250,7 +256,7 @@ func TestChallenge_CleanUp(t *testing.T) {
|
|||
{
|
||||
desc: "present fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: errors.New("OOPS"),
|
||||
},
|
||||
|
|
@ -258,7 +264,7 @@ func TestChallenge_CleanUp(t *testing.T) {
|
|||
{
|
||||
desc: "cleanUp fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
cleanUp: errors.New("OOPS"),
|
||||
},
|
||||
|
|
@ -290,11 +296,11 @@ func TestChallenge_CleanUp(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChallengeInfo(t *testing.T) {
|
||||
useAsNameserver(t, dnsmock.NewServer().
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.Noop).
|
||||
Build(t))
|
||||
|
||||
info := GetChallengeInfo("example.com", "123")
|
||||
info := GetChallengeInfo(t.Context(), "example.com", "123")
|
||||
|
||||
expected := ChallengeInfo{
|
||||
FQDN: "_acme-challenge.example.com.",
|
||||
|
|
@ -306,12 +312,12 @@ func TestGetChallengeInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChallengeInfo_CNAME(t *testing.T) {
|
||||
useAsNameserver(t, dnsmock.NewServer().
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.CNAME("example.org.")).
|
||||
Query("example.org. CNAME", dnsmock.Noop).
|
||||
Build(t))
|
||||
|
||||
info := GetChallengeInfo("example.com", "123")
|
||||
info := GetChallengeInfo(t.Context(), "example.com", "123")
|
||||
|
||||
expected := ChallengeInfo{
|
||||
FQDN: "_acme-challenge.example.com.",
|
||||
|
|
@ -323,14 +329,14 @@ func TestGetChallengeInfo_CNAME(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetChallengeInfo_CNAME_disabled(t *testing.T) {
|
||||
useAsNameserver(t, dnsmock.NewServer().
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
// Never called when the env var works.
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.CNAME("example.org.")).
|
||||
Build(t))
|
||||
|
||||
t.Setenv("LEGO_DISABLE_CNAME_SUPPORT", "true")
|
||||
|
||||
info := GetChallengeInfo("example.com", "123")
|
||||
info := GetChallengeInfo(t.Context(), "example.com", "123")
|
||||
|
||||
expected := ChallengeInfo{
|
||||
FQDN: "_acme-challenge.example.com.",
|
||||
|
|
|
|||
|
|
@ -6,13 +6,6 @@ import (
|
|||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// ToFqdn converts the name into a fqdn appending a trailing dot.
|
||||
//
|
||||
// Deprecated: Use [github.com/miekg/dns.Fqdn] directly.
|
||||
func ToFqdn(name string) string {
|
||||
return dns.Fqdn(name)
|
||||
}
|
||||
|
||||
// UnFqdn converts the fqdn into a name removing the trailing dot.
|
||||
func UnFqdn(name string) string {
|
||||
n := len(name)
|
||||
|
|
|
|||
|
|
@ -32,50 +32,47 @@ func fakeTXT(name, value string) *dns.TXT {
|
|||
}
|
||||
|
||||
// mockResolver modifies the default DNS resolver to use a custom network address during the test execution.
|
||||
// IMPORTANT: it modifying global variables.
|
||||
func mockResolver(t *testing.T, addr net.Addr) {
|
||||
t.Helper()
|
||||
// IMPORTANT: it modifying std global variables.
|
||||
func mockResolver(authoritativeNS net.Addr) func(t *testing.T, client *Client) {
|
||||
return func(t *testing.T, client *Client) {
|
||||
t.Helper()
|
||||
|
||||
_, port, err := net.SplitHostPort(addr.String())
|
||||
require.NoError(t, err)
|
||||
_, port, err := net.SplitHostPort(authoritativeNS.String())
|
||||
require.NoError(t, err)
|
||||
|
||||
originalDefaultNameserverPort := defaultNameserverPort
|
||||
client.authoritativeNSPort = port
|
||||
|
||||
t.Cleanup(func() {
|
||||
defaultNameserverPort = originalDefaultNameserverPort
|
||||
})
|
||||
originalResolver := net.DefaultResolver
|
||||
|
||||
defaultNameserverPort = port
|
||||
t.Cleanup(func() {
|
||||
net.DefaultResolver = originalResolver
|
||||
})
|
||||
|
||||
originalResolver := net.DefaultResolver
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{Timeout: 1 * time.Second}
|
||||
|
||||
t.Cleanup(func() {
|
||||
net.DefaultResolver = originalResolver
|
||||
})
|
||||
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{Timeout: 1 * time.Second}
|
||||
|
||||
return d.DialContext(ctx, network, addr.String())
|
||||
},
|
||||
return d.DialContext(ctx, network, authoritativeNS.String())
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func useAsNameserver(t *testing.T, addr net.Addr) {
|
||||
func mockDefault(t *testing.T, recursiveNS net.Addr, opts ...func(t *testing.T, client *Client)) {
|
||||
t.Helper()
|
||||
|
||||
ClearFqdnCache()
|
||||
t.Cleanup(func() {
|
||||
ClearFqdnCache()
|
||||
})
|
||||
|
||||
originalRecursiveNameservers := recursiveNameservers
|
||||
backup := DefaultClient()
|
||||
|
||||
t.Cleanup(func() {
|
||||
recursiveNameservers = originalRecursiveNameservers
|
||||
SetDefaultClient(backup)
|
||||
})
|
||||
|
||||
recursiveNameservers = ParseNameservers([]string{addr.String()})
|
||||
client := NewClient(&Options{RecursiveNameservers: []string{recursiveNS.String()}})
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(t, client)
|
||||
}
|
||||
|
||||
SetDefaultClient(client)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,354 +0,0 @@
|
|||
package dns01
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
const defaultResolvConf = "/etc/resolv.conf"
|
||||
|
||||
var fqdnSoaCache = &sync.Map{}
|
||||
|
||||
var defaultNameservers = []string{
|
||||
"google-public-dns-a.google.com:53",
|
||||
"google-public-dns-b.google.com:53",
|
||||
}
|
||||
|
||||
// recursiveNameservers are used to pre-check DNS propagation.
|
||||
var recursiveNameservers = getNameservers(defaultResolvConf, defaultNameservers)
|
||||
|
||||
// soaCacheEntry holds a cached SOA record (only selected fields).
|
||||
type soaCacheEntry struct {
|
||||
zone string // zone apex (a domain name)
|
||||
primaryNs string // primary nameserver for the zone apex
|
||||
expires time.Time // time when this cache entry should be evicted
|
||||
}
|
||||
|
||||
func newSoaCacheEntry(soa *dns.SOA) *soaCacheEntry {
|
||||
return &soaCacheEntry{
|
||||
zone: soa.Hdr.Name,
|
||||
primaryNs: soa.Ns,
|
||||
expires: time.Now().Add(time.Duration(soa.Refresh) * time.Second),
|
||||
}
|
||||
}
|
||||
|
||||
// isExpired checks whether a cache entry should be considered expired.
|
||||
func (cache *soaCacheEntry) isExpired() bool {
|
||||
return time.Now().After(cache.expires)
|
||||
}
|
||||
|
||||
// ClearFqdnCache clears the cache of fqdn to zone mappings. Primarily used in testing.
|
||||
func ClearFqdnCache() {
|
||||
// TODO(ldez): use `fqdnSoaCache.Clear()` when updating to go1.23
|
||||
fqdnSoaCache.Range(func(k, v any) bool {
|
||||
fqdnSoaCache.Delete(k)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func AddDNSTimeout(timeout time.Duration) ChallengeOption {
|
||||
return func(_ *Challenge) error {
|
||||
dnsTimeout = timeout
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func AddRecursiveNameservers(nameservers []string) ChallengeOption {
|
||||
return func(_ *Challenge) error {
|
||||
recursiveNameservers = ParseNameservers(nameservers)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// getNameservers attempts to get systems nameservers before falling back to the defaults.
|
||||
func getNameservers(path string, defaults []string) []string {
|
||||
config, err := dns.ClientConfigFromFile(path)
|
||||
if err != nil || len(config.Servers) == 0 {
|
||||
return defaults
|
||||
}
|
||||
|
||||
return ParseNameservers(config.Servers)
|
||||
}
|
||||
|
||||
func ParseNameservers(servers []string) []string {
|
||||
var resolvers []string
|
||||
|
||||
for _, resolver := range servers {
|
||||
// ensure all servers have a port number
|
||||
if _, _, err := net.SplitHostPort(resolver); err != nil {
|
||||
resolvers = append(resolvers, net.JoinHostPort(resolver, "53"))
|
||||
} else {
|
||||
resolvers = append(resolvers, resolver)
|
||||
}
|
||||
}
|
||||
|
||||
return resolvers
|
||||
}
|
||||
|
||||
// lookupNameservers returns the authoritative nameservers for the given fqdn.
|
||||
func lookupNameservers(fqdn string) ([]string, error) {
|
||||
var authoritativeNss []string
|
||||
|
||||
zone, err := FindZoneByFqdn(fqdn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
||||
r, err := dnsQuery(zone, dns.TypeNS, recursiveNameservers, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("NS call failed: %w", err)
|
||||
}
|
||||
|
||||
for _, rr := range r.Answer {
|
||||
if ns, ok := rr.(*dns.NS); ok {
|
||||
authoritativeNss = append(authoritativeNss, strings.ToLower(ns.Ns))
|
||||
}
|
||||
}
|
||||
|
||||
if len(authoritativeNss) > 0 {
|
||||
return authoritativeNss, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("[zone=%s] could not determine authoritative nameservers", zone)
|
||||
}
|
||||
|
||||
// FindPrimaryNsByFqdn determines the primary nameserver of the zone apex for the given fqdn
|
||||
// by recursing up the domain labels until the nameserver returns a SOA record in the answer section.
|
||||
func FindPrimaryNsByFqdn(fqdn string) (string, error) {
|
||||
return FindPrimaryNsByFqdnCustom(fqdn, recursiveNameservers)
|
||||
}
|
||||
|
||||
// FindPrimaryNsByFqdnCustom determines the primary nameserver of the zone apex for the given fqdn
|
||||
// by recursing up the domain labels until the nameserver returns a SOA record in the answer section.
|
||||
func FindPrimaryNsByFqdnCustom(fqdn string, nameservers []string) (string, error) {
|
||||
soa, err := lookupSoaByFqdn(fqdn, nameservers)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("[fqdn=%s] %w", fqdn, err)
|
||||
}
|
||||
|
||||
return soa.primaryNs, nil
|
||||
}
|
||||
|
||||
// FindZoneByFqdn determines the zone apex for the given fqdn
|
||||
// by recursing up the domain labels until the nameserver returns a SOA record in the answer section.
|
||||
func FindZoneByFqdn(fqdn string) (string, error) {
|
||||
return FindZoneByFqdnCustom(fqdn, recursiveNameservers)
|
||||
}
|
||||
|
||||
// FindZoneByFqdnCustom determines the zone apex for the given fqdn
|
||||
// by recursing up the domain labels until the nameserver returns a SOA record in the answer section.
|
||||
func FindZoneByFqdnCustom(fqdn string, nameservers []string) (string, error) {
|
||||
soa, err := lookupSoaByFqdn(fqdn, nameservers)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("[fqdn=%s] %w", fqdn, err)
|
||||
}
|
||||
|
||||
return soa.zone, nil
|
||||
}
|
||||
|
||||
func lookupSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
|
||||
// Do we have it cached and is it still fresh?
|
||||
entAny, ok := fqdnSoaCache.Load(fqdn)
|
||||
if ok && entAny != nil {
|
||||
ent, ok1 := entAny.(*soaCacheEntry)
|
||||
if ok1 && !ent.isExpired() {
|
||||
return ent, nil
|
||||
}
|
||||
}
|
||||
|
||||
ent, err := fetchSoaByFqdn(fqdn, nameservers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fqdnSoaCache.Store(fqdn, ent)
|
||||
|
||||
return ent, nil
|
||||
}
|
||||
|
||||
func fetchSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
|
||||
var (
|
||||
err error
|
||||
r *dns.Msg
|
||||
)
|
||||
|
||||
for domain := range DomainsSeq(fqdn) {
|
||||
r, err = dnsQuery(domain, dns.TypeSOA, nameservers, true)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if r == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
switch r.Rcode {
|
||||
case dns.RcodeSuccess:
|
||||
// Check if we got a SOA RR in the answer section
|
||||
if len(r.Answer) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// CNAME records cannot/should not exist at the root of a zone.
|
||||
// So we skip a domain when a CNAME is found.
|
||||
if dnsMsgContainsCNAME(r) {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, ans := range r.Answer {
|
||||
if soa, ok := ans.(*dns.SOA); ok {
|
||||
return newSoaCacheEntry(soa), nil
|
||||
}
|
||||
}
|
||||
case dns.RcodeNameError:
|
||||
// NXDOMAIN
|
||||
default:
|
||||
// Any response code other than NOERROR and NXDOMAIN is treated as error
|
||||
return nil, &DNSError{Message: fmt.Sprintf("unexpected response for '%s'", domain), MsgOut: r}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, &DNSError{Message: fmt.Sprintf("could not find the start of authority for '%s'", fqdn), MsgOut: r, Err: err}
|
||||
}
|
||||
|
||||
// dnsMsgContainsCNAME checks for a CNAME answer in msg.
|
||||
func dnsMsgContainsCNAME(msg *dns.Msg) bool {
|
||||
return slices.ContainsFunc(msg.Answer, func(rr dns.RR) bool {
|
||||
_, ok := rr.(*dns.CNAME)
|
||||
return ok
|
||||
})
|
||||
}
|
||||
|
||||
func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (*dns.Msg, error) {
|
||||
m := createDNSMsg(fqdn, rtype, recursive)
|
||||
|
||||
if len(nameservers) == 0 {
|
||||
return nil, &DNSError{Message: "empty list of nameservers"}
|
||||
}
|
||||
|
||||
var (
|
||||
r *dns.Msg
|
||||
err error
|
||||
errAll error
|
||||
)
|
||||
|
||||
for _, ns := range nameservers {
|
||||
r, err = sendDNSQuery(m, ns)
|
||||
if err == nil && len(r.Answer) > 0 {
|
||||
break
|
||||
}
|
||||
|
||||
errAll = errors.Join(errAll, err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return r, errAll
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func createDNSMsg(fqdn string, rtype uint16, recursive bool) *dns.Msg {
|
||||
m := new(dns.Msg)
|
||||
m.SetQuestion(fqdn, rtype)
|
||||
m.SetEdns0(4096, false)
|
||||
|
||||
if !recursive {
|
||||
m.RecursionDesired = false
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func sendDNSQuery(m *dns.Msg, ns string) (*dns.Msg, error) {
|
||||
if ok, _ := strconv.ParseBool(os.Getenv("LEGO_EXPERIMENTAL_DNS_TCP_ONLY")); ok {
|
||||
tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout}
|
||||
|
||||
r, _, err := tcp.Exchange(m, ns)
|
||||
if err != nil {
|
||||
return r, &DNSError{Message: "DNS call error", MsgIn: m, NS: ns, Err: err}
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
udp := &dns.Client{Net: "udp", Timeout: dnsTimeout}
|
||||
r, _, err := udp.Exchange(m, ns)
|
||||
|
||||
if r != nil && r.Truncated {
|
||||
tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout}
|
||||
// If the TCP request succeeds, the "err" will reset to nil
|
||||
r, _, err = tcp.Exchange(m, ns)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return r, &DNSError{Message: "DNS call error", MsgIn: m, NS: ns, Err: err}
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// DNSError error related to DNS calls.
|
||||
type DNSError struct {
|
||||
Message string
|
||||
NS string
|
||||
MsgIn *dns.Msg
|
||||
MsgOut *dns.Msg
|
||||
Err error
|
||||
}
|
||||
|
||||
func (d *DNSError) Error() string {
|
||||
var details []string
|
||||
if d.NS != "" {
|
||||
details = append(details, "ns="+d.NS)
|
||||
}
|
||||
|
||||
if d.MsgIn != nil && len(d.MsgIn.Question) > 0 {
|
||||
details = append(details, fmt.Sprintf("question='%s'", formatQuestions(d.MsgIn.Question)))
|
||||
}
|
||||
|
||||
if d.MsgOut != nil {
|
||||
if d.MsgIn == nil || len(d.MsgIn.Question) == 0 {
|
||||
details = append(details, fmt.Sprintf("question='%s'", formatQuestions(d.MsgOut.Question)))
|
||||
}
|
||||
|
||||
details = append(details, "code="+dns.RcodeToString[d.MsgOut.Rcode])
|
||||
}
|
||||
|
||||
msg := "DNS error"
|
||||
if d.Message != "" {
|
||||
msg = d.Message
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
msg += ": " + d.Err.Error()
|
||||
}
|
||||
|
||||
if len(details) > 0 {
|
||||
msg += " [" + strings.Join(details, ", ") + "]"
|
||||
}
|
||||
|
||||
return msg
|
||||
}
|
||||
|
||||
func (d *DNSError) Unwrap() error {
|
||||
return d.Err
|
||||
}
|
||||
|
||||
func formatQuestions(questions []dns.Question) string {
|
||||
var parts []string
|
||||
for _, question := range questions {
|
||||
parts = append(parts, strings.ReplaceAll(strings.TrimPrefix(question.String(), ";"), "\t", " "))
|
||||
}
|
||||
|
||||
return strings.Join(parts, ";")
|
||||
}
|
||||
|
|
@ -1,365 +0,0 @@
|
|||
package dns01
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/go-acme/lego/v5/platform/tester/dnsmock"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_lookupNameserversOK(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fakeDNSServer *dnsmock.Builder
|
||||
fqdn string
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
fqdn: "en.wikipedia.org.localhost.",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("en.wikipedia.org.localhost SOA", dnsmock.CNAME("dyna.wikimedia.org.localhost")).
|
||||
Query("wikipedia.org.localhost SOA", dnsmock.SOA("")).
|
||||
Query("wikipedia.org.localhost NS",
|
||||
dnsmock.Answer(
|
||||
fakeNS("wikipedia.org.localhost.", "ns0.wikimedia.org.localhost."),
|
||||
fakeNS("wikipedia.org.localhost.", "ns1.wikimedia.org.localhost."),
|
||||
fakeNS("wikipedia.org.localhost.", "ns2.wikimedia.org.localhost."),
|
||||
),
|
||||
),
|
||||
expected: []string{"ns0.wikimedia.org.localhost.", "ns1.wikimedia.org.localhost.", "ns2.wikimedia.org.localhost."},
|
||||
},
|
||||
{
|
||||
fqdn: "www.google.com.localhost.",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("www.google.com.localhost. SOA", dnsmock.Noop).
|
||||
Query("google.com.localhost. SOA", dnsmock.SOA("")).
|
||||
Query("google.com.localhost. NS",
|
||||
dnsmock.Answer(
|
||||
fakeNS("google.com.localhost.", "ns1.google.com.localhost."),
|
||||
fakeNS("google.com.localhost.", "ns2.google.com.localhost."),
|
||||
fakeNS("google.com.localhost.", "ns3.google.com.localhost."),
|
||||
fakeNS("google.com.localhost.", "ns4.google.com.localhost."),
|
||||
),
|
||||
),
|
||||
expected: []string{"ns1.google.com.localhost.", "ns2.google.com.localhost.", "ns3.google.com.localhost.", "ns4.google.com.localhost."},
|
||||
},
|
||||
{
|
||||
fqdn: "mail.proton.me.localhost.",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("mail.proton.me.localhost. SOA", dnsmock.Noop).
|
||||
Query("proton.me.localhost. SOA", dnsmock.SOA("")).
|
||||
Query("proton.me.localhost. NS",
|
||||
dnsmock.Answer(
|
||||
fakeNS("proton.me.localhost.", "ns1.proton.me.localhost."),
|
||||
fakeNS("proton.me.localhost.", "ns2.proton.me.localhost."),
|
||||
fakeNS("proton.me.localhost.", "ns3.proton.me.localhost."),
|
||||
),
|
||||
),
|
||||
expected: []string{"ns1.proton.me.localhost.", "ns2.proton.me.localhost.", "ns3.proton.me.localhost."},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.fqdn, func(t *testing.T) {
|
||||
useAsNameserver(t, test.fakeDNSServer.Build(t))
|
||||
|
||||
nss, err := lookupNameservers(test.fqdn)
|
||||
require.NoError(t, err)
|
||||
|
||||
sort.Strings(nss)
|
||||
sort.Strings(test.expected)
|
||||
|
||||
assert.Equal(t, test.expected, nss)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_lookupNameserversErr(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fqdn string
|
||||
fakeDNSServer *dnsmock.Builder
|
||||
error string
|
||||
}{
|
||||
{
|
||||
desc: "NXDOMAIN",
|
||||
fqdn: "example.invalid.",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query(". SOA", dnsmock.Error(dns.RcodeNameError)),
|
||||
error: "could not find zone: [fqdn=example.invalid.] could not find the start of authority for 'example.invalid.' [question='invalid. IN SOA', code=NXDOMAIN]",
|
||||
},
|
||||
{
|
||||
desc: "NS error",
|
||||
fqdn: "example.com.",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Query("example.com. NS", dnsmock.Error(dns.RcodeServerFailure)),
|
||||
error: "[zone=example.com.] could not determine authoritative nameservers",
|
||||
},
|
||||
{
|
||||
desc: "empty NS",
|
||||
fqdn: "example.com.",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Query("example.me NS", dnsmock.Noop),
|
||||
error: "[zone=example.com.] could not determine authoritative nameservers",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
useAsNameserver(t, test.fakeDNSServer.Build(t))
|
||||
|
||||
_, err := lookupNameservers(test.fqdn)
|
||||
require.Error(t, err)
|
||||
assert.EqualError(t, err, test.error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type lookupSoaByFqdnTestCase struct {
|
||||
desc string
|
||||
fqdn string
|
||||
zone string
|
||||
primaryNs string
|
||||
nameservers []string
|
||||
expectedError string
|
||||
}
|
||||
|
||||
func lookupSoaByFqdnTestCases(t *testing.T) []lookupSoaByFqdnTestCase {
|
||||
t.Helper()
|
||||
|
||||
return []lookupSoaByFqdnTestCase{
|
||||
{
|
||||
desc: "domain is a CNAME",
|
||||
fqdn: "mail.example.com.",
|
||||
zone: "example.com.",
|
||||
primaryNs: "ns1.example.com.",
|
||||
nameservers: []string{
|
||||
dnsmock.NewServer().
|
||||
Query("mail.example.com. SOA", dnsmock.CNAME("example.com.")).
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Build(t).
|
||||
String(),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "domain is a non-existent subdomain",
|
||||
fqdn: "foo.example.com.",
|
||||
zone: "example.com.",
|
||||
primaryNs: "ns1.example.com.",
|
||||
nameservers: []string{
|
||||
dnsmock.NewServer().
|
||||
Query("foo.example.com. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Build(t).
|
||||
String(),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "domain is a eTLD",
|
||||
fqdn: "example.com.ac.",
|
||||
zone: "ac.",
|
||||
primaryNs: "ns1.nic.ac.",
|
||||
nameservers: []string{
|
||||
dnsmock.NewServer().
|
||||
Query("example.com.ac. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("com.ac. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("ac. SOA", dnsmock.SOA("")).
|
||||
Build(t).
|
||||
String(),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "domain is a cross-zone CNAME",
|
||||
fqdn: "cross-zone-example.example.com.",
|
||||
zone: "example.com.",
|
||||
primaryNs: "ns1.example.com.",
|
||||
nameservers: []string{
|
||||
dnsmock.NewServer().
|
||||
Query("cross-zone-example.example.com. SOA", dnsmock.CNAME("example.org.")).
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Build(t).
|
||||
String(),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "NXDOMAIN",
|
||||
fqdn: "test.lego.invalid.",
|
||||
zone: "lego.invalid.",
|
||||
nameservers: []string{
|
||||
dnsmock.NewServer().
|
||||
Query("test.lego.invalid. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("lego.invalid. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("invalid. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Build(t).
|
||||
String(),
|
||||
},
|
||||
expectedError: `[fqdn=test.lego.invalid.] could not find the start of authority for 'test.lego.invalid.' [question='invalid. IN SOA', code=NXDOMAIN]`,
|
||||
},
|
||||
{
|
||||
desc: "several non existent nameservers",
|
||||
fqdn: "mail.example.com.",
|
||||
zone: "example.com.",
|
||||
primaryNs: "ns1.example.com.",
|
||||
nameservers: []string{
|
||||
":7053",
|
||||
":8053",
|
||||
dnsmock.NewServer().
|
||||
Query("mail.example.com. SOA", dnsmock.CNAME("example.com.")).
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Build(t).
|
||||
String(),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "only non-existent nameservers",
|
||||
fqdn: "mail.example.com.",
|
||||
zone: "example.com.",
|
||||
nameservers: []string{":7053", ":8053", ":9053"},
|
||||
// use only the start of the message because the port changes with each call: 127.0.0.1:XXXXX->127.0.0.1:7053.
|
||||
expectedError: "[fqdn=mail.example.com.] could not find the start of authority for 'mail.example.com.': DNS call error: read udp ",
|
||||
},
|
||||
{
|
||||
desc: "no nameservers",
|
||||
fqdn: "test.example.com.",
|
||||
zone: "example.com.",
|
||||
nameservers: []string{},
|
||||
expectedError: "[fqdn=test.example.com.] could not find the start of authority for 'test.example.com.': empty list of nameservers",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindZoneByFqdnCustom(t *testing.T) {
|
||||
for _, test := range lookupSoaByFqdnTestCases(t) {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
ClearFqdnCache()
|
||||
|
||||
zone, err := FindZoneByFqdnCustom(test.fqdn, test.nameservers)
|
||||
if test.expectedError != "" {
|
||||
require.Error(t, err)
|
||||
assert.ErrorContains(t, err, test.expectedError)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, test.zone, zone)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindPrimaryNsByFqdnCustom(t *testing.T) {
|
||||
for _, test := range lookupSoaByFqdnTestCases(t) {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
ClearFqdnCache()
|
||||
|
||||
ns, err := FindPrimaryNsByFqdnCustom(test.fqdn, test.nameservers)
|
||||
if test.expectedError != "" {
|
||||
require.Error(t, err)
|
||||
assert.ErrorContains(t, err, test.expectedError)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, test.primaryNs, ns)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_getNameservers_ResolveConfServers(t *testing.T) {
|
||||
testCases := []struct {
|
||||
fixture string
|
||||
expected []string
|
||||
defaults []string
|
||||
}{
|
||||
{
|
||||
fixture: "fixtures/resolv.conf.1",
|
||||
defaults: []string{"127.0.0.1:53"},
|
||||
expected: []string{"10.200.3.249:53", "10.200.3.250:5353", "[2001:4860:4860::8844]:53", "[10.0.0.1]:5353"},
|
||||
},
|
||||
{
|
||||
fixture: "fixtures/resolv.conf.nonexistant",
|
||||
defaults: []string{"127.0.0.1:53"},
|
||||
expected: []string{"127.0.0.1:53"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.fixture, func(t *testing.T) {
|
||||
result := getNameservers(test.fixture, test.defaults)
|
||||
|
||||
sort.Strings(result)
|
||||
sort.Strings(test.expected)
|
||||
|
||||
assert.Equal(t, test.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDNSError_Error(t *testing.T) {
|
||||
msgIn := createDNSMsg("example.com.", dns.TypeTXT, true)
|
||||
|
||||
msgOut := createDNSMsg("example.org.", dns.TypeSOA, true)
|
||||
msgOut.Rcode = dns.RcodeNameError
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
err *DNSError
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "empty error",
|
||||
err: &DNSError{},
|
||||
expected: "DNS error",
|
||||
},
|
||||
{
|
||||
desc: "all fields",
|
||||
err: &DNSError{
|
||||
Message: "Oops",
|
||||
NS: "example.com.",
|
||||
MsgIn: msgIn,
|
||||
MsgOut: msgOut,
|
||||
Err: errors.New("I did it again"),
|
||||
},
|
||||
expected: "Oops: I did it again [ns=example.com., question='example.com. IN TXT', code=NXDOMAIN]",
|
||||
},
|
||||
{
|
||||
desc: "only NS",
|
||||
err: &DNSError{
|
||||
NS: "example.com.",
|
||||
},
|
||||
expected: "DNS error [ns=example.com.]",
|
||||
},
|
||||
{
|
||||
desc: "only MsgIn",
|
||||
err: &DNSError{
|
||||
MsgIn: msgIn,
|
||||
},
|
||||
expected: "DNS error [question='example.com. IN TXT']",
|
||||
},
|
||||
{
|
||||
desc: "only MsgOut",
|
||||
err: &DNSError{
|
||||
MsgOut: msgOut,
|
||||
},
|
||||
expected: "DNS error [question='example.org. IN SOA', code=NXDOMAIN]",
|
||||
},
|
||||
{
|
||||
desc: "only Err",
|
||||
err: &DNSError{
|
||||
Err: errors.New("I did it again"),
|
||||
},
|
||||
expected: "DNS error: I did it again",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert.EqualError(t, test.err, test.expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
//go:build !windows
|
||||
|
||||
package dns01
|
||||
|
||||
import "time"
|
||||
|
||||
// dnsTimeout is used to override the default DNS timeout of 10 seconds.
|
||||
var dnsTimeout = 10 * time.Second
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
//go:build windows
|
||||
|
||||
package dns01
|
||||
|
||||
import "time"
|
||||
|
||||
// dnsTimeout is used to override the default DNS timeout of 20 seconds.
|
||||
var dnsTimeout = 20 * time.Second
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
package dns01
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// defaultNameserverPort used by authoritative NS.
|
||||
// This is for tests only.
|
||||
var defaultNameserverPort = "53"
|
||||
|
||||
// PreCheckFunc checks DNS propagation before notifying ACME that the DNS challenge is ready.
|
||||
type PreCheckFunc func(fqdn, value string) (bool, error)
|
||||
|
||||
// WrapPreCheckFunc wraps a PreCheckFunc in order to do extra operations before or after
|
||||
// the main check, put it in a loop, etc.
|
||||
type WrapPreCheckFunc func(domain, fqdn, value string, check PreCheckFunc) (bool, error)
|
||||
|
||||
// WrapPreCheck Allow to define checks before notifying ACME that the DNS challenge is ready.
|
||||
func WrapPreCheck(wrap WrapPreCheckFunc) ChallengeOption {
|
||||
return func(chlg *Challenge) error {
|
||||
chlg.preCheck.checkFunc = wrap
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DisableCompletePropagationRequirement obsolete.
|
||||
//
|
||||
// Deprecated: use DisableAuthoritativeNssPropagationRequirement instead.
|
||||
func DisableCompletePropagationRequirement() ChallengeOption {
|
||||
return DisableAuthoritativeNssPropagationRequirement()
|
||||
}
|
||||
|
||||
func DisableAuthoritativeNssPropagationRequirement() ChallengeOption {
|
||||
return func(chlg *Challenge) error {
|
||||
chlg.preCheck.requireAuthoritativeNssPropagation = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func RecursiveNSsPropagationRequirement() ChallengeOption {
|
||||
return func(chlg *Challenge) error {
|
||||
chlg.preCheck.requireRecursiveNssPropagation = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func PropagationWait(wait time.Duration, skipCheck bool) ChallengeOption {
|
||||
return WrapPreCheck(func(domain, fqdn, value string, check PreCheckFunc) (bool, error) {
|
||||
time.Sleep(wait)
|
||||
|
||||
if skipCheck {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return check(fqdn, value)
|
||||
})
|
||||
}
|
||||
|
||||
type preCheck struct {
|
||||
// checks DNS propagation before notifying ACME that the DNS challenge is ready.
|
||||
checkFunc WrapPreCheckFunc
|
||||
|
||||
// require the TXT record to be propagated to all authoritative name servers
|
||||
requireAuthoritativeNssPropagation bool
|
||||
|
||||
// require the TXT record to be propagated to all recursive name servers
|
||||
requireRecursiveNssPropagation bool
|
||||
}
|
||||
|
||||
func newPreCheck() preCheck {
|
||||
return preCheck{
|
||||
requireAuthoritativeNssPropagation: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (p preCheck) call(domain, fqdn, value string) (bool, error) {
|
||||
if p.checkFunc == nil {
|
||||
return p.checkDNSPropagation(fqdn, value)
|
||||
}
|
||||
|
||||
return p.checkFunc(domain, fqdn, value, p.checkDNSPropagation)
|
||||
}
|
||||
|
||||
// checkDNSPropagation checks if the expected TXT record has been propagated to all authoritative nameservers.
|
||||
func (p preCheck) checkDNSPropagation(fqdn, value string) (bool, error) {
|
||||
// Initial attempt to resolve at the recursive NS (require to get CNAME)
|
||||
r, err := dnsQuery(fqdn, dns.TypeTXT, recursiveNameservers, true)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("initial recursive nameserver: %w", err)
|
||||
}
|
||||
|
||||
if r.Rcode == dns.RcodeSuccess {
|
||||
fqdn = updateDomainWithCName(r, fqdn)
|
||||
}
|
||||
|
||||
if p.requireRecursiveNssPropagation {
|
||||
_, err = checkNameserversPropagation(fqdn, value, recursiveNameservers, false)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("recursive nameservers: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if !p.requireAuthoritativeNssPropagation {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
authoritativeNss, err := lookupNameservers(fqdn)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
found, err := checkNameserversPropagation(fqdn, value, authoritativeNss, true)
|
||||
if err != nil {
|
||||
return found, fmt.Errorf("authoritative nameservers: %w", err)
|
||||
}
|
||||
|
||||
return found, nil
|
||||
}
|
||||
|
||||
// checkNameserversPropagation queries each of the given nameservers for the expected TXT record.
|
||||
func checkNameserversPropagation(fqdn, value string, nameservers []string, addPort bool) (bool, error) {
|
||||
for _, ns := range nameservers {
|
||||
if addPort {
|
||||
ns = net.JoinHostPort(ns, defaultNameserverPort)
|
||||
}
|
||||
|
||||
r, err := dnsQuery(fqdn, dns.TypeTXT, []string{ns}, false)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if r.Rcode != dns.RcodeSuccess {
|
||||
return false, fmt.Errorf("NS %s returned %s for %s", ns, dns.RcodeToString[r.Rcode], fqdn)
|
||||
}
|
||||
|
||||
var records []string
|
||||
|
||||
var found bool
|
||||
|
||||
for _, rr := range r.Answer {
|
||||
if txt, ok := rr.(*dns.TXT); ok {
|
||||
record := strings.Join(txt.Txt, "")
|
||||
|
||||
records = append(records, record)
|
||||
if record == value {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return false, fmt.Errorf("NS %s did not return the expected TXT record [fqdn: %s, value: %s]: %s", ns, fqdn, value, strings.Join(records, " ,"))
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
package dns01
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-acme/lego/v5/platform/tester/dnsmock"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_preCheck_checkDNSPropagation(t *testing.T) {
|
||||
mockResolver(t,
|
||||
dnsmock.NewServer().
|
||||
Query("ns0.lego.localhost. A",
|
||||
dnsmock.Answer(fakeA("ns0.lego.localhost.", "127.0.0.1"))).
|
||||
Query("ns1.lego.localhost. A",
|
||||
dnsmock.Answer(fakeA("ns1.lego.localhost.", "127.0.0.1"))).
|
||||
Query("example.com. TXT",
|
||||
dnsmock.Answer(
|
||||
fakeTXT("example.com.", "one"),
|
||||
fakeTXT("example.com.", "two"),
|
||||
fakeTXT("example.com.", "three"),
|
||||
fakeTXT("example.com.", "four"),
|
||||
fakeTXT("example.com.", "five"),
|
||||
),
|
||||
).
|
||||
Build(t),
|
||||
)
|
||||
|
||||
useAsNameserver(t,
|
||||
dnsmock.NewServer().
|
||||
Query("acme-staging.api.example.com. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("api.example.com. SOA", dnsmock.Error(dns.RcodeNameError)).
|
||||
Query("example.com. SOA", dnsmock.SOA("")).
|
||||
Query("example.com. NS",
|
||||
dnsmock.Answer(
|
||||
fakeNS("example.com.", "ns0.lego.localhost."),
|
||||
fakeNS("example.com.", "ns1.lego.localhost."),
|
||||
),
|
||||
).
|
||||
Build(t),
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fqdn string
|
||||
value string
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
fqdn: "example.com.",
|
||||
value: "four",
|
||||
},
|
||||
{
|
||||
desc: "no matching TXT record",
|
||||
fqdn: "acme-staging.api.example.com.",
|
||||
value: "fe01=",
|
||||
expectedError: "did not return the expected TXT record [fqdn: acme-staging.api.example.com., value: fe01=]: one ,two ,three ,four ,five",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
ClearFqdnCache()
|
||||
|
||||
check := newPreCheck()
|
||||
|
||||
ok, err := check.checkDNSPropagation(test.fqdn, test.value)
|
||||
if test.expectedError != "" {
|
||||
assert.ErrorContainsf(t, err, test.expectedError, "PreCheckDNS must fail for %s", test.fqdn)
|
||||
assert.False(t, ok, "PreCheckDNS must fail for %s", test.fqdn)
|
||||
} else {
|
||||
assert.NoErrorf(t, err, "PreCheckDNS failed for %s", test.fqdn)
|
||||
assert.True(t, ok, "PreCheckDNS failed for %s", test.fqdn)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_checkNameserversPropagation_authoritativeNss(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fqdn, value string
|
||||
fakeDNSServer *dnsmock.Builder
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
desc: "TXT RR w/ expected value",
|
||||
// NS: asnums.routeviews.org.
|
||||
fqdn: "8.8.8.8.asn.routeviews.org.",
|
||||
value: "151698.8.8.024",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("8.8.8.8.asn.routeviews.org. TXT",
|
||||
dnsmock.Answer(
|
||||
fakeTXT("8.8.8.8.asn.routeviews.org.", "151698.8.8.024"),
|
||||
),
|
||||
),
|
||||
},
|
||||
{
|
||||
desc: "TXT RR w/ unexpected value",
|
||||
// NS: asnums.routeviews.org.
|
||||
fqdn: "8.8.8.8.asn.routeviews.org.",
|
||||
value: "fe01=",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("8.8.8.8.asn.routeviews.org. TXT",
|
||||
dnsmock.Answer(
|
||||
fakeTXT("8.8.8.8.asn.routeviews.org.", "15169"),
|
||||
fakeTXT("8.8.8.8.asn.routeviews.org.", "8.8.8.0"),
|
||||
fakeTXT("8.8.8.8.asn.routeviews.org.", "24"),
|
||||
),
|
||||
),
|
||||
expectedError: "did not return the expected TXT record [fqdn: 8.8.8.8.asn.routeviews.org., value: fe01=]: 15169 ,8.8.8.0 ,24",
|
||||
},
|
||||
{
|
||||
desc: "No TXT RR",
|
||||
// NS: ns2.google.com.
|
||||
fqdn: "ns1.google.com.",
|
||||
value: "fe01=",
|
||||
fakeDNSServer: dnsmock.NewServer().
|
||||
Query("ns1.google.com.", dnsmock.Noop),
|
||||
expectedError: "did not return the expected TXT record [fqdn: ns1.google.com., value: fe01=]: ",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
ClearFqdnCache()
|
||||
|
||||
addr := test.fakeDNSServer.Build(t)
|
||||
|
||||
ok, err := checkNameserversPropagation(test.fqdn, test.value, []string{addr.String()}, false)
|
||||
|
||||
if test.expectedError == "" {
|
||||
require.NoError(t, err)
|
||||
assert.True(t, ok)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
require.ErrorContains(t, err, test.expectedError)
|
||||
assert.False(t, ok)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_updateDomainWithCName_caseInsensitive(t *testing.T) {
|
||||
qname := "_acme-challenge.uppercase-test.example.com."
|
||||
cnameTarget := "_acme-challenge.uppercase-test.cname-target.example.com."
|
||||
|
||||
msg := &dns.Msg{
|
||||
MsgHdr: dns.MsgHdr{
|
||||
Authoritative: true,
|
||||
},
|
||||
Answer: []dns.RR{
|
||||
&dns.CNAME{
|
||||
Hdr: dns.RR_Header{
|
||||
Name: strings.ToUpper(qname), // CNAME names are case-insensitive
|
||||
Rrtype: dns.TypeCNAME,
|
||||
Class: dns.ClassINET,
|
||||
Ttl: 3600,
|
||||
},
|
||||
Target: cnameTarget,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fqdn := updateDomainWithCName(msg, qname)
|
||||
|
||||
assert.Equal(t, cnameTarget, fqdn)
|
||||
}
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/acme"
|
||||
"github.com/go-acme/lego/v5/acme/api"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/go-acme/lego/v5/platform/wait"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultPropagationTimeout default propagation timeout.
|
||||
DefaultPropagationTimeout = 60 * time.Second
|
||||
|
||||
// DefaultPollingInterval default polling interval.
|
||||
DefaultPollingInterval = 2 * time.Second
|
||||
|
||||
// DefaultTTL default TTL.
|
||||
DefaultTTL = 120
|
||||
)
|
||||
|
||||
type ValidateFunc func(ctx context.Context, core *api.Core, domain string, chlng acme.Challenge) error
|
||||
|
||||
// Challenge implements the dns-01 challenge.
|
||||
type Challenge struct {
|
||||
core *api.Core
|
||||
validate ValidateFunc
|
||||
provider challenge.Provider
|
||||
preCheck preCheck
|
||||
}
|
||||
|
||||
func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Provider, opts ...ChallengeOption) *Challenge {
|
||||
chlg := &Challenge{
|
||||
core: core,
|
||||
validate: validate,
|
||||
provider: provider,
|
||||
preCheck: newPreCheck(),
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
err := opt(chlg)
|
||||
if err != nil {
|
||||
log.Warn("Challenge option skipped.", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
return chlg
|
||||
}
|
||||
|
||||
// PreSolve just submits the txt record to the dns provider.
|
||||
// It does not validate record propagation or do anything at all with the ACME server.
|
||||
func (c *Challenge) PreSolve(ctx context.Context, authz acme.Authorization) error {
|
||||
domain := challenge.GetTargetedDomain(authz)
|
||||
log.Info("acme: Preparing to solve DNS-01.", "domain", domain)
|
||||
|
||||
chlng, err := challenge.FindChallenge(challenge.DNS01, authz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.provider == nil {
|
||||
return fmt.Errorf("[%s] acme: no DNS Provider configured", domain)
|
||||
}
|
||||
|
||||
// Generate the Key Authorization for the challenge
|
||||
keyAuth, err := c.core.GetKeyAuthorization(chlng.Token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.provider.Present(authz.Identifier.Value, chlng.Token, keyAuth)
|
||||
if err != nil {
|
||||
return fmt.Errorf("[%s] acme: error presenting token: %w", domain, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Challenge) Solve(ctx context.Context, authz acme.Authorization) error {
|
||||
domain := challenge.GetTargetedDomain(authz)
|
||||
log.Info("acme: Trying to solve DNS-01.", "domain", domain)
|
||||
|
||||
chlng, err := challenge.FindChallenge(challenge.DNS01, authz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Generate the Key Authorization for the challenge
|
||||
keyAuth, err := c.core.GetKeyAuthorization(chlng.Token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
info := GetChallengeInfo(ctx, authz.Identifier.Value, keyAuth)
|
||||
|
||||
var timeout, interval time.Duration
|
||||
|
||||
switch provider := c.provider.(type) {
|
||||
case challenge.ProviderTimeout:
|
||||
timeout, interval = provider.Timeout()
|
||||
default:
|
||||
timeout, interval = DefaultPropagationTimeout, DefaultPollingInterval
|
||||
}
|
||||
|
||||
log.Info("acme: Checking DNS record propagation.",
|
||||
"domain", domain, "nameservers", strings.Join(DefaultClient().recursiveNameservers, ","))
|
||||
|
||||
time.Sleep(interval)
|
||||
|
||||
err = wait.For("propagation", timeout, interval, func() (bool, error) {
|
||||
stop, errP := c.preCheck.call(ctx, domain, info.EffectiveFQDN, info.Value)
|
||||
if !stop || errP != nil {
|
||||
log.Info("acme: Waiting for DNS record propagation.", "domain", domain)
|
||||
}
|
||||
|
||||
return stop, errP
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
chlng.KeyAuthorization = keyAuth
|
||||
|
||||
return c.validate(ctx, c.core, domain, chlng)
|
||||
}
|
||||
|
||||
// CleanUp cleans the challenge.
|
||||
func (c *Challenge) CleanUp(authz acme.Authorization) error {
|
||||
log.Info("acme: Cleaning DNS-01 challenge.", "domain", challenge.GetTargetedDomain(authz))
|
||||
|
||||
chlng, err := challenge.FindChallenge(challenge.DNS01, authz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
keyAuth, err := c.core.GetKeyAuthorization(chlng.Token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.provider.CleanUp(authz.Identifier.Value, chlng.Token, keyAuth)
|
||||
}
|
||||
|
||||
func (c *Challenge) Sequential() (bool, time.Duration) {
|
||||
if p, ok := c.provider.(sequential); ok {
|
||||
return ok, p.Sequential()
|
||||
}
|
||||
|
||||
return false, 0
|
||||
}
|
||||
|
||||
type sequential interface {
|
||||
Sequential() time.Duration
|
||||
}
|
||||
|
||||
// ChallengeInfo contains the information use to create the TXT record.
|
||||
type ChallengeInfo struct {
|
||||
// FQDN is the full-qualified challenge domain (i.e. `_acme-challenge.[domain].`)
|
||||
FQDN string
|
||||
|
||||
// EffectiveFQDN contains the resulting FQDN after the CNAMEs resolutions.
|
||||
EffectiveFQDN string
|
||||
|
||||
// Value contains the value for the TXT record.
|
||||
Value string
|
||||
}
|
||||
|
||||
// GetChallengeInfo returns information used to create a DNS record which will fulfill the `dns-01` challenge.
|
||||
func GetChallengeInfo(ctx context.Context, domain, keyAuth string) ChallengeInfo {
|
||||
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
|
||||
// base64URL encoding without padding
|
||||
value := base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size])
|
||||
|
||||
ok, _ := strconv.ParseBool(os.Getenv("LEGO_DISABLE_CNAME_SUPPORT"))
|
||||
|
||||
return ChallengeInfo{
|
||||
Value: value,
|
||||
FQDN: getChallengeFQDN(ctx, domain, false),
|
||||
EffectiveFQDN: getChallengeFQDN(ctx, domain, !ok),
|
||||
}
|
||||
}
|
||||
|
||||
func getChallengeFQDN(ctx context.Context, domain string, followCNAME bool) string {
|
||||
fqdn := fmt.Sprintf("_acme-challenge.%s.", domain)
|
||||
|
||||
if !followCNAME {
|
||||
return fqdn
|
||||
}
|
||||
|
||||
return DefaultClient().lookupCNAME(ctx, fqdn)
|
||||
}
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/acme"
|
||||
"github.com/go-acme/lego/v5/acme/api"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/platform/tester"
|
||||
"github.com/go-acme/lego/v5/platform/tester/dnsmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type providerMock struct {
|
||||
present, cleanUp error
|
||||
}
|
||||
|
||||
func (p *providerMock) Present(domain, token, keyAuth string) error { return p.present }
|
||||
func (p *providerMock) CleanUp(domain, token, keyAuth string) error { return p.cleanUp }
|
||||
|
||||
type providerTimeoutMock struct {
|
||||
present, cleanUp error
|
||||
timeout, interval time.Duration
|
||||
}
|
||||
|
||||
func (p *providerTimeoutMock) Present(domain, token, keyAuth string) error { return p.present }
|
||||
func (p *providerTimeoutMock) CleanUp(domain, token, keyAuth string) error { return p.cleanUp }
|
||||
func (p *providerTimeoutMock) Timeout() (time.Duration, time.Duration) { return p.timeout, p.interval }
|
||||
|
||||
func TestChallenge_PreSolve(t *testing.T) {
|
||||
server := tester.MockACMEServer().BuildHTTPS(t)
|
||||
|
||||
privateKey, err := rsa.GenerateKey(rand.Reader, 1024)
|
||||
require.NoError(t, err)
|
||||
|
||||
core, err := api.New(server.Client(), "lego-test", server.URL+"/dir", "", privateKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
validate ValidateFunc
|
||||
preCheck WrapPreCheckFunc
|
||||
provider challenge.Provider
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{},
|
||||
},
|
||||
{
|
||||
desc: "validate fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return errors.New("OOPS") },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: nil,
|
||||
cleanUp: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "preCheck fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) {
|
||||
return false, errors.New("OOPS")
|
||||
},
|
||||
provider: &providerTimeoutMock{
|
||||
timeout: 2 * time.Second,
|
||||
interval: 500 * time.Millisecond,
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "present fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: errors.New("OOPS"),
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
desc: "cleanUp fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
cleanUp: errors.New("OOPS"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
chlg := NewChallenge(core, test.validate, test.provider, WrapPreCheck(test.preCheck))
|
||||
|
||||
authz := acme.Authorization{
|
||||
Identifier: acme.Identifier{
|
||||
Value: "example.com",
|
||||
},
|
||||
Challenges: []acme.Challenge{
|
||||
{Type: challenge.DNS01.String()},
|
||||
},
|
||||
}
|
||||
|
||||
err = chlg.PreSolve(t.Context(), authz)
|
||||
if test.expectError {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChallenge_Solve(t *testing.T) {
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.Noop).
|
||||
Build(t))
|
||||
|
||||
server := tester.MockACMEServer().BuildHTTPS(t)
|
||||
|
||||
privateKey, err := rsa.GenerateKey(rand.Reader, 1024)
|
||||
require.NoError(t, err)
|
||||
|
||||
core, err := api.New(server.Client(), "lego-test", server.URL+"/dir", "", privateKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
validate ValidateFunc
|
||||
preCheck WrapPreCheckFunc
|
||||
provider challenge.Provider
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{},
|
||||
},
|
||||
{
|
||||
desc: "validate fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return errors.New("OOPS") },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: nil,
|
||||
cleanUp: nil,
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
desc: "preCheck fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) {
|
||||
return false, errors.New("OOPS")
|
||||
},
|
||||
provider: &providerTimeoutMock{
|
||||
timeout: 2 * time.Second,
|
||||
interval: 500 * time.Millisecond,
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
desc: "present fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: errors.New("OOPS"),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "cleanUp fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
cleanUp: errors.New("OOPS"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
var options []ChallengeOption
|
||||
if test.preCheck != nil {
|
||||
options = append(options, WrapPreCheck(test.preCheck))
|
||||
}
|
||||
|
||||
chlg := NewChallenge(core, test.validate, test.provider, options...)
|
||||
|
||||
authz := acme.Authorization{
|
||||
Identifier: acme.Identifier{
|
||||
Value: "example.com",
|
||||
},
|
||||
Challenges: []acme.Challenge{
|
||||
{Type: challenge.DNS01.String()},
|
||||
},
|
||||
}
|
||||
|
||||
err = chlg.Solve(t.Context(), authz)
|
||||
if test.expectError {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChallenge_CleanUp(t *testing.T) {
|
||||
server := tester.MockACMEServer().BuildHTTPS(t)
|
||||
|
||||
privateKey, err := rsa.GenerateKey(rand.Reader, 1024)
|
||||
require.NoError(t, err)
|
||||
|
||||
core, err := api.New(server.Client(), "lego-test", server.URL+"/dir", "", privateKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
validate ValidateFunc
|
||||
preCheck WrapPreCheckFunc
|
||||
provider challenge.Provider
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
desc: "success",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{},
|
||||
},
|
||||
{
|
||||
desc: "validate fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return errors.New("OOPS") },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: nil,
|
||||
cleanUp: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "preCheck fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) {
|
||||
return false, errors.New("OOPS")
|
||||
},
|
||||
provider: &providerTimeoutMock{
|
||||
timeout: 2 * time.Second,
|
||||
interval: 500 * time.Millisecond,
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "present fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
present: errors.New("OOPS"),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "cleanUp fail",
|
||||
validate: func(_ context.Context, _ *api.Core, _ string, _ acme.Challenge) error { return nil },
|
||||
preCheck: func(_ context.Context, _, _, _ string, _ PreCheckFunc) (bool, error) { return true, nil },
|
||||
provider: &providerMock{
|
||||
cleanUp: errors.New("OOPS"),
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
chlg := NewChallenge(core, test.validate, test.provider, WrapPreCheck(test.preCheck))
|
||||
|
||||
authz := acme.Authorization{
|
||||
Identifier: acme.Identifier{
|
||||
Value: "example.com",
|
||||
},
|
||||
Challenges: []acme.Challenge{
|
||||
{Type: challenge.DNS01.String()},
|
||||
},
|
||||
}
|
||||
|
||||
err = chlg.CleanUp(authz)
|
||||
if test.expectError {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetChallengeInfo(t *testing.T) {
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.Noop).
|
||||
Build(t))
|
||||
|
||||
info := GetChallengeInfo(t.Context(), "example.com", "123")
|
||||
|
||||
expected := ChallengeInfo{
|
||||
FQDN: "_acme-challenge.example.com.",
|
||||
EffectiveFQDN: "_acme-challenge.example.com.",
|
||||
Value: "pmWkWSBCL51Bfkhn79xPuKBKHz__H6B-mY6G9_eieuM",
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, info)
|
||||
}
|
||||
|
||||
func TestGetChallengeInfo_CNAME(t *testing.T) {
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.CNAME("example.org.")).
|
||||
Query("example.org. CNAME", dnsmock.Noop).
|
||||
Build(t))
|
||||
|
||||
info := GetChallengeInfo(t.Context(), "example.com", "123")
|
||||
|
||||
expected := ChallengeInfo{
|
||||
FQDN: "_acme-challenge.example.com.",
|
||||
EffectiveFQDN: "example.org.",
|
||||
Value: "pmWkWSBCL51Bfkhn79xPuKBKHz__H6B-mY6G9_eieuM",
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, info)
|
||||
}
|
||||
|
||||
func TestGetChallengeInfo_CNAME_disabled(t *testing.T) {
|
||||
mockDefault(t, dnsmock.NewServer().
|
||||
// Never called when the env var works.
|
||||
Query("_acme-challenge.example.com. CNAME", dnsmock.CNAME("example.org.")).
|
||||
Build(t))
|
||||
|
||||
t.Setenv("LEGO_DISABLE_CNAME_SUPPORT", "true")
|
||||
|
||||
info := GetChallengeInfo(t.Context(), "example.com", "123")
|
||||
|
||||
expected := ChallengeInfo{
|
||||
FQDN: "_acme-challenge.example.com.",
|
||||
EffectiveFQDN: "_acme-challenge.example.com.",
|
||||
Value: "pmWkWSBCL51Bfkhn79xPuKBKHz__H6B-mY6G9_eieuM",
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, info)
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// ExtractSubDomain extracts the subdomain part from a domain and a zone.
|
||||
func ExtractSubDomain(domain, zone string) (string, error) {
|
||||
canonDomain := dns.Fqdn(domain)
|
||||
canonZone := dns.Fqdn(zone)
|
||||
|
||||
if canonDomain == canonZone {
|
||||
return "", fmt.Errorf("no subdomain because the domain and the zone are identical: %s", canonDomain)
|
||||
}
|
||||
|
||||
if !dns.IsSubDomain(canonZone, canonDomain) {
|
||||
return "", fmt.Errorf("%s is not a subdomain of %s", canonDomain, canonZone)
|
||||
}
|
||||
|
||||
return strings.TrimSuffix(canonDomain, "."+canonZone), nil
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestExtractSubDomain(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
domain string
|
||||
zone string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "no FQDN",
|
||||
domain: "_acme-challenge.example.com",
|
||||
zone: "example.com",
|
||||
expected: "_acme-challenge",
|
||||
},
|
||||
{
|
||||
desc: "no FQDN zone",
|
||||
domain: "_acme-challenge.example.com.",
|
||||
zone: "example.com",
|
||||
expected: "_acme-challenge",
|
||||
},
|
||||
{
|
||||
desc: "no FQDN domain",
|
||||
domain: "_acme-challenge.example.com",
|
||||
zone: "example.com.",
|
||||
expected: "_acme-challenge",
|
||||
},
|
||||
{
|
||||
desc: "FQDN",
|
||||
domain: "_acme-challenge.example.com.",
|
||||
zone: "example.com.",
|
||||
expected: "_acme-challenge",
|
||||
},
|
||||
{
|
||||
desc: "multi-level subdomain",
|
||||
domain: "_acme-challenge.one.example.com.",
|
||||
zone: "example.com.",
|
||||
expected: "_acme-challenge.one",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
subDomain, err := ExtractSubDomain(test.domain, test.zone)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, test.expected, subDomain)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractSubDomain_errors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
domain string
|
||||
zone string
|
||||
}{
|
||||
{
|
||||
desc: "same domain",
|
||||
domain: "example.com",
|
||||
zone: "example.com",
|
||||
},
|
||||
{
|
||||
desc: "same domain, no FQDN zone",
|
||||
domain: "example.com.",
|
||||
zone: "example.com",
|
||||
},
|
||||
{
|
||||
desc: "same domain, no FQDN domain",
|
||||
domain: "example.com",
|
||||
zone: "example.com.",
|
||||
},
|
||||
{
|
||||
desc: "same domain, FQDN",
|
||||
domain: "example.com.",
|
||||
zone: "example.com.",
|
||||
},
|
||||
{
|
||||
desc: "zone and domain are unrelated",
|
||||
domain: "_acme-challenge.example.com",
|
||||
zone: "example.org",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := ExtractSubDomain(test.domain, test.zone)
|
||||
require.Error(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
domain example.com
|
||||
nameserver 10.200.3.249
|
||||
nameserver 10.200.3.250:5353
|
||||
nameserver 2001:4860:4860::8844
|
||||
nameserver [10.0.0.1]:5353
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"iter"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// UnFqdn converts the fqdn into a name removing the trailing dot.
|
||||
func UnFqdn(name string) string {
|
||||
n := len(name)
|
||||
if n != 0 && name[n-1] == '.' {
|
||||
return name[:n-1]
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
|
||||
// UnFqdnDomainsSeq generates a sequence of "unFQDNed" domain names derived from a domain (FQDN or not) in descending order.
|
||||
func UnFqdnDomainsSeq(fqdn string) iter.Seq[string] {
|
||||
return func(yield func(string) bool) {
|
||||
if fqdn == "" {
|
||||
return
|
||||
}
|
||||
|
||||
for _, index := range dns.Split(fqdn) {
|
||||
if !yield(UnFqdn(fqdn[index:])) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DomainsSeq generates a sequence of domain names derived from a domain (FQDN or not) in descending order.
|
||||
func DomainsSeq(fqdn string) iter.Seq[string] {
|
||||
return func(yield func(string) bool) {
|
||||
if fqdn == "" {
|
||||
return
|
||||
}
|
||||
|
||||
for _, index := range dns.Split(fqdn) {
|
||||
if !yield(fqdn[index:]) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUnFqdn(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fqdn string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "simple",
|
||||
fqdn: "foo.example.",
|
||||
expected: "foo.example",
|
||||
},
|
||||
{
|
||||
desc: "already domain",
|
||||
fqdn: "foo.example",
|
||||
expected: "foo.example",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
domain := UnFqdn(test.fqdn)
|
||||
|
||||
assert.Equal(t, test.expected, domain)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnFqdnDomainsSeq(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fqdn string
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
desc: "empty",
|
||||
fqdn: "",
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
desc: "TLD",
|
||||
fqdn: "com",
|
||||
expected: []string{"com"},
|
||||
},
|
||||
{
|
||||
desc: "2 levels",
|
||||
fqdn: "example.com",
|
||||
expected: []string{"example.com", "com"},
|
||||
},
|
||||
{
|
||||
desc: "3 levels",
|
||||
fqdn: "foo.example.com",
|
||||
expected: []string{"foo.example.com", "example.com", "com"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
for name, suffix := range map[string]string{"": "", " FQDN": "."} { //nolint:gocritic
|
||||
t.Run(test.desc+name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
actual := slices.Collect(UnFqdnDomainsSeq(test.fqdn + suffix))
|
||||
|
||||
assert.Equal(t, test.expected, actual)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDomainsSeq(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fqdn string
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
desc: "empty",
|
||||
fqdn: "",
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
desc: "empty FQDN",
|
||||
fqdn: ".",
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
desc: "TLD FQDN",
|
||||
fqdn: "com",
|
||||
expected: []string{"com"},
|
||||
},
|
||||
{
|
||||
desc: "TLD",
|
||||
fqdn: "com.",
|
||||
expected: []string{"com."},
|
||||
},
|
||||
{
|
||||
desc: "2 levels",
|
||||
fqdn: "example.com",
|
||||
expected: []string{"example.com", "com"},
|
||||
},
|
||||
{
|
||||
desc: "2 levels FQDN",
|
||||
fqdn: "example.com.",
|
||||
expected: []string{"example.com.", "com."},
|
||||
},
|
||||
{
|
||||
desc: "3 levels",
|
||||
fqdn: "foo.example.com",
|
||||
expected: []string{"foo.example.com", "example.com", "com"},
|
||||
},
|
||||
{
|
||||
desc: "3 levels FQDN",
|
||||
fqdn: "foo.example.com.",
|
||||
expected: []string{"foo.example.com.", "example.com.", "com."},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
actual := slices.Collect(DomainsSeq(test.fqdn))
|
||||
|
||||
assert.Equal(t, test.expected, actual)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
package dnsnew
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func fakeNS(name, ns string) *dns.NS {
|
||||
return &dns.NS{
|
||||
Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: 172800},
|
||||
Ns: ns,
|
||||
}
|
||||
}
|
||||
|
||||
func fakeA(name, ip string) *dns.A {
|
||||
return &dns.A{
|
||||
Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 10},
|
||||
A: net.ParseIP(ip),
|
||||
}
|
||||
}
|
||||
|
||||
func fakeTXT(name, value string) *dns.TXT {
|
||||
return &dns.TXT{
|
||||
Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 10},
|
||||
Txt: []string{value},
|
||||
}
|
||||
}
|
||||
|
||||
// mockResolver modifies the default DNS resolver to use a custom network address during the test execution.
|
||||
// IMPORTANT: it modifying std global variables.
|
||||
func mockResolver(authoritativeNS net.Addr) func(t *testing.T, client *Client) {
|
||||
return func(t *testing.T, client *Client) {
|
||||
t.Helper()
|
||||
|
||||
_, port, err := net.SplitHostPort(authoritativeNS.String())
|
||||
require.NoError(t, err)
|
||||
|
||||
client.authoritativeNSPort = port
|
||||
|
||||
originalResolver := net.DefaultResolver
|
||||
|
||||
t.Cleanup(func() {
|
||||
net.DefaultResolver = originalResolver
|
||||
})
|
||||
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{Timeout: 1 * time.Second}
|
||||
|
||||
return d.DialContext(ctx, network, authoritativeNS.String())
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockDefault(t *testing.T, recursiveNS net.Addr, opts ...func(t *testing.T, client *Client)) {
|
||||
t.Helper()
|
||||
|
||||
backup := DefaultClient()
|
||||
|
||||
t.Cleanup(func() {
|
||||
SetDefaultClient(backup)
|
||||
})
|
||||
|
||||
client := NewClient(&Options{RecursiveNameservers: []string{recursiveNS.String()}})
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(t, client)
|
||||
}
|
||||
|
||||
SetDefaultClient(client)
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/go-acme/lego/v5/acme"
|
||||
"github.com/go-acme/lego/v5/acme/api"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/challenge/http01"
|
||||
"github.com/go-acme/lego/v5/challenge/tlsalpn01"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
|
|
@ -50,8 +50,8 @@ func (c *SolverManager) SetTLSALPN01Provider(p challenge.Provider, opts ...tlsal
|
|||
}
|
||||
|
||||
// SetDNS01Provider specifies a custom provider p that can solve the given DNS-01 challenge.
|
||||
func (c *SolverManager) SetDNS01Provider(p challenge.Provider, opts ...dnsnew.ChallengeOption) error {
|
||||
c.solvers[challenge.DNS01] = dnsnew.NewChallenge(c.core, validate, p, opts...)
|
||||
func (c *SolverManager) SetDNS01Provider(p challenge.Provider, opts ...dns01.ChallengeOption) error {
|
||||
c.solvers[challenge.DNS01] = dns01.NewChallenge(c.core, validate, p, opts...)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/challenge/http01"
|
||||
"github.com/go-acme/lego/v5/challenge/tlsalpn01"
|
||||
"github.com/go-acme/lego/v5/lego"
|
||||
|
|
@ -170,25 +170,25 @@ func setupDNS(ctx *cli.Context, client *lego.Client) error {
|
|||
return err
|
||||
}
|
||||
|
||||
opts := &dnsnew.Options{RecursiveNameservers: ctx.StringSlice(flgDNSResolvers)}
|
||||
opts := &dns01.Options{RecursiveNameservers: ctx.StringSlice(flgDNSResolvers)}
|
||||
|
||||
if ctx.IsSet(flgDNSTimeout) {
|
||||
opts.Timeout = time.Duration(ctx.Int(flgDNSTimeout)) * time.Second
|
||||
}
|
||||
|
||||
dnsnew.SetDefaultClient(dnsnew.NewClient(opts))
|
||||
dns01.SetDefaultClient(dns01.NewClient(opts))
|
||||
|
||||
err = client.Challenge.SetDNS01Provider(provider,
|
||||
dnsnew.CondOption(ctx.Bool(flgDNSDisableCP) || ctx.Bool(flgDNSPropagationDisableANS),
|
||||
dnsnew.DisableAuthoritativeNssPropagationRequirement()),
|
||||
dns01.CondOption(ctx.Bool(flgDNSDisableCP) || ctx.Bool(flgDNSPropagationDisableANS),
|
||||
dns01.DisableAuthoritativeNssPropagationRequirement()),
|
||||
|
||||
dnsnew.CondOption(ctx.Duration(flgDNSPropagationWait) > 0,
|
||||
dns01.CondOption(ctx.Duration(flgDNSPropagationWait) > 0,
|
||||
// TODO(ldez): inside the next major version we will use flgDNSDisableCP here.
|
||||
// This will change the meaning of this flag to really disable all propagation checks.
|
||||
dnsnew.PropagationWait(wait, true)),
|
||||
dns01.PropagationWait(wait, true)),
|
||||
|
||||
dnsnew.CondOption(ctx.Bool(flgDNSPropagationRNS),
|
||||
dnsnew.RecursiveNSsPropagationRequirement()),
|
||||
dns01.CondOption(ctx.Bool(flgDNSPropagationRNS),
|
||||
dns01.RecursiveNSsPropagationRequirement()),
|
||||
)
|
||||
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/go-acme/lego/v5/certificate"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/e2e/loader"
|
||||
"github.com/go-acme/lego/v5/lego"
|
||||
"github.com/go-acme/lego/v5/providers/dns"
|
||||
|
|
@ -98,7 +98,7 @@ func TestChallengeDNS_Client_Obtain(t *testing.T) {
|
|||
mockDefault(t)
|
||||
|
||||
err = client.Challenge.SetDNS01Provider(provider,
|
||||
dnsnew.DisableAuthoritativeNssPropagationRequirement())
|
||||
dns01.DisableAuthoritativeNssPropagationRequirement())
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := t.Context()
|
||||
|
|
@ -158,7 +158,7 @@ func TestChallengeDNS_Client_Obtain_profile(t *testing.T) {
|
|||
mockDefault(t)
|
||||
|
||||
err = client.Challenge.SetDNS01Provider(provider,
|
||||
dnsnew.DisableAuthoritativeNssPropagationRequirement())
|
||||
dns01.DisableAuthoritativeNssPropagationRequirement())
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := t.Context()
|
||||
|
|
@ -205,11 +205,11 @@ func (f *fakeUser) GetPrivateKey() crypto.PrivateKey { return f.privateKe
|
|||
func mockDefault(t *testing.T) {
|
||||
t.Helper()
|
||||
|
||||
backup := dnsnew.DefaultClient()
|
||||
backup := dns01.DefaultClient()
|
||||
|
||||
t.Cleanup(func() {
|
||||
dnsnew.SetDefaultClient(backup)
|
||||
dns01.SetDefaultClient(backup)
|
||||
})
|
||||
|
||||
dnsnew.SetDefaultClient(dnsnew.NewClient(&dnsnew.Options{RecursiveNameservers: []string{":8053"}}))
|
||||
dns01.SetDefaultClient(dns01.NewClient(&dns01.Options{RecursiveNameservers: []string{":8053"}}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/acmedns/internal"
|
||||
"github.com/nrdcg/goacmedns"
|
||||
|
|
@ -168,7 +168,7 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
|||
ctx := context.Background()
|
||||
|
||||
// Compute the challenge response FQDN and TXT value for the domain based on the keyAuth.
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
// Check if credentials were previously saved for this domain.
|
||||
account, err := d.storage.Fetch(ctx, domain)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/active24"
|
||||
)
|
||||
|
|
@ -34,9 +34,9 @@ type Config = active24.Config
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/aliyun/credentials-go/credentials"
|
||||
alidns "github.com/go-acme/alidns-20150109/v4/client"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/ptr"
|
||||
"golang.org/x/net/idna"
|
||||
|
|
@ -55,8 +55,8 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPTimeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 10*time.Second),
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zoneName, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -178,7 +178,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
records, err := d.findTxtRecords(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -228,7 +228,7 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
|
|||
startPage++
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, domain)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, domain)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
|
|||
var hostedZone *alidns.DescribeDomainsResponseBodyDomainsDomain
|
||||
|
||||
for _, zone := range domains {
|
||||
if ptr.Deref(zone.DomainName) == dnsnew.UnFqdn(authZone) || ptr.Deref(zone.PunyCode) == dnsnew.UnFqdn(authZone) {
|
||||
if ptr.Deref(zone.DomainName) == dns01.UnFqdn(authZone) || ptr.Deref(zone.PunyCode) == dns01.UnFqdn(authZone) {
|
||||
hostedZone = zone
|
||||
}
|
||||
}
|
||||
|
|
@ -299,7 +299,7 @@ func extractRecordName(fqdn, zone string) (string, error) {
|
|||
return "", fmt.Errorf("fail to convert punycode: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, asciiDomain)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, asciiDomain)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/alibabacloud-go/tea/dara"
|
||||
"github.com/aliyun/credentials-go/credentials"
|
||||
esa "github.com/go-acme/esa-20240910/v2/client"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/ptr"
|
||||
)
|
||||
|
|
@ -52,9 +52,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPTimeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
siteID, err := d.getSiteID(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -171,7 +171,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
crReq := new(esa.CreateRecordRequest).
|
||||
SetSiteId(siteID).
|
||||
SetType("TXT").
|
||||
SetRecordName(dnsnew.UnFqdn(info.EffectiveFQDN)).
|
||||
SetRecordName(dns01.UnFqdn(info.EffectiveFQDN)).
|
||||
SetTtl(int32(d.config.TTL)).
|
||||
SetData(new(esa.CreateRecordRequestData).SetValue(info.Value))
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
// gets the record's unique ID
|
||||
d.recordIDsMu.Lock()
|
||||
|
|
@ -226,13 +226,13 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
}
|
||||
|
||||
func (d *DNSProvider) getSiteID(ctx context.Context, fqdn string) (int64, error) {
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("aliesa: could not find zone for domain %q: %w", fqdn, err)
|
||||
}
|
||||
|
||||
lsReq := new(esa.ListSitesRequest).
|
||||
SetSiteName(dnsnew.UnFqdn(authZone)).
|
||||
SetSiteName(dns01.UnFqdn(authZone)).
|
||||
SetSiteSearchType("suffix")
|
||||
|
||||
// https://www.alibabacloud.com/help/en/edge-security-acceleration/esa/api-esa-2024-09-10-listsites
|
||||
|
|
@ -241,7 +241,7 @@ func (d *DNSProvider) getSiteID(ctx context.Context, fqdn string) (int64, error)
|
|||
return 0, fmt.Errorf("list sites: %w", err)
|
||||
}
|
||||
|
||||
for f := range dnsnew.UnFqdnDomainsSeq(fqdn) {
|
||||
for f := range dns01.UnFqdnDomainsSeq(fqdn) {
|
||||
for _, site := range lsResp.Body.GetSites() {
|
||||
if ptr.Deref(site.GetSiteName()) == f {
|
||||
return ptr.Deref(site.GetSiteId()), nil
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/allinkl/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -43,8 +43,8 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -121,9 +121,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("allinkl: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
|
||||
ctx = internal.WithContext(ctx, credential)
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("allinkl: %w", err)
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
credential, err := d.identifier.Authentication(ctx, 60, true)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/alwaysdata/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -41,9 +41,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -97,14 +97,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.findZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("alwaysdata: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("alwaysdata: %w", err)
|
||||
}
|
||||
|
|
@ -130,14 +130,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.findZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("alwaysdata: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("alwaysdata: %w", err)
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ func (d *DNSProvider) findZone(ctx context.Context, fqdn string) (*internal.Doma
|
|||
return nil, fmt.Errorf("list domains: %w", err)
|
||||
}
|
||||
|
||||
for a := range dnsnew.UnFqdnDomainsSeq(fqdn) {
|
||||
for a := range dns01.UnFqdnDomainsSeq(fqdn) {
|
||||
for _, domain := range domains {
|
||||
if a == domain.Name {
|
||||
return &domain, nil
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
"github.com/cenkalti/backoff/v5"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/anexia/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -51,7 +51,7 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, defaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 5*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -125,9 +125,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("anexia: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("anexia: %w", err)
|
||||
}
|
||||
|
||||
zoneName := dnsnew.UnFqdn(authZone)
|
||||
zoneName := dns01.UnFqdn(authZone)
|
||||
|
||||
recordReq := internal.Record{
|
||||
Name: recordName,
|
||||
|
|
@ -160,9 +160,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("anexia: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -172,12 +172,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("anexia: %w", err)
|
||||
}
|
||||
|
||||
recordID, err := d.findRecordID(ctx, dnsnew.UnFqdn(authZone), recordName, info.Value)
|
||||
recordID, err := d.findRecordID(ctx, dns01.UnFqdn(authZone), recordName, info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("anexia: %w", err)
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(ctx, dnsnew.UnFqdn(authZone), recordID)
|
||||
err = d.client.DeleteRecord(ctx, dns01.UnFqdn(authZone), recordID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("anexia: delete TXT record: %w", err)
|
||||
}
|
||||
|
|
@ -228,10 +228,10 @@ func findRecordIdentifier(zone *internal.Zone, recordName, rdata string) string
|
|||
}
|
||||
|
||||
func extractRecordName(fqdn, authZone string) (string, error) {
|
||||
if dnsnew.UnFqdn(fqdn) == dnsnew.UnFqdn(authZone) {
|
||||
if dns01.UnFqdn(fqdn) == dns01.UnFqdn(authZone) {
|
||||
// "@" for the root domain instead of an empty string.
|
||||
return "@", nil
|
||||
}
|
||||
|
||||
return dnsnew.ExtractSubDomain(fqdn, authZone)
|
||||
return dns01.ExtractSubDomain(fqdn, authZone)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/arvancloud/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -115,16 +115,16 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("arvancloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
authZone = dnsnew.UnFqdn(authZone)
|
||||
authZone = dns01.UnFqdn(authZone)
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("arvancloud: %w", err)
|
||||
}
|
||||
|
|
@ -158,14 +158,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("arvancloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
authZone = dnsnew.UnFqdn(authZone)
|
||||
authZone = dns01.UnFqdn(authZone)
|
||||
|
||||
// gets the record's unique ID from when we created it
|
||||
d.recordIDsMu.Lock()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
"github.com/miekg/dns"
|
||||
|
|
@ -47,8 +47,8 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,9 +112,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("aurora: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
|
||||
subdomain := info.EffectiveFQDN[0 : len(info.EffectiveFQDN)-len(authZone)-1]
|
||||
|
||||
authZone = dnsnew.UnFqdn(authZone)
|
||||
authZone = dns01.UnFqdn(authZone)
|
||||
|
||||
zone, err := d.getZoneInformationByName(authZone)
|
||||
if err != nil {
|
||||
|
|
@ -157,7 +157,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes a given record that was generated by Present.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
d.recordIDsMu.Lock()
|
||||
recordID, ok := d.recordIDs[token]
|
||||
|
|
@ -167,12 +167,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("aurora: unknown recordID for %q", info.EffectiveFQDN)
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, dns.Fqdn(info.EffectiveFQDN))
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, dns.Fqdn(info.EffectiveFQDN))
|
||||
if err != nil {
|
||||
return fmt.Errorf("aurora: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
authZone = dnsnew.UnFqdn(authZone)
|
||||
authZone = dns01.UnFqdn(authZone)
|
||||
|
||||
zone, err := d.getZoneInformationByName(authZone)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/autodns/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -120,7 +120,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
records := []*internal.ResourceRecord{{
|
||||
Name: info.EffectiveFQDN,
|
||||
|
|
@ -140,7 +140,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record previously created.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
records := []*internal.ResourceRecord{{
|
||||
Name: info.EffectiveFQDN,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/axelname/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -41,9 +41,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -97,14 +97,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("axelname: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("axelname: %w", err)
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
Value: info.Value,
|
||||
}
|
||||
|
||||
err = d.client.AddRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
err = d.client.AddRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("axelname: add record: %w", err)
|
||||
}
|
||||
|
|
@ -127,14 +127,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("axelname: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
records, err := d.client.ListRecords(ctx, dnsnew.UnFqdn(authZone))
|
||||
records, err := d.client.ListRecords(ctx, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("axelname: list records: %w", err)
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
continue
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
err = d.client.DeleteRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("axelname: delete record: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/aziontech/azionapi-go-sdk/idns"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
)
|
||||
|
|
@ -42,9 +42,9 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PageSize: env.GetOrDefaultInt(EnvPageSize, 50),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -107,7 +107,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
ctxAuth := authContext(ctx, d.config.PersonalToken)
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
ctxAuth := authContext(ctx, d.config.PersonalToken)
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ func (d *DNSProvider) findZone(ctx context.Context, fqdn string) (*idns.Zone, er
|
|||
return nil, errors.New("get zones: no results")
|
||||
}
|
||||
|
||||
for domain := range dnsnew.UnFqdnDomainsSeq(fqdn) {
|
||||
for domain := range dns01.UnFqdnDomainsSeq(fqdn) {
|
||||
for _, zone := range resp.GetResults() {
|
||||
if zone.GetDomain() == domain {
|
||||
return &zone, nil
|
||||
|
|
@ -295,8 +295,8 @@ func authContext(ctx context.Context, key string) context.Context {
|
|||
})
|
||||
}
|
||||
|
||||
func extractSubDomain(info dnsnew.ChallengeInfo, zone *idns.Zone) (string, error) {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.GetName())
|
||||
func extractSubDomain(info dns01.ChallengeInfo, zone *idns.Zone) (string, error) {
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.GetName())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/profiles/latest/privatedns/mgmt/privatedns"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
)
|
||||
|
||||
// dnsProviderPrivate implements the challenge.Provider interface for Azure Private Zone DNS.
|
||||
|
|
@ -28,7 +28,7 @@ func (d *dnsProviderPrivate) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *dnsProviderPrivate) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZoneID(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -38,7 +38,7 @@ func (d *dnsProviderPrivate) Present(domain, token, keyAuth string) error {
|
|||
rsc := privatedns.NewRecordSetsClientWithBaseURI(d.config.ResourceManagerEndpoint, d.config.SubscriptionID)
|
||||
rsc.Authorizer = d.authorizer
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure: %w", err)
|
||||
}
|
||||
|
|
@ -89,14 +89,14 @@ func (d *dnsProviderPrivate) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *dnsProviderPrivate) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZoneID(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure: %w", err)
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ func (d *dnsProviderPrivate) getHostedZoneID(ctx context.Context, fqdn string) (
|
|||
return d.config.ZoneName, nil
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ func (d *dnsProviderPrivate) getHostedZoneID(ctx context.Context, fqdn string) (
|
|||
dc := privatedns.NewPrivateZonesClientWithBaseURI(d.config.ResourceManagerEndpoint, d.config.SubscriptionID)
|
||||
dc.Authorizer = d.authorizer
|
||||
|
||||
zone, err := dc.Get(ctx, d.config.ResourceGroup, dnsnew.UnFqdn(authZone))
|
||||
zone, err := dc.Get(ctx, d.config.ResourceGroup, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/profiles/latest/dns/mgmt/dns"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
)
|
||||
|
||||
// dnsProviderPublic implements the challenge.Provider interface for Azure Public Zone DNS.
|
||||
|
|
@ -28,7 +28,7 @@ func (d *dnsProviderPublic) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *dnsProviderPublic) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZoneID(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -38,7 +38,7 @@ func (d *dnsProviderPublic) Present(domain, token, keyAuth string) error {
|
|||
rsc := dns.NewRecordSetsClientWithBaseURI(d.config.ResourceManagerEndpoint, d.config.SubscriptionID)
|
||||
rsc.Authorizer = d.authorizer
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure: %w", err)
|
||||
}
|
||||
|
|
@ -89,14 +89,14 @@ func (d *dnsProviderPublic) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *dnsProviderPublic) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZoneID(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure: %w", err)
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ func (d *dnsProviderPublic) getHostedZoneID(ctx context.Context, fqdn string) (s
|
|||
return d.config.ZoneName, nil
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ func (d *dnsProviderPublic) getHostedZoneID(ctx context.Context, fqdn string) (s
|
|||
dc := dns.NewZonesClientWithBaseURI(d.config.ResourceManagerEndpoint, d.config.SubscriptionID)
|
||||
dc.Authorizer = d.authorizer
|
||||
|
||||
zone, err := dc.Get(ctx, d.config.ResourceGroup, dnsnew.UnFqdn(authZone))
|
||||
zone, err := dc.Get(ctx, d.config.ResourceGroup, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -111,7 +111,7 @@ func getZoneName(ctx context.Context, config *Config, fqdn string) (string, erro
|
|||
return config.ZoneName, nil
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone for %s: %w", fqdn, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/ptr"
|
||||
)
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ func (d *DNSProviderPrivate) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProviderPrivate) Present(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -61,7 +61,7 @@ func (d *DNSProviderPrivate) Present(domain, _, keyAuth string) error {
|
|||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ func (d *DNSProviderPrivate) Present(domain, _, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProviderPrivate) CleanUp(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -114,7 +114,7 @@ func (d *DNSProviderPrivate) CleanUp(domain, _, keyAuth string) error {
|
|||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ func (d *DNSProviderPrivate) getHostedZone(ctx context.Context, fqdn string) (Se
|
|||
return ServiceDiscoveryZone{}, err
|
||||
}
|
||||
|
||||
azureZone, exists := d.serviceDiscoveryZones[dnsnew.UnFqdn(authZone)]
|
||||
azureZone, exists := d.serviceDiscoveryZones[dns01.UnFqdn(authZone)]
|
||||
if !exists {
|
||||
return ServiceDiscoveryZone{}, fmt.Errorf("could not find zone (from discovery): %s", authZone)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/ptr"
|
||||
)
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ func (d *DNSProviderPublic) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProviderPublic) Present(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -61,7 +61,7 @@ func (d *DNSProviderPublic) Present(domain, _, keyAuth string) error {
|
|||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ func (d *DNSProviderPublic) Present(domain, _, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProviderPublic) CleanUp(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -113,7 +113,7 @@ func (d *DNSProviderPublic) CleanUp(domain, _, keyAuth string) error {
|
|||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("azuredns: %w", err)
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ func (d *DNSProviderPublic) getHostedZone(ctx context.Context, fqdn string) (Ser
|
|||
return ServiceDiscoveryZone{}, err
|
||||
}
|
||||
|
||||
azureZone, exists := d.serviceDiscoveryZones[dnsnew.UnFqdn(authZone)]
|
||||
azureZone, exists := d.serviceDiscoveryZones[dns01.UnFqdn(authZone)]
|
||||
if !exists {
|
||||
return ServiceDiscoveryZone{}, fmt.Errorf("could not find zone (from discovery): %s", authZone)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
baidudns "github.com/baidubce/bce-sdk-go/services/dns"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/ptr"
|
||||
)
|
||||
|
|
@ -42,8 +42,8 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, defaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,14 +91,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(context.Background(), info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(context.Background(), info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("baiducloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("baiducloud: %w", err)
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
Ttl: ptr.Pointer(int32(d.config.TTL)),
|
||||
}
|
||||
|
||||
err = d.client.CreateRecord(dnsnew.UnFqdn(authZone), crr, "")
|
||||
err = d.client.CreateRecord(dns01.UnFqdn(authZone), crr, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("baiducloud: create record: %w", err)
|
||||
}
|
||||
|
|
@ -122,19 +122,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(context.Background(), info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(context.Background(), info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("baiducloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
recordID, err := d.findRecordID(dnsnew.UnFqdn(authZone), info.Value)
|
||||
recordID, err := d.findRecordID(dns01.UnFqdn(authZone), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("baiducloud: find record: %w", err)
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(dnsnew.UnFqdn(authZone), recordID, "")
|
||||
err = d.client.DeleteRecord(dns01.UnFqdn(authZone), recordID, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("baiducloud: delete record: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/beget/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -106,9 +106,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
records, err := d.client.GetTXTRecords(ctx, dnsnew.UnFqdn(info.EffectiveFQDN))
|
||||
records, err := d.client.GetTXTRecords(ctx, dns01.UnFqdn(info.EffectiveFQDN))
|
||||
if err != nil {
|
||||
return fmt.Errorf("beget: get TXT records: %w", err)
|
||||
}
|
||||
|
|
@ -120,10 +120,10 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
TTL: d.config.TTL,
|
||||
})
|
||||
|
||||
err = d.client.ChangeTXTRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), records)
|
||||
err = d.client.ChangeTXTRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN), records)
|
||||
if err != nil {
|
||||
return fmt.Errorf("beget: failed to create TXT records [domain: %s]: %w",
|
||||
dnsnew.UnFqdn(info.EffectiveFQDN), err)
|
||||
dns01.UnFqdn(info.EffectiveFQDN), err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -133,9 +133,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
records, err := d.client.GetTXTRecords(ctx, dnsnew.UnFqdn(info.EffectiveFQDN))
|
||||
records, err := d.client.GetTXTRecords(ctx, dns01.UnFqdn(info.EffectiveFQDN))
|
||||
if err != nil {
|
||||
return fmt.Errorf("beget: get TXT records: %w", err)
|
||||
}
|
||||
|
|
@ -154,10 +154,10 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
updatedRecords = append(updatedRecords, record)
|
||||
}
|
||||
|
||||
err = d.client.ChangeTXTRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), updatedRecords)
|
||||
err = d.client.ChangeTXTRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN), updatedRecords)
|
||||
if err != nil {
|
||||
return fmt.Errorf("beget: failed to remove TXT records [domain: %s]: %w",
|
||||
dnsnew.UnFqdn(info.EffectiveFQDN), err)
|
||||
dns01.UnFqdn(info.EffectiveFQDN), err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/binarylane/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -41,8 +41,8 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 3600),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -99,14 +99,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("binarylane: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("binarylane: %w", err)
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
TTL: d.config.TTL,
|
||||
}
|
||||
|
||||
response, err := d.client.CreateRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
response, err := d.client.CreateRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("binarylane: create record: %w", err)
|
||||
}
|
||||
|
|
@ -134,9 +134,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("binarylane: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("binarylane: unknown record ID for '%s'", info.EffectiveFQDN)
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(ctx, dnsnew.UnFqdn(authZone), recordID)
|
||||
err = d.client.DeleteRecord(ctx, dns01.UnFqdn(authZone), recordID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("binarylane: delete record: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
bindman "github.com/labbsr0x/bindman-dns-webhook/src/client"
|
||||
|
|
@ -39,8 +39,8 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, time.Minute),
|
||||
},
|
||||
|
|
@ -95,7 +95,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// so make sure the FQDN specified is within an extant zone.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
if err := d.client.AddRecord(info.EffectiveFQDN, "TXT", info.Value); err != nil {
|
||||
return fmt.Errorf("bindman: %w", err)
|
||||
|
|
@ -107,7 +107,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
if err := d.client.RemoveRecord(info.EffectiveFQDN, "TXT"); err != nil {
|
||||
return fmt.Errorf("bindman: %w", err)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/bluecat/internal"
|
||||
|
|
@ -54,9 +54,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -121,7 +121,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// so make sure the FQDN specified is within an existent zone.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
ctxAuth, err := d.client.CreateAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -171,7 +171,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
ctxAuth, err := d.client.CreateAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/bookmyname/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -44,9 +44,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -99,10 +99,10 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
record := internal.Record{
|
||||
Hostname: dnsnew.UnFqdn(info.EffectiveFQDN),
|
||||
Hostname: dns01.UnFqdn(info.EffectiveFQDN),
|
||||
Type: "txt",
|
||||
TTL: d.config.TTL,
|
||||
Value: info.Value,
|
||||
|
|
@ -119,10 +119,10 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
record := internal.Record{
|
||||
Hostname: dnsnew.UnFqdn(info.EffectiveFQDN),
|
||||
Hostname: dns01.UnFqdn(info.EffectiveFQDN),
|
||||
Type: "txt",
|
||||
TTL: d.config.TTL,
|
||||
Value: info.Value,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/brandit/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 10*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -112,14 +112,14 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: %w", err)
|
||||
}
|
||||
|
|
@ -132,18 +132,18 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
}
|
||||
|
||||
// find the account associated with the domain
|
||||
account, err := d.client.StatusDomain(ctx, dnsnew.UnFqdn(authZone))
|
||||
account, err := d.client.StatusDomain(ctx, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: status domain: %w", err)
|
||||
}
|
||||
|
||||
// Find the next record id
|
||||
recordID, err := d.client.ListRecords(ctx, account.Registrar[0], dnsnew.UnFqdn(authZone))
|
||||
recordID, err := d.client.ListRecords(ctx, account.Registrar[0], dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: list records: %w", err)
|
||||
}
|
||||
|
||||
result, err := d.client.AddRecord(ctx, dnsnew.UnFqdn(authZone), account.Registrar[0], strconv.Itoa(recordID.Total[0]), record)
|
||||
result, err := d.client.AddRecord(ctx, dns01.UnFqdn(authZone), account.Registrar[0], strconv.Itoa(recordID.Total[0]), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: add record: %w", err)
|
||||
}
|
||||
|
|
@ -159,9 +159,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -176,12 +176,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
}
|
||||
|
||||
// find the account associated with the domain
|
||||
account, err := d.client.StatusDomain(ctx, dnsnew.UnFqdn(authZone))
|
||||
account, err := d.client.StatusDomain(ctx, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: status domain: %w", err)
|
||||
}
|
||||
|
||||
records, err := d.client.ListRecords(ctx, account.Registrar[0], dnsnew.UnFqdn(authZone))
|
||||
records, err := d.client.ListRecords(ctx, account.Registrar[0], dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: list records: %w", err)
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
}
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(ctx, dnsnew.UnFqdn(authZone), account.Registrar[0], dnsRecord, strconv.Itoa(recordID))
|
||||
err = d.client.DeleteRecord(ctx, dns01.UnFqdn(authZone), account.Registrar[0], dnsRecord, strconv.Itoa(recordID))
|
||||
if err != nil {
|
||||
return fmt.Errorf("brandit: delete record: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/ptr"
|
||||
|
|
@ -50,7 +50,7 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 120*time.Second),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -115,14 +115,14 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.findZone(ctx, dnsnew.UnFqdn(info.EffectiveFQDN))
|
||||
zone, err := d.findZone(ctx, dns01.UnFqdn(info.EffectiveFQDN))
|
||||
if err != nil {
|
||||
return fmt.Errorf("bunny: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, ptr.Deref(zone.Domain))
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, ptr.Deref(zone.Domain))
|
||||
if err != nil {
|
||||
return fmt.Errorf("bunny: %w", err)
|
||||
}
|
||||
|
|
@ -144,14 +144,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.findZone(ctx, dnsnew.UnFqdn(info.EffectiveFQDN))
|
||||
zone, err := d.findZone(ctx, dns01.UnFqdn(info.EffectiveFQDN))
|
||||
if err != nil {
|
||||
return fmt.Errorf("bunny: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, ptr.Deref(zone.Domain))
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, ptr.Deref(zone.Domain))
|
||||
if err != nil {
|
||||
return fmt.Errorf("bunny: %w", err)
|
||||
}
|
||||
|
|
@ -220,13 +220,13 @@ func possibleDomains(domain string) []string {
|
|||
var domains []string
|
||||
|
||||
tld, _ := publicsuffix.PublicSuffix(domain)
|
||||
for d := range dnsnew.DomainsSeq(domain) {
|
||||
for d := range dns01.DomainsSeq(domain) {
|
||||
if tld == d {
|
||||
// skip the TLD
|
||||
break
|
||||
}
|
||||
|
||||
domains = append(domains, dnsnew.UnFqdn(d))
|
||||
domains = append(domains, dns01.UnFqdn(d))
|
||||
}
|
||||
|
||||
return domains
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/checkdomain/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -116,7 +116,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("checkdomain: %w", err)
|
||||
}
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err = d.client.CreateRecord(ctx, domainID, &internal.Record{
|
||||
Name: info.EffectiveFQDN,
|
||||
|
|
@ -146,7 +146,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("checkdomain: %w", err)
|
||||
}
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
defer d.client.CleanCache(info.EffectiveFQDN)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/tester/servermock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -113,7 +113,7 @@ func TestClient_DeleteTXTRecord(t *testing.T) {
|
|||
servermock.CheckRequestJSONBodyFromFixture("delete_txt_record-request.json")).
|
||||
Build(t)
|
||||
|
||||
info := dnsnew.GetChallengeInfo(t.Context(), domainName, "abc")
|
||||
info := dns01.GetChallengeInfo(t.Context(), domainName, "abc")
|
||||
|
||||
err := client.DeleteTXTRecord(t.Context(), 1, info.EffectiveFQDN, recordValue)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/civo/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -107,21 +107,21 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("civo: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
zone := dnsnew.UnFqdn(authZone)
|
||||
zone := dns01.UnFqdn(authZone)
|
||||
|
||||
domainID, err := d.getDomainIDByName(ctx, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("civo: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("civo: %w", err)
|
||||
}
|
||||
|
|
@ -142,14 +142,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("civo: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
zone := dnsnew.UnFqdn(authZone)
|
||||
zone := dns01.UnFqdn(authZone)
|
||||
|
||||
domainID, err := d.getDomainIDByName(ctx, zone)
|
||||
if err != nil {
|
||||
|
|
@ -161,7 +161,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
return fmt.Errorf("civo: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("civo: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/clouddns/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -109,9 +109,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("clouddns: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -133,9 +133,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("clouddns: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/cloudflare/internal"
|
||||
)
|
||||
|
|
@ -68,7 +68,7 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
TTL: env.GetOneWithFallback(EnvTTL, minTTL, strconv.Atoi, altEnvName(EnvTTL)),
|
||||
PropagationTimeout: env.GetOneWithFallback(EnvPropagationTimeout, 2*time.Minute, env.ParseSecond, altEnvName(EnvPropagationTimeout)),
|
||||
PollingInterval: env.GetOneWithFallback(EnvPollingInterval, dnsnew.DefaultPollingInterval, env.ParseSecond, altEnvName(EnvPollingInterval)),
|
||||
PollingInterval: env.GetOneWithFallback(EnvPollingInterval, dns01.DefaultPollingInterval, env.ParseSecond, altEnvName(EnvPollingInterval)),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOneWithFallback(EnvHTTPTimeout, 30*time.Second, env.ParseSecond, altEnvName(EnvHTTPTimeout)),
|
||||
},
|
||||
|
|
@ -156,9 +156,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cloudflare: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
|
||||
dnsRecord := internal.Record{
|
||||
Type: "TXT",
|
||||
Name: dnsnew.UnFqdn(info.EffectiveFQDN),
|
||||
Name: dns01.UnFqdn(info.EffectiveFQDN),
|
||||
Content: `"` + info.Value + `"`,
|
||||
TTL: d.config.TTL,
|
||||
}
|
||||
|
|
@ -191,9 +191,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cloudflare: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"errors"
|
||||
"sync"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/cloudflare/internal"
|
||||
)
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ func (m *metaClient) ZoneIDByName(ctx context.Context, fdqn string) (string, err
|
|||
return id, nil
|
||||
}
|
||||
|
||||
zones, err := m.clientRead.ZonesByName(ctx, dnsnew.UnFqdn(fdqn))
|
||||
zones, err := m.clientRead.ZonesByName(ctx, dns01.UnFqdn(fdqn))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/cenkalti/backoff/v5"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/platform/wait"
|
||||
|
|
@ -114,7 +114,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.client.GetZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -132,7 +132,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT records matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.client.GetZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/errutils"
|
||||
)
|
||||
|
||||
|
|
@ -53,12 +53,12 @@ func NewClient(authID, subAuthID, authPassword string) (*Client, error) {
|
|||
|
||||
// GetZone Get domain name information for a FQDN.
|
||||
func (c *Client) GetZone(ctx context.Context, authFQDN string) (*Zone, error) {
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, authFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, authFQDN)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
||||
authZoneName := dnsnew.UnFqdn(authZone)
|
||||
authZoneName := dns01.UnFqdn(authZone)
|
||||
|
||||
endpoint := c.BaseURL.JoinPath("get-zone-info.json")
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ func (c *Client) GetZone(ctx context.Context, authFQDN string) (*Zone, error) {
|
|||
|
||||
// FindTxtRecord returns the TXT record a zone ID and a FQDN.
|
||||
func (c *Client) FindTxtRecord(ctx context.Context, zoneName, fqdn string) (*TXTRecord, error) {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zoneName)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zoneName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ func (c *Client) FindTxtRecord(ctx context.Context, zoneName, fqdn string) (*TXT
|
|||
|
||||
// ListTxtRecords returns the TXT records a zone ID and a FQDN.
|
||||
func (c *Client) ListTxtRecords(ctx context.Context, zoneName, fqdn string) ([]TXTRecord, error) {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zoneName)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zoneName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ func (c *Client) ListTxtRecords(ctx context.Context, zoneName, fqdn string) ([]T
|
|||
|
||||
// AddTxtRecord adds a TXT record.
|
||||
func (c *Client) AddTxtRecord(ctx context.Context, zoneName, fqdn, value string, ttl int) error {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zoneName)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zoneName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/cloudru/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -50,10 +50,10 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 5*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 5*time.Second),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dnsnew.DefaultPropagationTimeout),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -114,14 +114,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cloudru: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
authZone = dnsnew.UnFqdn(authZone)
|
||||
authZone = dns01.UnFqdn(authZone)
|
||||
|
||||
ctxAuth, err := d.client.CreateAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -155,7 +155,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes a given record that was generated by Present.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
d.recordsMu.Lock()
|
||||
record, ok := d.records[token]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
)
|
||||
|
||||
// Environment variables names.
|
||||
|
|
@ -63,5 +63,5 @@ func (d *DNSProvider) CleanUp(_, _, _ string) error {
|
|||
// 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 dnsnew.DefaultPropagationTimeout, dnsnew.DefaultPollingInterval
|
||||
return dns01.DefaultPropagationTimeout, dns01.DefaultPollingInterval
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/conoha/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -49,8 +49,8 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
Region: env.GetOrDefaultString(EnvRegion, "tyo1"),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -132,9 +132,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("conoha: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -163,9 +163,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("conoha: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/conohav3/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -49,8 +49,8 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
Region: env.GetOrDefaultString(EnvRegion, "c3j1"),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -141,9 +141,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("conohav3: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -172,9 +172,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("conohav3: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/constellix/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -47,7 +47,7 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 60),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 10*time.Second),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
|
|
@ -112,19 +112,19 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("constellix: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
dom, err := d.client.Domains.GetByName(ctx, dnsnew.UnFqdn(authZone))
|
||||
dom, err := d.client.Domains.GetByName(ctx, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("constellix: failed to get domain (%s): %w", authZone, err)
|
||||
}
|
||||
|
||||
recordName, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
recordName, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("constellix: %w", err)
|
||||
}
|
||||
|
|
@ -155,19 +155,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("constellix: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
dom, err := d.client.Domains.GetByName(ctx, dnsnew.UnFqdn(authZone))
|
||||
dom, err := d.client.Domains.GetByName(ctx, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("constellix: failed to get domain (%s): %w", authZone, err)
|
||||
}
|
||||
|
||||
recordName, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
recordName, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("constellix: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/corenetworks/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -45,9 +45,9 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 3600),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dnsnew.DefaultPropagationTimeout),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -111,19 +111,19 @@ func (d *DNSProvider) Sequential() time.Duration {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
ctxAuth, err := d.client.CreateAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create authentication token: %w", err)
|
||||
}
|
||||
|
||||
zone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctxAuth, info.EffectiveFQDN)
|
||||
zone, err := dns01.DefaultClient().FindZoneByFqdn(ctxAuth, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: %w", err)
|
||||
}
|
||||
|
|
@ -135,12 +135,12 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
Data: info.Value,
|
||||
}
|
||||
|
||||
err = d.client.AddRecord(ctxAuth, dnsnew.UnFqdn(zone), record)
|
||||
err = d.client.AddRecord(ctxAuth, dns01.UnFqdn(zone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: add record: %w", err)
|
||||
}
|
||||
|
||||
err = d.client.CommitRecords(ctxAuth, dnsnew.UnFqdn(zone))
|
||||
err = d.client.CommitRecords(ctxAuth, dns01.UnFqdn(zone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: commit records: %w", err)
|
||||
}
|
||||
|
|
@ -151,19 +151,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
ctxAuth, err := d.client.CreateAuthenticatedContext(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create authentication token: %w", err)
|
||||
}
|
||||
|
||||
zone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctxAuth, info.EffectiveFQDN)
|
||||
zone, err := dns01.DefaultClient().FindZoneByFqdn(ctxAuth, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, zone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: %w", err)
|
||||
}
|
||||
|
|
@ -175,12 +175,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
Data: info.Value,
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecords(ctxAuth, dnsnew.UnFqdn(zone), record)
|
||||
err = d.client.DeleteRecords(ctxAuth, dns01.UnFqdn(zone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: delete records: %w", err)
|
||||
}
|
||||
|
||||
err = d.client.CommitRecords(ctxAuth, dnsnew.UnFqdn(zone))
|
||||
err = d.client.CommitRecords(ctxAuth, dns01.UnFqdn(zone))
|
||||
if err != nil {
|
||||
return fmt.Errorf("corenetworks: commit records: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/cpanel/internal/cpanel"
|
||||
"github.com/go-acme/lego/v5/providers/dns/cpanel/internal/shared"
|
||||
|
|
@ -62,7 +62,7 @@ func NewDefaultConfig() *Config {
|
|||
Mode: env.GetOrDefaultString(EnvMode, "cpanel"),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 300),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 2*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -126,14 +126,14 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("arvancloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
zone := dnsnew.UnFqdn(authZone)
|
||||
zone := dns01.UnFqdn(authZone)
|
||||
|
||||
zoneInfo, err := d.client.FetchZoneInformation(ctx, zone)
|
||||
if err != nil {
|
||||
|
|
@ -204,14 +204,14 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("arvancloud: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
zone := dnsnew.UnFqdn(authZone)
|
||||
zone := dns01.UnFqdn(authZone)
|
||||
|
||||
zoneInfo, err := d.client.FetchZoneInformation(ctx, zone)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/ddnss/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -41,10 +41,10 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dnsnew.DefaultPropagationTimeout),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -96,9 +96,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err := d.client.AddTXTRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
err := d.client.AddTXTRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ddnss: add TXT record: %w", err)
|
||||
}
|
||||
|
|
@ -109,9 +109,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err := d.client.RemoveTXTRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN))
|
||||
err := d.client.RemoveTXTRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN))
|
||||
if err != nil {
|
||||
return fmt.Errorf("ddnss: remove TXT record: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/derak/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -46,7 +46,7 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 2*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 5*time.Second),
|
||||
HTTPClient: &http.Client{
|
||||
|
|
@ -113,14 +113,14 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("derak: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
recordName, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
recordName, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("derak: %w", err)
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zoneID, err := d.getZoneID(ctx, info)
|
||||
if err != nil {
|
||||
|
|
@ -181,7 +181,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *DNSProvider) getZoneID(ctx context.Context, info dnsnew.ChallengeInfo) (string, error) {
|
||||
func (d *DNSProvider) getZoneID(ctx context.Context, info dns01.ChallengeInfo) (string, error) {
|
||||
zoneID := d.config.WebsiteID
|
||||
if zoneID != "" {
|
||||
return zoneID, nil
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -108,19 +108,19 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("desec: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
recordName, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
recordName, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("desec: %w", err)
|
||||
}
|
||||
|
||||
domainName := dnsnew.UnFqdn(authZone)
|
||||
domainName := dns01.UnFqdn(authZone)
|
||||
|
||||
quotedValue := fmt.Sprintf(`%q`, info.Value)
|
||||
|
||||
|
|
@ -160,19 +160,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("desec: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
recordName, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
recordName, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("desec: %w", err)
|
||||
}
|
||||
|
||||
domainName := dnsnew.UnFqdn(authZone)
|
||||
domainName := dns01.UnFqdn(authZone)
|
||||
|
||||
rrSet, err := d.client.Records.Get(ctx, domainName, recordName, "TXT")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/gophercloud/gophercloud"
|
||||
|
|
@ -134,7 +134,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getZoneName(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -175,7 +175,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, err := d.getZoneName(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -303,7 +303,7 @@ func (d *DNSProvider) getZoneName(ctx context.Context, fqdn string) (string, err
|
|||
return d.config.ZoneName, nil
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone for %s: %w", fqdn, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/digitalocean/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -47,7 +47,7 @@ func NewDefaultConfig() *Config {
|
|||
return &Config{
|
||||
BaseURL: env.GetOrDefaultString(EnvAPIUrl, internal.DefaultBaseURL),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 30),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 5*time.Second),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
|
|
@ -121,9 +121,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("digitalocean: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -146,9 +146,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("digitalocean: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/errutils"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
|
@ -37,7 +37,7 @@ func NewClient(hc *http.Client) *Client {
|
|||
}
|
||||
|
||||
func (c *Client) AddTxtRecord(ctx context.Context, zone string, record Record) (*TxtRecordResponse, error) {
|
||||
endpoint := c.BaseURL.JoinPath("v2", "domains", dnsnew.UnFqdn(zone), "records")
|
||||
endpoint := c.BaseURL.JoinPath("v2", "domains", dns01.UnFqdn(zone), "records")
|
||||
|
||||
req, err := newJSONRequest(ctx, http.MethodPost, endpoint, record)
|
||||
if err != nil {
|
||||
|
|
@ -55,7 +55,7 @@ func (c *Client) AddTxtRecord(ctx context.Context, zone string, record Record) (
|
|||
}
|
||||
|
||||
func (c *Client) RemoveTxtRecord(ctx context.Context, zone string, recordID int) error {
|
||||
endpoint := c.BaseURL.JoinPath("v2", "domains", dnsnew.UnFqdn(zone), "records", strconv.Itoa(recordID))
|
||||
endpoint := c.BaseURL.JoinPath("v2", "domains", dns01.UnFqdn(zone), "records", strconv.Itoa(recordID))
|
||||
|
||||
req, err := newJSONRequest(ctx, http.MethodDelete, endpoint, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/directadmin/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -115,14 +115,14 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := d.getZoneName(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("directadmin: [domain: %q] %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("directadmin: %w", err)
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
TTL: d.config.TTL,
|
||||
}
|
||||
|
||||
err = d.client.SetRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
err = d.client.SetRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("directadmin: set record for zone %s and subdomain %s: %w", authZone, subDomain, err)
|
||||
}
|
||||
|
|
@ -146,14 +146,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := d.getZoneName(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("directadmin: [domain: %q] %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("directadmin: %w", err)
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
Value: info.Value,
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
err = d.client.DeleteRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("directadmin: delete record for zone %s and subdomain %s: %w", authZone, subDomain, err)
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ func (d *DNSProvider) getZoneName(ctx context.Context, fqdn string) (string, err
|
|||
return d.config.ZoneName, nil
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone for %s: %w", fqdn, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dnsexit/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -39,7 +39,7 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 5*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 10*time.Second),
|
||||
HTTPClient: &http.Client{
|
||||
|
|
@ -94,14 +94,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsexit: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsexit: %w", err)
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
TTL: toMinutes(d.config.TTL),
|
||||
}
|
||||
|
||||
err = d.client.AddRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
err = d.client.AddRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsexit: add record: %w", err)
|
||||
}
|
||||
|
|
@ -125,14 +125,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsexit: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsexit: %w", err)
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
|||
Content: info.Value,
|
||||
}
|
||||
|
||||
err = d.client.DeleteRecord(ctx, dnsnew.UnFqdn(authZone), record)
|
||||
err = d.client.DeleteRecord(ctx, dns01.UnFqdn(authZone), record)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsexit: add record: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dnshomede/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -39,7 +39,7 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 20*time.Minute),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, 2*time.Minute),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
|
|
@ -106,9 +106,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present updates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err := d.client.Add(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
err := d.client.Add(ctx, dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnshomede: %w", err)
|
||||
}
|
||||
|
|
@ -119,9 +119,9 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
|||
// CleanUp updates the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err := d.client.Remove(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
err := d.client.Remove(ctx, dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnshomede: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/dnsimple/dnsimple-go/v4/dnsimple"
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/useragent"
|
||||
|
|
@ -45,10 +45,10 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
Debug: env.GetOrDefaultBool(EnvDebug, false),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zoneName, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -132,7 +132,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
records, err := d.findTxtRecords(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -163,7 +163,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
}
|
||||
|
||||
func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string, error) {
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, domain)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, domain)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not find zone for FQDN %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
|
|||
return "", err
|
||||
}
|
||||
|
||||
hostedZone, err := d.client.Zones.GetZone(ctx, accountID, dnsnew.UnFqdn(authZone))
|
||||
hostedZone, err := d.client.Zones.GetZone(ctx, accountID, dns01.UnFqdn(authZone))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("get zone: %w", err)
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, fqdn string) ([]dnsimp
|
|||
return nil, err
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zoneName)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zoneName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, fqdn string) ([]dnsimp
|
|||
}
|
||||
|
||||
func newTxtRecord(zoneName, fqdn, value string, ttl int) (dnsimple.ZoneRecordAttributes, error) {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zoneName)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zoneName)
|
||||
if err != nil {
|
||||
return dnsimple.ZoneRecordAttributes{}, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dnsmadeeasy/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -58,9 +58,9 @@ func NewDefaultConfig() *Config {
|
|||
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 10*time.Second),
|
||||
Transport: tr,
|
||||
|
|
@ -134,9 +134,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domainName, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domainName, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsmadeeasy: could not find zone for domain %q: %w", domainName, err)
|
||||
}
|
||||
|
|
@ -163,9 +163,9 @@ func (d *DNSProvider) Present(domainName, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domainName, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domainName, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dnsmadeeasy: could not find zone for domain %q: %w", domainName, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/errutils"
|
||||
)
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ func (c *Client) GetDomain(ctx context.Context, authZone string) (*Domain, error
|
|||
endpoint := c.BaseURL.JoinPath("dns", "managed", "name")
|
||||
|
||||
query := endpoint.Query()
|
||||
query.Set("domainname", dnsnew.UnFqdn(authZone))
|
||||
query.Set("domainname", dns01.UnFqdn(authZone))
|
||||
endpoint.RawQuery = query.Encode()
|
||||
|
||||
req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
"github.com/nrdcg/dnspod-go"
|
||||
|
|
@ -43,8 +43,8 @@ type Config struct {
|
|||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, 600),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -97,7 +97,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zoneID, zoneName, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -120,7 +120,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zoneID, zoneName, err := d.getHostedZone(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -154,7 +154,7 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
|
|||
return "", "", fmt.Errorf("API call failed: %w", err)
|
||||
}
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, domain)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, domain)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
|
|||
var hostedZone dnspod.Domain
|
||||
|
||||
for _, zone := range zones {
|
||||
if zone.Name == dnsnew.UnFqdn(authZone) {
|
||||
if zone.Name == dns01.UnFqdn(authZone) {
|
||||
hostedZone = zone
|
||||
}
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
|
|||
}
|
||||
|
||||
func (d *DNSProvider) newTxtRecord(zone, fqdn, value string, ttl int) (*dnspod.Record, error) {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zone)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ func (d *DNSProvider) newTxtRecord(zone, fqdn, value string, ttl int) (*dnspod.R
|
|||
}
|
||||
|
||||
func (d *DNSProvider) findTxtRecords(fqdn, zoneID, zoneName string) ([]dnspod.Record, error) {
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zoneName)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zoneName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dode/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -41,9 +41,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dnsnew.DefaultPropagationTimeout),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -94,7 +94,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
return d.client.UpdateTxtRecord(ctx, info.EffectiveFQDN, info.Value, false)
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp clears TXT record.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
return d.client.UpdateTxtRecord(ctx, info.EffectiveFQDN, "", true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/errutils"
|
||||
)
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ func (c *Client) UpdateTxtRecord(ctx context.Context, fqdn, txt string, clearRec
|
|||
|
||||
query := endpoint.Query()
|
||||
query.Set("token", c.token)
|
||||
query.Set("domain", dnsnew.UnFqdn(fqdn))
|
||||
query.Set("domain", dns01.UnFqdn(fqdn))
|
||||
|
||||
// api call differs per set/delete
|
||||
if clearRecord {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/domeneshop/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -102,7 +102,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
|||
func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, host, err := d.splitDomain(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -126,7 +126,7 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
zone, host, err := d.splitDomain(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
|
|
@ -147,15 +147,15 @@ func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
|
|||
|
||||
// splitDomain splits the hostname from the authoritative zone, and returns both parts (non-fqdn).
|
||||
func (d *DNSProvider) splitDomain(ctx context.Context, fqdn string) (string, string, error) {
|
||||
zone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
zone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, fqdn)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("could not find zone: %w", err)
|
||||
}
|
||||
|
||||
subDomain, err := dnsnew.ExtractSubDomain(fqdn, zone)
|
||||
subDomain, err := dns01.ExtractSubDomain(fqdn, zone)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return dnsnew.UnFqdn(zone), subDomain, nil
|
||||
return dns01.UnFqdn(zone), subDomain, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dreamhost/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -99,9 +99,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record using the specified parameters.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err := d.client.AddRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
err := d.client.AddRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dreamhost: %w", err)
|
||||
}
|
||||
|
|
@ -112,9 +112,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
// CleanUp removes the TXT record matching the specified parameters.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
err := d.client.RemoveRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
err := d.client.RemoveRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dreamhost: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/duckdns/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -42,9 +42,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dnsnew.DefaultPropagationTimeout),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -95,17 +95,17 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
// Present creates a TXT record to fulfill the dns-01 challenge.
|
||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
return d.client.AddTXTRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
return d.client.AddTXTRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
}
|
||||
|
||||
// CleanUp clears DuckDNS TXT record.
|
||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
return d.client.RemoveTXTRecord(ctx, dnsnew.UnFqdn(info.EffectiveFQDN))
|
||||
return d.client.RemoveTXTRecord(ctx, dns01.UnFqdn(info.EffectiveFQDN))
|
||||
}
|
||||
|
||||
// Timeout returns the timeout and interval to use when checking for DNS propagation.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/errutils"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
|
@ -90,7 +90,7 @@ func (c *Client) UpdateTxtRecord(ctx context.Context, domain, txt string, clearR
|
|||
// not in format subsubdomain.subdomain.duckdns.org.
|
||||
// So strip off everything that is not top 3 levels.
|
||||
func getMainDomain(domain string) string {
|
||||
domain = dnsnew.UnFqdn(domain)
|
||||
domain = dns01.UnFqdn(domain)
|
||||
|
||||
split := dns.Split(domain)
|
||||
if strings.HasSuffix(strings.ToLower(domain), "duckdns.org") {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge"
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dyn/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -45,9 +45,9 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dnsnew.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 10*time.Second),
|
||||
},
|
||||
|
|
@ -102,9 +102,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dyn: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
@ -131,9 +131,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
|||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dyn: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v5/challenge/dnsnew"
|
||||
"github.com/go-acme/lego/v5/challenge/dns01"
|
||||
"github.com/go-acme/lego/v5/platform/config/env"
|
||||
"github.com/go-acme/lego/v5/providers/dns/dyndnsfree/internal"
|
||||
"github.com/go-acme/lego/v5/providers/dns/internal/clientdebug"
|
||||
|
|
@ -39,8 +39,8 @@ type Config struct {
|
|||
// NewDefaultConfig returns a default configuration for the DNSProvider.
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dnsnew.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dnsnew.DefaultPollingInterval),
|
||||
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
|
||||
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
|
||||
},
|
||||
|
|
@ -94,14 +94,14 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
info := dnsnew.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
info := dns01.GetChallengeInfo(ctx, domain, keyAuth)
|
||||
|
||||
authZone, err := dnsnew.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
authZone, err := dns01.DefaultClient().FindZoneByFqdn(ctx, info.EffectiveFQDN)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dyndnsforfree: could not find zone for domain %q: %w", domain, err)
|
||||
}
|
||||
|
||||
err = d.client.AddTXTRecord(ctx, dnsnew.UnFqdn(authZone), dnsnew.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
err = d.client.AddTXTRecord(ctx, dns01.UnFqdn(authZone), dns01.UnFqdn(info.EffectiveFQDN), info.Value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("dyndnsfree: add record: %w", err)
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue