Add -timeout flag for customizable HTTP Request timeouts (#31)

* Add -timeout flag to specify HTTP request timeouts
This commit is contained in:
Corben Leo 2019-04-27 02:29:05 -05:00 committed by Joona Hoikkala
parent 4d0977a7d8
commit 752002d56b
4 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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
}

View file

@ -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,