实装-c参数, 可以自定义client

This commit is contained in:
M09Ic 2023-01-10 00:57:55 +08:00
parent 171786c51e
commit 033f3acdd7
3 changed files with 20 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/chainreactors/files"
"github.com/chainreactors/logs"
"github.com/chainreactors/spray/pkg"
"github.com/chainreactors/spray/pkg/ihttp"
"github.com/chainreactors/words/mask"
"github.com/chainreactors/words/rule"
"github.com/gosuri/uiprogress"
@ -163,6 +164,14 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
r.ErrPeriod = max
}
if opt.Client == "auto" {
r.ClientType = ihttp.Auto
} else if opt.Client == "fast" {
r.ClientType = ihttp.FAST
} else if opt.Client == "standard" {
r.ClientType = ihttp.STANDARD
}
if opt.Advance {
r.Crawl = true
r.Active = true

View File

@ -48,6 +48,7 @@ type Runner struct {
RecuDepth int
Threads int
PoolSize int
ClientType int
Pools *ants.PoolWithFunc
PoolName map[string]bool
Timeout int
@ -99,11 +100,15 @@ func (r *Runner) PrepareConfig() *pkg.Config {
Active: r.Active,
Bak: r.Bak,
Common: r.Common,
ClientType: r.ClientType,
}
if config.Mod == pkg.PathSpray {
config.ClientType = ihttp.FAST
} else if config.Mod == pkg.HostSpray {
config.ClientType = ihttp.STANDARD
if config.ClientType == 0 {
if config.Mod == pkg.PathSpray {
config.ClientType = ihttp.FAST
} else if config.Mod == pkg.HostSpray {
config.ClientType = ihttp.STANDARD
}
}
return config
}

View File

@ -14,7 +14,8 @@ var (
)
const (
FAST = iota
Auto = iota
FAST
STANDARD
)