From 752002d56bed267fa9529cec7624cda8284fb608 Mon Sep 17 00:00:00 2001 From: Corben Leo Date: Sat, 27 Apr 2019 02:29:05 -0500 Subject: [PATCH] Add -timeout flag for customizable HTTP Request timeouts (#31) * Add -timeout flag to specify HTTP request timeouts --- README.md | 2 ++ main.go | 1 + pkg/ffuf/config.go | 2 ++ pkg/runner/simple.go | 3 +-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b3b475..deb0702 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,8 @@ The only dependency of ffuf is Go 1.11. No dependencies outside of Go standard l - master - New - New CLI flag: -ac to autocalibrate response size and word filters based on few preset URLs. + - New CLI flag: -timeout to specify custom timeouts for all HTTP requests. + - Changed diff --git a/main.go b/main.go index ee5cd6b..1fa6bc0 100644 --- a/main.go +++ b/main.go @@ -78,6 +78,7 @@ func main() { flag.BoolVar(&conf.FollowRedirects, "r", false, "Follow redirects") flag.BoolVar(&conf.AutoCalibration, "ac", false, "Automatically calibrate filtering options") flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.") + flag.IntVar(&conf.Timeout, "timeout", 10, "HTTP request timeout in seconds.") flag.BoolVar(&opts.showVersion, "V", false, "Show version information.") flag.Parse() if opts.showVersion { diff --git a/pkg/ffuf/config.go b/pkg/ffuf/config.go index 52bb123..def26e5 100644 --- a/pkg/ffuf/config.go +++ b/pkg/ffuf/config.go @@ -34,6 +34,7 @@ type Config struct { StopOnAll bool FollowRedirects bool AutoCalibration bool + Timeout int Delay optRange Filters []FilterProvider Matchers []FilterProvider @@ -61,6 +62,7 @@ func NewConfig(ctx context.Context) Config { conf.Filters = make([]FilterProvider, 0) conf.Delay = optRange{0, 0, false, false} conf.Extensions = make([]string, 0) + conf.Timeout = 10 conf.DirSearchCompat = false return conf } diff --git a/pkg/runner/simple.go b/pkg/runner/simple.go index 1c95dcb..8df8086 100644 --- a/pkg/runner/simple.go +++ b/pkg/runner/simple.go @@ -25,10 +25,9 @@ type SimpleRunner struct { func NewSimpleRunner(conf *ffuf.Config) ffuf.RunnerProvider { var simplerunner SimpleRunner simplerunner.config = conf - simplerunner.client = &http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, - Timeout: time.Duration(10 * time.Second), + Timeout: time.Duration(time.Duration(conf.Timeout) * time.Second), Transport: &http.Transport{ Proxy: conf.ProxyURL, MaxIdleConns: 1000,