From 9d954fcc413264c1f160e655a771f0031f42a219 Mon Sep 17 00:00:00 2001 From: Ian Bishop Date: Fri, 19 Aug 2016 19:27:26 +1000 Subject: [PATCH] Allow custom DNS resolvers --- cli.go | 4 ++++ cli_handlers.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/cli.go b/cli.go index 650bcc3b..abc279bd 100644 --- a/cli.go +++ b/cli.go @@ -158,6 +158,10 @@ func main() { Name: "dns-timeout", Usage: "Set the DNS timeout value to a specific value in seconds. The default is 10 seconds.", }, + cli.StringSliceFlag{ + Name: "dns-resolvers", + Usage: "Set the resolvers to use for performing recursive DNS queries. Supported: host:port. The default is to use Google's DNS resolvers.", + }, cli.BoolFlag{ Name: "pem", Usage: "Generate a .pem file by concatanating the .key and .crt files together.", diff --git a/cli_handlers.go b/cli_handlers.go index b94aaa31..137662da 100644 --- a/cli_handlers.go +++ b/cli_handlers.go @@ -47,6 +47,17 @@ func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) { acme.DNSTimeout = time.Duration(c.GlobalInt("dns-timeout")) * time.Second } + if len(c.GlobalStringSlice("dns-resolvers")) > 0 { + resolvers := []string{} + for _, resolver := range c.GlobalStringSlice("dns-resolvers") { + if !strings.Contains(resolver, ":") { + resolver += ":53" + } + resolvers = append(resolvers, resolver) + } + acme.RecursiveNameservers = resolvers + } + err := checkFolder(c.GlobalString("path")) if err != nil { logger().Fatalf("Could not check/create path: %s", err.Error())