Skip to content

Commit

Permalink
fix --check-only panic
Browse files Browse the repository at this point in the history
  • Loading branch information
M09Ic committed Mar 7, 2024
1 parent 3da923b commit 006e1af
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
13 changes: 0 additions & 13 deletions internal/pool/brutepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,16 +764,3 @@ func (pool *BrutePool) resetFailed() {
pool.failedCount = 1
pool.FailedBaselines = nil
}

func NewBaselines() *Baselines {
return &Baselines{
baselines: map[int]*pkg.Baseline{},
}
}

type Baselines struct {
FailedBaselines []*pkg.Baseline
random *pkg.Baseline
index *pkg.Baseline
baselines map[int]*pkg.Baseline
}
14 changes: 9 additions & 5 deletions internal/pool/checkpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pool

import (
"context"
"errors"
"github.com/chainreactors/logs"
"github.com/chainreactors/parsers"
"github.com/chainreactors/spray/internal/ihttp"
Expand All @@ -19,9 +20,10 @@ func NewCheckPool(ctx context.Context, config *Config) (*CheckPool, error) {
pctx, cancel := context.WithCancel(ctx)
pool := &CheckPool{
&This{
Config: config,
ctx: pctx,
Cancel: cancel,
Config: config,
Statistor: pkg.NewStatistor(""),
ctx: pctx,
Cancel: cancel,
client: ihttp.NewClient(&ihttp.ClientConfig{
Thread: config.Thread,
Type: config.ClientType,
Expand Down Expand Up @@ -112,7 +114,7 @@ func (pool *CheckPool) Invoke(v interface{}) {
defer fasthttp.ReleaseRequest(req.FastRequest)
}

if reqerr != nil && reqerr != fasthttp.ErrBodyTooLarge {
if reqerr != nil && !errors.Is(reqerr, fasthttp.ErrBodyTooLarge) {
pool.failedCount++
bl = &pkg.Baseline{
SprayResult: &parsers.SprayResult{
Expand Down Expand Up @@ -156,9 +158,11 @@ func (pool *CheckPool) Invoke(v interface{}) {
}
}

if bl.Source == parsers.CheckSource {
pool.Bar.Done()
}
pool.reqCount++
pool.wg.Done()
pool.Bar.Done()
}

func (pool *CheckPool) doRedirect(bl *pkg.Baseline, depth int) {
Expand Down
18 changes: 17 additions & 1 deletion internal/pool/unit.go → internal/pool/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package pool

import "github.com/chainreactors/parsers"
import (
"github.com/chainreactors/parsers"
"github.com/chainreactors/spray/pkg"
)

func newUnit(path string, source parsers.SpraySource) *Unit {
return &Unit{path: path, source: source}
Expand All @@ -18,3 +21,16 @@ type Unit struct {
frontUrl string
depth int // redirect depth
}

func NewBaselines() *Baselines {
return &Baselines{
baselines: map[int]*pkg.Baseline{},
}
}

type Baselines struct {
FailedBaselines []*pkg.Baseline
random *pkg.Baseline
index *pkg.Baseline
baselines map[int]*pkg.Baseline
}

0 comments on commit 006e1af

Please sign in to comment.