Skip to content

Commit

Permalink
Option to override recursive nameservers for propagation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
janeczku committed May 13, 2017
1 parent b7293e3 commit 0d83373
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (c *Context) InitContext() {
certNameParam := getEnvOption("CERT_NAME", true)
timeParam := getEnvOption("RENEWAL_TIME", true)
providerParam := getEnvOption("PROVIDER", true)
resolversParam := getEnvOption("DNS_RESOLVERS", false)

if eulaParam != "Yes" {
logrus.Fatalf("Terms of service were not accepted")
Expand All @@ -58,6 +59,16 @@ func (c *Context) InitContext() {
logrus.Fatalf("Invalid value for DOMAINS: %s", domainParam)
}

dnsResolvers := []string{}
if len(resolversParam) > 0 {
for _, resolver := range listToSlice(resolversParam) {
if !strings.Contains(resolver, ":") {
resolver += ":53"
}
dnsResolvers = append(dnsResolvers, resolver)
}
}

c.CertificateName = certNameParam
c.RenewalTime, err = strconv.Atoi(timeParam)
if err != nil || c.RenewalTime < 0 || c.RenewalTime > 23 {
Expand Down Expand Up @@ -100,7 +111,7 @@ func (c *Context) InitContext() {
NS1ApiKey: getEnvOption("NS1_API_KEY", false),
}

c.Acme, err = letsencrypt.NewClient(emailParam, keyType, apiVersion, providerOpts)
c.Acme, err = letsencrypt.NewClient(emailParam, keyType, apiVersion, dnsResolvers, providerOpts)
if err != nil {
logrus.Fatalf("LetsEncrypt client: %v", err)
}
Expand Down
6 changes: 5 additions & 1 deletion letsencrypt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Client struct {
}

// NewClient returns a new Lets Encrypt client
func NewClient(email string, kt KeyType, apiVer ApiVersion, provider ProviderOpts) (*Client, error) {
func NewClient(email string, kt KeyType, apiVer ApiVersion, dnsResolvers []string, provider ProviderOpts) (*Client, error) {
var keyType lego.KeyType
switch kt {
case RSA2048:
Expand Down Expand Up @@ -138,6 +138,10 @@ func NewClient(email string, kt KeyType, apiVer ApiVersion, provider ProviderOpt
client.ExcludeChallenges([]lego.Challenge{lego.TLSSNI01, lego.DNS01})
}

if len(dnsResolvers) > 0 {
lego.RecursiveNameservers = dnsResolvers
}

return &Client{
client: client,
apiVersion: apiVer,
Expand Down

0 comments on commit 0d83373

Please sign in to comment.