mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 19:50:18 +00:00
优化compare逻辑, 如果不为fuzzy statuscode, 则使用base
优化offset与limit的逻辑与显示
This commit is contained in:
parent
9f6199c243
commit
f8f2fe839c
@ -55,7 +55,7 @@ type RequestOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MiscOptions 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)"`
|
Timeout int `long:"timeout" default:"2" description:"Int, timeout with request (seconds)"`
|
||||||
PoolSize int `short:"p" long:"pool" default:"5" description:"Int, Pool size"`
|
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)"`
|
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 {
|
if r.Limit == 0 {
|
||||||
r.Limit = len(r.Wordlist)
|
r.Limit = len(r.Wordlist)
|
||||||
|
} else {
|
||||||
|
r.Limit = r.Offset + opt.Limit
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.Uppercase {
|
if opt.Uppercase {
|
||||||
|
@ -212,7 +212,6 @@ func (p *Pool) Init() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) Run(ctx context.Context, offset, limit int) {
|
func (p *Pool) Run(ctx context.Context, offset, limit int) {
|
||||||
maxreq := offset + limit
|
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -226,7 +225,7 @@ Loop:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.reqCount > maxreq {
|
if p.reqCount > limit {
|
||||||
break Loop
|
break Loop
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,12 +276,14 @@ func (p *Pool) BaseCompare(bl *pkg.Baseline) {
|
|||||||
}
|
}
|
||||||
var status int
|
var status int
|
||||||
base, ok := p.baselines[bl.Status]
|
base, ok := p.baselines[bl.Status]
|
||||||
if ok {
|
if !ok {
|
||||||
// 挑选对应状态码的baseline进行compare
|
base = p.base
|
||||||
if status = base.Compare(bl); status == 1 {
|
}
|
||||||
p.PutToInvalid(bl, "compare failed")
|
|
||||||
return
|
// 挑选对应状态码的baseline进行compare
|
||||||
}
|
if status = base.Compare(bl); status == 1 {
|
||||||
|
p.PutToInvalid(bl, "compare failed")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
bl.Collect()
|
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.PutToInvalid(bl, "fuzzy compare failed")
|
||||||
p.PutToFuzzy(bl)
|
p.PutToFuzzy(bl)
|
||||||
return
|
return
|
||||||
|
@ -74,7 +74,7 @@ func (r *Runner) Prepare(ctx context.Context) error {
|
|||||||
logs.Log.Error(err.Error())
|
logs.Log.Error(err.Error())
|
||||||
return
|
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()
|
err = pool.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Log.Error(err.Error())
|
logs.Log.Error(err.Error())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user