Add -timeout flag for customizable HTTP Request timeouts (#31)
* Add -timeout flag to specify HTTP request timeouts
This commit is contained in:
parent
4d0977a7d8
commit
752002d56b
@ -137,6 +137,8 @@ The only dependency of ffuf is Go 1.11. No dependencies outside of Go standard l
|
|||||||
- master
|
- master
|
||||||
- New
|
- New
|
||||||
- New CLI flag: -ac to autocalibrate response size and word filters based on few preset URLs.
|
- 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
|
- Changed
|
||||||
|
|
||||||
|
|||||||
1
main.go
1
main.go
@ -78,6 +78,7 @@ func main() {
|
|||||||
flag.BoolVar(&conf.FollowRedirects, "r", false, "Follow redirects")
|
flag.BoolVar(&conf.FollowRedirects, "r", false, "Follow redirects")
|
||||||
flag.BoolVar(&conf.AutoCalibration, "ac", false, "Automatically calibrate filtering options")
|
flag.BoolVar(&conf.AutoCalibration, "ac", false, "Automatically calibrate filtering options")
|
||||||
flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.")
|
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.BoolVar(&opts.showVersion, "V", false, "Show version information.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if opts.showVersion {
|
if opts.showVersion {
|
||||||
|
|||||||
@ -34,6 +34,7 @@ type Config struct {
|
|||||||
StopOnAll bool
|
StopOnAll bool
|
||||||
FollowRedirects bool
|
FollowRedirects bool
|
||||||
AutoCalibration bool
|
AutoCalibration bool
|
||||||
|
Timeout int
|
||||||
Delay optRange
|
Delay optRange
|
||||||
Filters []FilterProvider
|
Filters []FilterProvider
|
||||||
Matchers []FilterProvider
|
Matchers []FilterProvider
|
||||||
@ -61,6 +62,7 @@ func NewConfig(ctx context.Context) Config {
|
|||||||
conf.Filters = make([]FilterProvider, 0)
|
conf.Filters = make([]FilterProvider, 0)
|
||||||
conf.Delay = optRange{0, 0, false, false}
|
conf.Delay = optRange{0, 0, false, false}
|
||||||
conf.Extensions = make([]string, 0)
|
conf.Extensions = make([]string, 0)
|
||||||
|
conf.Timeout = 10
|
||||||
conf.DirSearchCompat = false
|
conf.DirSearchCompat = false
|
||||||
return conf
|
return conf
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,10 +25,9 @@ type SimpleRunner struct {
|
|||||||
func NewSimpleRunner(conf *ffuf.Config) ffuf.RunnerProvider {
|
func NewSimpleRunner(conf *ffuf.Config) ffuf.RunnerProvider {
|
||||||
var simplerunner SimpleRunner
|
var simplerunner SimpleRunner
|
||||||
simplerunner.config = conf
|
simplerunner.config = conf
|
||||||
|
|
||||||
simplerunner.client = &http.Client{
|
simplerunner.client = &http.Client{
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse },
|
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{
|
Transport: &http.Transport{
|
||||||
Proxy: conf.ProxyURL,
|
Proxy: conf.ProxyURL,
|
||||||
MaxIdleConns: 1000,
|
MaxIdleConns: 1000,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user