接入DNS在线测试传播参数

This commit is contained in:
xuans committed 2026-08-31 03:01:32 +08:00
1 parent e982f54607
commit 8c1471e8fe
7 files changed
+175 -20

No files matched your search

+19 -3
View File
@@ -456,13 +456,29 @@ func prepareDNSCredentials(ctx context.Context, cfg config.Config, input *setup.
return func() {}, fmt.Errorf("初始化 DNS 凭据存储失败:%w", err)
}
manager := setup.NewDNSVerificationManager(
dnsprovider.NewTester(dnsprovider.NewLegoFactory()),
dnsprovider.NewTesterWithSettings(
dnsprovider.NewLegoFactory(),
time.Duration(cfg.ACME.PropagationTimeoutSecs)*time.Second,
time.Duration(cfg.ACME.PropagationPollingIntervalSecs)*time.Second,
),
store,
)
return prepareDNSCredentialsWithManager(ctx, input, output, manager, store)
return prepareDNSCredentialsWithManagerAndTimeout(ctx, input, output, manager, store, dnsVerificationTimeout(cfg))
}
func dnsVerificationTimeout(cfg config.Config) time.Duration {
timeout := time.Duration(cfg.ACME.PropagationTimeoutSecs)*time.Second + 30*time.Second
if timeout <= 30*time.Second {
return 45 * time.Second
}
return timeout
}
func prepareDNSCredentialsWithManager(ctx context.Context, input *setup.Input, output io.Writer, manager *setup.DNSVerificationManager, store *secretstore.Store) (func(), error) {
return prepareDNSCredentialsWithManagerAndTimeout(ctx, input, output, manager, store, 45*time.Second)
}
func prepareDNSCredentialsWithManagerAndTimeout(ctx context.Context, input *setup.Input, output io.Writer, manager *setup.DNSVerificationManager, store *secretstore.Store, timeout time.Duration) (func(), error) {
if input == nil {
return func() {}, errors.New("初始化输入不能为空")
}
@@ -478,7 +494,7 @@ func prepareDNSCredentialsWithManager(ctx context.Context, input *setup.Input, o
if strings.TrimSpace(input.DNSTestDomain) == "" {
return func() {}, errors.New("DNS 权限测试域名不能为空")
}
testContext, cancel := context.WithTimeout(ctx, 45*time.Second)
testContext, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
result, err := manager.Verify(testContext, setup.DNSVerificationInput{
ProviderID: input.DNSProvider,