From 033f3acdd7f6bdabbac8c429d2943abb27dfaa9e Mon Sep 17 00:00:00 2001 From: M09Ic Date: Tue, 10 Jan 2023 00:57:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=A3=85-c=E5=8F=82=E6=95=B0,=20?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/option.go | 9 +++++++++ internal/runner.go | 13 +++++++++---- pkg/ihttp/client.go | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/internal/option.go b/internal/option.go index 9be39f5..8f5219b 100644 --- a/internal/option.go +++ b/internal/option.go @@ -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 diff --git a/internal/runner.go b/internal/runner.go index e7b8406..2589644 100644 --- a/internal/runner.go +++ b/internal/runner.go @@ -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 } diff --git a/pkg/ihttp/client.go b/pkg/ihttp/client.go index 6ee6950..6b7c100 100644 --- a/pkg/ihttp/client.go +++ b/pkg/ihttp/client.go @@ -14,7 +14,8 @@ var ( ) const ( - FAST = iota + Auto = iota + FAST STANDARD )