feat: add recursive nameservers settings for dns challenge #372

This commit is contained in:
Jacky 2024-05-04 12:00:53 +08:00
parent d3e9d92750
commit 7be4a70824
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
22 changed files with 4517 additions and 3498 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/go-acme/lego/v4/challenge/http01"
"github.com/go-acme/lego/v4/lego"
legolog "github.com/go-acme/lego/v4/log"
@ -116,7 +117,15 @@ func IssueCert(payload *ConfigPayload, logChan chan string, errChan chan error)
if err != nil {
break
}
err = client.Challenge.SetDNS01Provider(provider)
challengeOptions := make([]dns01.ChallengeOption, 0)
if len(settings.ServerSettings.RecursiveNameservers) > 0 {
challengeOptions = append(challengeOptions,
dns01.AddRecursiveNameservers(settings.ServerSettings.RecursiveNameservers),
)
}
err = client.Challenge.SetDNS01Provider(provider, challengeOptions...)
} else {
errChan <- errors.Wrap(err, "environment configuration is empty")
return