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:
|
||||
// 异步进行性能消耗较大的深度对比
|
||||
pool.reqCount++
|
||||
pool.tempCh <- bl
|
||||
|
||||
if pool.reqCount%pool.checkPeriod == 0 {
|
||||
@ -187,8 +186,8 @@ func (p *Pool) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Pool) Run(ctx context.Context) {
|
||||
|
||||
func (p *Pool) Run(ctx context.Context, offset, limit int) {
|
||||
maxreq := offset + limit
|
||||
Loop:
|
||||
for {
|
||||
select {
|
||||
@ -196,12 +195,23 @@ Loop:
|
||||
if !ok {
|
||||
break Loop
|
||||
}
|
||||
|
||||
if p.reqCount < offset {
|
||||
p.reqCount++
|
||||
continue
|
||||
}
|
||||
|
||||
if p.reqCount > maxreq {
|
||||
break Loop
|
||||
}
|
||||
|
||||
for _, fn := range p.Fns {
|
||||
u = fn(u)
|
||||
}
|
||||
if u == "" {
|
||||
continue
|
||||
}
|
||||
p.reqCount++
|
||||
p.wg.Add(1)
|
||||
_ = p.pool.Invoke(newUnit(u, WordSource))
|
||||
case <-ctx.Done():
|
||||
|
@ -28,6 +28,8 @@ type Runner struct {
|
||||
Probes []string
|
||||
OutputCh chan *baseline
|
||||
Progress *uiprogress.Progress
|
||||
Offset int
|
||||
Limit int
|
||||
}
|
||||
|
||||
func (r *Runner) Prepare() error {
|
||||
@ -74,7 +76,7 @@ func (r *Runner) Prepare() error {
|
||||
return
|
||||
}
|
||||
// todo pool 总超时时间
|
||||
pool.Run(ctx)
|
||||
pool.Run(ctx, r.Offset, r.Limit)
|
||||
r.poolwg.Done()
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user