mirror of
https://github.com/chainreactors/spray.git
synced 2025-06-22 02:40:41 +00:00
clean fallback print and fix multi print
This commit is contained in:
parent
ed3e95f21d
commit
24eade89d0
@ -701,10 +701,10 @@ func (pool *BrutePool) addFuzzyBaseline(bl *pkg.Baseline) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pool *BrutePool) recover() {
|
func (pool *BrutePool) fallback() {
|
||||||
logs.Log.Errorf("%s ,failed request exceeds the threshold , task will exit. Breakpoint %d", pool.BaseURL, pool.wordOffset)
|
logs.Log.Errorf("%s ,failed request exceeds the threshold , task will exit. Breakpoint %d", pool.BaseURL, pool.wordOffset)
|
||||||
for i, bl := range pool.FailedBaselines {
|
for i, bl := range pool.FailedBaselines {
|
||||||
if i > int(pool.BreakThreshold) {
|
if i > 5 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logs.Log.Errorf("[failed.%d] %s", i, bl.String())
|
logs.Log.Errorf("[failed.%d] %s", i, bl.String())
|
||||||
@ -717,7 +717,7 @@ func (pool *BrutePool) Close() {
|
|||||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||||
}
|
}
|
||||||
close(pool.additionCh) // 关闭addition管道
|
close(pool.additionCh) // 关闭addition管道
|
||||||
close(pool.checkCh) // 关闭check管道
|
//close(pool.checkCh) // 关闭check管道
|
||||||
pool.Statistor.EndTime = time.Now().Unix()
|
pool.Statistor.EndTime = time.Now().Unix()
|
||||||
pool.reqPool.Release()
|
pool.reqPool.Release()
|
||||||
pool.scopePool.Release()
|
pool.scopePool.Release()
|
||||||
@ -740,7 +740,11 @@ func (pool *BrutePool) resetFailed() {
|
|||||||
func (pool *BrutePool) doCheck() {
|
func (pool *BrutePool) doCheck() {
|
||||||
if pool.failedCount > pool.BreakThreshold {
|
if pool.failedCount > pool.BreakThreshold {
|
||||||
// 当报错次数超过上限是, 结束任务
|
// 当报错次数超过上限是, 结束任务
|
||||||
pool.recover()
|
if pool.isFallback.Load() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pool.isFallback.Store(true)
|
||||||
|
pool.fallback()
|
||||||
pool.Cancel()
|
pool.Cancel()
|
||||||
pool.IsFailed = true
|
pool.IsFailed = true
|
||||||
return
|
return
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/chainreactors/spray/pkg"
|
"github.com/chainreactors/spray/pkg"
|
||||||
"github.com/chainreactors/words"
|
"github.com/chainreactors/words"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BasePool struct {
|
type BasePool struct {
|
||||||
@ -24,6 +25,7 @@ type BasePool struct {
|
|||||||
additionCh chan *Unit
|
additionCh chan *Unit
|
||||||
closeCh chan struct{}
|
closeCh chan struct{}
|
||||||
wg *sync.WaitGroup
|
wg *sync.WaitGroup
|
||||||
|
isFallback atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pool *BasePool) doRedirect(bl *pkg.Baseline, depth int) {
|
func (pool *BasePool) doRedirect(bl *pkg.Baseline, depth int) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user