feat: add ns1 applicant

This commit is contained in:
Fu Diwei
2025-01-15 14:24:51 +08:00
parent e264d71048
commit dd236b925d
17 changed files with 174 additions and 34 deletions

View File

@@ -0,0 +1,33 @@
package ns1
import (
"errors"
"time"
"github.com/go-acme/lego/v4/challenge"
"github.com/go-acme/lego/v4/providers/dns/ns1"
)
type NS1ApplicantConfig struct {
ApiKey string `json:"apiKey"`
PropagationTimeout int32 `json:"propagationTimeout,omitempty"`
}
func NewChallengeProvider(config *NS1ApplicantConfig) (challenge.Provider, error) {
if config == nil {
return nil, errors.New("config is nil")
}
providerConfig := ns1.NewDefaultConfig()
providerConfig.APIKey = config.ApiKey
if config.PropagationTimeout != 0 {
providerConfig.PropagationTimeout = time.Duration(config.PropagationTimeout) * time.Second
}
provider, err := ns1.NewDNSProviderConfig(providerConfig)
if err != nil {
return nil, err
}
return provider, nil
}