(v interface{})
| 146 | } |
| 147 | |
| 148 | func (pool *CheckPool) Invoke(v interface{}) { |
| 149 | defer func() { |
| 150 | pool.reqCount.Add(1) |
| 151 | pool.wg.Done() |
| 152 | }() |
| 153 | |
| 154 | unit := v.(*Unit) |
| 155 | |
| 156 | // 为Check请求创建RequestConfig,使用配置的参数 |
| 157 | checkReqConfig := &ihttp.RequestConfig{ |
| 158 | Method: pool.Request.Method, // 使用配置的 Method |
| 159 | Headers: pool.Request.Headers, |
| 160 | Host: pool.Request.Host, // 使用配置的 Host |
| 161 | Path: pool.Request.Path, // 使用配置的 Path |
| 162 | Body: pool.Request.Body, // 使用配置的 Body |
| 163 | RandomUserAgent: pool.Request.RandomUserAgent, |
| 164 | } |
| 165 | |
| 166 | req, err := checkReqConfig.Build(pool.ctx, pool.ClientType, unit.path, "", "", "") |
| 167 | if err != nil { |
| 168 | logs.Log.Debug(err.Error()) |
| 169 | bl := &baseline.Baseline{ |
| 170 | SprayResult: &parsers.SprayResult{ |
| 171 | UrlString: unit.path, |
| 172 | IsValid: false, |
| 173 | ErrString: err.Error(), |
| 174 | Reason: pkg.ErrUrlError.Error(), |
| 175 | ReqDepth: unit.depth, |
| 176 | }, |
| 177 | } |
| 178 | pool.sendProcess(bl) |
| 179 | return |
| 180 | } |
| 181 | start := time.Now() |
| 182 | var bl *baseline.Baseline |
| 183 | resp, reqerr := pool.client.Do(req) |
| 184 | if reqerr != nil { |
| 185 | pool.failedCount.Add(1) |
| 186 | bl = &baseline.Baseline{ |
| 187 | SprayResult: &parsers.SprayResult{ |
| 188 | UrlString: unit.path, |
| 189 | IsValid: false, |
| 190 | ErrString: reqerr.Error(), |
| 191 | Reason: pkg.ErrRequestFailed.Error(), |
| 192 | ReqDepth: unit.depth, |
| 193 | }, |
| 194 | } |
| 195 | logs.Log.Debugf("%s, %s", unit.path, reqerr.Error()) |
| 196 | pool.doUpgrade(bl) |
| 197 | } else { |
| 198 | bl = baseline.NewBaseline(req.URI(), req.Host(), resp) |
| 199 | bl.ReqDepth = unit.depth |
| 200 | bl.Collect() |
| 201 | if bl.Status == 400 { |
| 202 | pool.doUpgrade(bl) |
| 203 | } |
| 204 | } |
| 205 | bl.ReqDepth = unit.depth |
no test coverage detected