From bdc793c75b7a1013d09eda4b2a3a369da4913be8 Mon Sep 17 00:00:00 2001 From: M09Ic Date: Fri, 24 Mar 2023 13:41:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D-m=20host=20=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E4=B8=8B=E5=AD=97=E5=85=B8=E4=B8=8Eredirect=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pool.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/internal/pool.go b/internal/pool.go index 7cb6986..1bcf6f3 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -199,8 +199,13 @@ Loop: } pool.waiter.Add(1) - //pool.urls[w] = struct{}{} - pool.reqPool.Invoke(newUnitWithNumber(pool.safePath(w), WordSource, pool.wordOffset)) // 原样的目录拼接, 输入了几个"/"就是几个, 适配java的目录解析 + if pool.Mod == pkg.HostSpray { + pool.reqPool.Invoke(newUnitWithNumber(w, WordSource, pool.wordOffset)) + } else { + // 原样的目录拼接, 输入了几个"/"就是几个, 适配/有语义的中间件 + pool.reqPool.Invoke(newUnitWithNumber(pool.safePath(w), WordSource, pool.wordOffset)) + } + case source := <-pool.checkCh: pool.Statistor.CheckNumber++ if pool.Mod == pkg.HostSpray { @@ -239,7 +244,15 @@ func (pool *Pool) Invoke(v interface{}) { atomic.AddInt32(&pool.Statistor.ReqTotal, 1) unit := v.(*Unit) - req, err := pool.genReq(unit.path) + + var req *ihttp.Request + var err error + if unit.source == WordSource { + req, err = pool.genReq(pool.Mod, unit.path) + } else { + req, err = pool.genReq(pkg.PathSpray, unit.path) + } + if err != nil { logs.Log.Error(err.Error()) return @@ -453,10 +466,10 @@ func (pool *Pool) checkRedirect(redirectURL string) bool { } } -func (pool *Pool) genReq(s string) (*ihttp.Request, error) { - if pool.Mod == pkg.HostSpray { +func (pool *Pool) genReq(mod pkg.SprayMod, s string) (*ihttp.Request, error) { + if mod == pkg.HostSpray { return ihttp.BuildHostRequest(pool.ClientType, pool.BaseURL, s) - } else if pool.Mod == pkg.PathSpray { + } else if mod == pkg.PathSpray { return ihttp.BuildPathRequest(pool.ClientType, pool.base, s) } return nil, fmt.Errorf("unknown mod")