-
I had a related problem when I used a timeout of 15 seconds but it took me about 1 minute to get the return error. Below is my code package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"time"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/gologger/levels"
"github.com/rs/zerolog/log"
"github.com/projectdiscovery/httpx/runner"
)
func main() {
gologger.DefaultLogger.SetMaxLevel(levels.LevelFatal)
targets := []string{
"123123.com",
"example.com",
}
start := time.Now()
go func() {
addr := fmt.Sprintf(":%d", 6060)
log.Info().Msgf("Starting pprof http://localhost%s", addr)
http.ListenAndServe(addr, nil)
}()
options := runner.Options{
Methods: http.MethodGet,
InputTargetHost: targets,
RandomAgent: true,
OutputResponseTime: true,
Threads: 50,
Timeout: 15,
Retries: 3,
StatusCode: true,
TLSGrab: true,
NoDecode: true,
Probe: true,
RateLimit: 200,
// Redirects
FollowRedirects: true,
MaxRedirects: 10,
OnResult: func(r runner.Result) {
l := log.Info().
Str("url", r.Input)
defer l.Msg("Ping url")
if r.FinalURL != "" {
l.Str("finalURL", r.FinalURL)
}
if r.Error != "" {
l.Str("err", r.Error)
} else if r.Err != nil {
l.Str("err", r.Err.Error())
}
if r.TLSData != nil {
if !r.TLSData.NotAfter.IsZero() {
l.Str("tlsNotAfter", r.TLSData.NotAfter.Format(time.RFC3339))
}
}
l.Str("scheme", r.Scheme).
Int("statusCode", r.StatusCode).
Str("responseTime", r.ResponseTime)
if r.StatusCode > 199 && r.StatusCode < 300 {
l.Str("status", "UP")
} else {
l.Str("status", "DOWN")
}
},
}
if err := options.ValidateOptions(); err != nil {
log.Fatal().Err(err).Send()
}
httpxRunner, err := runner.New(&options)
if err != nil {
log.Fatal().Err(err).Send()
}
defer httpxRunner.Close()
httpxRunner.RunEnumeration()
elapsed := time.Since(start)
log.Info().
Msgf("Done %s", elapsed.String())
} And this is the result i got
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The framework will retry once(see runner/runner.go:1252), and you set |
Beta Was this translation helpful? Give feedback.
-
The total time is given by the slowest thread with retries ( |
Beta Was this translation helpful? Give feedback.
The total time is given by the slowest thread with retries (
total time = retries x timeout
), as correctly explained by @aschoolboy