mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
实装--offset与--limit
This commit is contained in:
parent
c9e16aa36a
commit
217bf0ab0f
@ -116,7 +116,6 @@ func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) (
|
|||||||
|
|
||||||
case WordSource:
|
case WordSource:
|
||||||
// 异步进行性能消耗较大的深度对比
|
// 异步进行性能消耗较大的深度对比
|
||||||
pool.reqCount++
|
|
||||||
pool.tempCh <- bl
|
pool.tempCh <- bl
|
||||||
|
|
||||||
if pool.reqCount%pool.checkPeriod == 0 {
|
if pool.reqCount%pool.checkPeriod == 0 {
|
||||||
@ -187,8 +186,8 @@ func (p *Pool) Init() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) Run(ctx context.Context) {
|
func (p *Pool) Run(ctx context.Context, offset, limit int) {
|
||||||
|
maxreq := offset + limit
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -196,12 +195,23 @@ Loop:
|
|||||||
if !ok {
|
if !ok {
|
||||||
break Loop
|
break Loop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.reqCount < offset {
|
||||||
|
p.reqCount++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.reqCount > maxreq {
|
||||||
|
break Loop
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range p.Fns {
|
for _, fn := range p.Fns {
|
||||||
u = fn(u)
|
u = fn(u)
|
||||||
}
|
}
|
||||||
if u == "" {
|
if u == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
p.reqCount++
|
||||||
p.wg.Add(1)
|
p.wg.Add(1)
|
||||||
_ = p.pool.Invoke(newUnit(u, WordSource))
|
_ = p.pool.Invoke(newUnit(u, WordSource))
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
@ -28,6 +28,8 @@ type Runner struct {
|
|||||||
Probes []string
|
Probes []string
|
||||||
OutputCh chan *baseline
|
OutputCh chan *baseline
|
||||||
Progress *uiprogress.Progress
|
Progress *uiprogress.Progress
|
||||||
|
Offset int
|
||||||
|
Limit int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runner) Prepare() error {
|
func (r *Runner) Prepare() error {
|
||||||
@ -74,7 +76,7 @@ func (r *Runner) Prepare() error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// todo pool 总超时时间
|
// todo pool 总超时时间
|
||||||
pool.Run(ctx)
|
pool.Run(ctx, r.Offset, r.Limit)
|
||||||
r.poolwg.Done()
|
r.poolwg.Done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user