Skip to content

Commit

Permalink
feat: Implement custom dns servers
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Aug 17, 2022
1 parent bc604a6 commit 1759626
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions internal/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func (a AcmeServerDomains) String() string {
}

type AcmeConfig struct {
Email string `json:"email"`
AcmeUrl string `json:"acmeUrl"`
AcmeDnsProvider string `json:"acmeDnsProvider"`
Email string `json:"email"`
AcmeUrl string `json:"acmeUrl"`
AcmeDnsProvider string `json:"acmeDnsProvider"`
AcmeCustomDnsServers []string `json:"acmeCustomDnsServers,omitempty"`
}

func (conf AcmeConfig) Validate() error {
Expand All @@ -80,6 +81,9 @@ func (conf AcmeConfig) Print() {
log.Info().Msgf("AcmeEmail=%s", conf.Email)
log.Info().Msgf("AcmeUrl=%s", conf.AcmeUrl)
log.Info().Msgf("AcmeDnsProvider=%s", conf.AcmeDnsProvider)
if len(conf.AcmeCustomDnsServers) > 0 {
log.Info().Msgf("AcmeCustomDnsServers=%v", conf.AcmeCustomDnsServers)
}
}

func (conf AcmeVaultServerConfig) Validate() error {
Expand Down
8 changes: 7 additions & 1 deletion internal/server/acme/lego.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/go-acme/lego/v4/certificate"
"github.com/go-acme/lego/v4/challenge"
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/go-acme/lego/v4/lego"
"github.com/go-acme/lego/v4/registration"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -61,7 +62,12 @@ func NewGoLegoDealer(accountStorage certstorage.AccountStorage, acmeConfig confi
}
}

err = l.client.Challenge.SetDNS01Provider(dnsProvider)
var opts []dns01.ChallengeOption
if len(acmeConfig.AcmeCustomDnsServers) > 0 {
opts = append(opts, dns01.AddRecursiveNameservers(acmeConfig.AcmeCustomDnsServers))
}

err = l.client.Challenge.SetDNS01Provider(dnsProvider, opts...)
if err != nil {
return nil, fmt.Errorf("could not set dns challenge: %v", err)
}
Expand Down

0 comments on commit 1759626

Please sign in to comment.