diff --git a/internal/option.go b/internal/option.go index a85d25d..2c54ed9 100644 --- a/internal/option.go +++ b/internal/option.go @@ -55,7 +55,7 @@ type RequestOptions struct { } type MiscOptions struct { - Deadline int `long:"deadline" default:"600" description:"Int, deadline (seconds)"` // todo 总的超时时间,适配云函数的deadline + Deadline int `long:"deadline" default:"99999" description:"Int, deadline (seconds)"` // todo 总的超时时间,适配云函数的deadline Timeout int `long:"timeout" default:"2" description:"Int, timeout with request (seconds)"` PoolSize int `short:"p" long:"pool" default:"5" description:"Int, Pool size"` Threads int `short:"t" long:"thread" default:"20" description:"Int, number of threads per pool (seconds)"` @@ -183,6 +183,8 @@ func (opt *Option) PrepareRunner() (*Runner, error) { } if r.Limit == 0 { r.Limit = len(r.Wordlist) + } else { + r.Limit = r.Offset + opt.Limit } if opt.Uppercase { diff --git a/internal/pool.go b/internal/pool.go index efc5b2a..6d51f3a 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -212,7 +212,6 @@ func (p *Pool) Init() error { } func (p *Pool) Run(ctx context.Context, offset, limit int) { - maxreq := offset + limit Loop: for { select { @@ -226,7 +225,7 @@ Loop: continue } - if p.reqCount > maxreq { + if p.reqCount > limit { break Loop } @@ -277,12 +276,14 @@ func (p *Pool) BaseCompare(bl *pkg.Baseline) { } var status int base, ok := p.baselines[bl.Status] - if ok { - // 挑选对应状态码的baseline进行compare - if status = base.Compare(bl); status == 1 { - p.PutToInvalid(bl, "compare failed") - return - } + if !ok { + base = p.base + } + + // 挑选对应状态码的baseline进行compare + if status = base.Compare(bl); status == 1 { + p.PutToInvalid(bl, "compare failed") + return } bl.Collect() @@ -293,7 +294,7 @@ func (p *Pool) BaseCompare(bl *pkg.Baseline) { } } - if status == 0 && ok && base.FuzzyCompare(bl) { + if status == 0 && base.FuzzyCompare(bl) { p.PutToInvalid(bl, "fuzzy compare failed") p.PutToFuzzy(bl) return diff --git a/internal/runner.go b/internal/runner.go index b17dc88..2dfb09a 100644 --- a/internal/runner.go +++ b/internal/runner.go @@ -74,7 +74,7 @@ func (r *Runner) Prepare(ctx context.Context) error { logs.Log.Error(err.Error()) return } - pool.bar = pkg.NewBar(u, len(r.Wordlist), r.Progress) + pool.bar = pkg.NewBar(u, r.Limit-r.Offset, r.Progress) err = pool.Init() if err != nil { logs.Log.Error(err.Error())