diff --git a/cmd/cmd.go b/cmd/cmd.go index ff65a95..6df1c80 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -75,6 +75,7 @@ func Spray() { pkg.Distance = uint8(option.SimhashDistance) ihttp.DefaultMaxBodySize = option.MaxBodyLength * 1024 + internal.MaxCrawl = option.CrawlDepth if option.ReadAll { ihttp.DefaultMaxBodySize = 0 } diff --git a/internal/option.go b/internal/option.go index 8f5219b..c9a7573 100644 --- a/internal/option.go +++ b/internal/option.go @@ -414,7 +414,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) { } if opt.Recursive != "current.IsDir()" { - maxRecursion = 1 + MaxRecursion = 1 exp, err := expr.Compile(opt.Recursive) if err != nil { return nil, err @@ -422,7 +422,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) { r.RecursiveExpr = exp } if opt.Depth != 0 { - maxRecursion = opt.Depth + MaxRecursion = opt.Depth } // prepare header diff --git a/internal/pool.go b/internal/pool.go index 2953a96..c06a966 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -24,9 +24,9 @@ import ( var ( max = 2147483647 - maxRedirect = 3 - maxCrawl = 3 - maxRecursion = 0 + MaxRedirect = 3 + MaxCrawl = 3 + MaxRecursion = 0 nilBaseline = &pkg.Baseline{} ) @@ -107,7 +107,7 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) { pool.wg.Add(2) pool.doCrawl(bl) pool.doRule(bl) - if bl.RecuDepth < maxRecursion { + if bl.RecuDepth < MaxRecursion { if CompareWithExpr(pool.RecuExpr, params) { bl.Recu = true } @@ -473,7 +473,7 @@ func CompareWithExpr(exp *vm.Program, params map[string]interface{}) bool { func (pool *Pool) doRedirect(bl *pkg.Baseline, depth int) { defer pool.wg.Done() - if depth >= maxRedirect { + if depth >= MaxRedirect { return } @@ -546,7 +546,7 @@ func (pool *Pool) doCrawl(bl *pkg.Baseline) { } else { // 通过map去重, 只有新的url才会进入到该逻辑 pool.urls[u] = 1 - if bl.ReqDepth < maxCrawl { + if bl.ReqDepth < MaxCrawl { pool.wg.Add(1) pool.addAddition(&Unit{ path: u[1:],