mirror of
https://github.com/chainreactors/spray.git
synced 2026-10-28 19:40:49 +00:00
实装--crawl-depth
This commit is contained in:
1 parent
9600d6fe3e
commit
c6f41ef84b
3 files changed
+9
-8
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+6
-6
@@ -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:],
|
||||
|
||||
Reference in new issue
Block a user