feat(cert): add registry-based DNS provider system with 21 libdns providers

Refs #37
This commit is contained in:
xboard
2026-04-20 03:01:21 +08:00
parent 07c37023ab
commit 68ca2d2716
31 changed files with 1575 additions and 48 deletions
+7 -7
View File
@@ -15,6 +15,7 @@ import (
"time"
"github.com/cedar2025/xboard-node/internal/cert"
"github.com/cedar2025/xboard-node/internal/cert/dnsproviders"
"github.com/cedar2025/xboard-node/internal/config"
"github.com/cedar2025/xboard-node/internal/controlplane"
"github.com/cedar2025/xboard-node/internal/kernel"
@@ -1219,15 +1220,14 @@ func validateRuntimeCertConfig(spec *model.NodeSpec) error {
if mode != "dns" {
return nil
}
provider := strings.ToLower(strings.TrimSpace(spec.CertConfig.DNSProvider))
switch provider {
case "cloudflare", "cf", "alidns", "aliyun":
return nil
case "":
provider := strings.TrimSpace(spec.CertConfig.DNSProvider)
if provider == "" {
return fmt.Errorf("dns cert mode requires cert_config.dns_provider")
default:
return fmt.Errorf("unsupported cert_config.dns_provider %q (supported: cloudflare, alidns)", spec.CertConfig.DNSProvider)
}
if _, ok := dnsproviders.Get(provider); !ok {
return fmt.Errorf("unsupported cert_config.dns_provider %q (supported: %s)", provider, strings.Join(dnsproviders.CanonicalNames(), ", "))
}
return nil
}
func validateRealityRequirements(spec *model.NodeSpec, _ string) error {
+2 -1
View File
@@ -3,6 +3,7 @@ package service
import (
"context"
"errors"
"strings"
"testing"
"github.com/cedar2025/xboard-node/internal/cert"
@@ -214,7 +215,7 @@ func TestValidateNodeRuntimeRejectsUnsupportedDNSProvider(t *testing.T) {
if err.Error() == "" {
t.Fatal("expected non-empty error")
}
if got := err.Error(); got != "unsupported cert_config.dns_provider \"3123123\" (supported: cloudflare, alidns)" {
if got := err.Error(); !strings.HasPrefix(got, `unsupported cert_config.dns_provider "3123123" (supported: `) {
t.Fatalf("unexpected error: %v", got)
}
}