From b119bc45fbd1cc71348003541aac9d3a7da63654 Mon Sep 17 00:00:00 2001 From: xenolf Date: Thu, 19 May 2016 18:52:44 +0200 Subject: [PATCH] Add "http-timeout" CLI flag. This allows for an override of the default HTTP timeout for library HTTP requests. Fixes #207. --- cli.go | 4 ++++ cli_handlers.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/cli.go b/cli.go index 997f974e1..438557fed 100644 --- a/cli.go +++ b/cli.go @@ -146,6 +146,10 @@ func main() { Name: "dns", Usage: "Solve a DNS challenge using the specified provider. Disables all other challenges. Run 'lego dnshelp' for help on usage.", }, + cli.IntFlag{ + Name: "http-timeout", + Usage: "Set the HTTP timeout value to a specific value in seconds. The default is 10 seconds.", + }, } err = app.Run(os.Args) diff --git a/cli_handlers.go b/cli_handlers.go index 5585bcfb8..6a2fe56ef 100644 --- a/cli_handlers.go +++ b/cli_handlers.go @@ -32,6 +32,11 @@ func checkFolder(path string) error { } func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) { + + if c.GlobalIsSet("http-timeout") { + acme.HTTPTimeout = time.Duration(c.GlobalInt("http-timeout")) * time.Second + } + err := checkFolder(c.GlobalString("path")) if err != nil { logger().Fatalf("Could not check/create path: %s", err.Error())