From 029a83faa844b026f4ac199b151df25e3bed1f81 Mon Sep 17 00:00:00 2001 From: M09Ic Date: Wed, 19 Oct 2022 16:38:23 +0800 Subject: [PATCH] misc update --- go.mod | 1 - internal/pool.go | 24 +++--------------------- internal/types.go | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index a1a7fd2..e00173c 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( require ( github.com/gosuri/uiprogress v0.0.1 github.com/jessevdk/go-flags v1.5.0 - github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/valyala/fasthttp v1.40.0 ) diff --git a/internal/pool.go b/internal/pool.go index 8cdcedb..ae70be6 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -59,10 +59,10 @@ func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) ( defer fasthttp.ReleaseResponse(resp) defer fasthttp.ReleaseRequest(req) if reqerr != nil && reqerr != fasthttp.ErrBodyTooLarge { - pool.errorCount++ + pool.failedCount++ bl = &baseline{UrlString: pool.BaseURL + unit.path, Err: reqerr} } else { - pool.errorCount = 0 + pool.failedCount = 0 if err = pool.PreCompare(resp); err == nil || unit.source == CheckSource { // 通过预对比跳过一些无用数据, 减少性能消耗 bl = NewBaseline(req.URI(), resp) @@ -96,7 +96,7 @@ func NewPool(ctx context.Context, config *pkg.Config, outputCh chan *baseline) ( go pool.check() } } - //todo connectivity check + pool.bar.Done() pool.wg.Done() }) @@ -118,7 +118,6 @@ type Pool struct { outputCh chan *baseline // 输出的chan, 全局统一 tempCh chan *baseline // 待处理的baseline reqCount int - errorCount int failedCount int checkPeriod int errPeriod int @@ -251,20 +250,3 @@ func (p *Pool) buildHostRequest(host string) (*fasthttp.Request, error) { req.SetHost(host) return req, nil } - -type sourceType int - -const ( - CheckSource sourceType = iota + 1 - WordSource - WafSource -) - -func newUnit(path string, source sourceType) *Unit { - return &Unit{path: path, source: source} -} - -type Unit struct { - path string - source sourceType -} diff --git a/internal/types.go b/internal/types.go index d0f5c60..40f58e8 100644 --- a/internal/types.go +++ b/internal/types.go @@ -20,3 +20,20 @@ func (e ErrorType) Error() string { return "unknown error" } } + +type sourceType int + +const ( + CheckSource sourceType = iota + 1 + WordSource + WafSource +) + +func newUnit(path string, source sourceType) *Unit { + return &Unit{path: path, source: source} +} + +type Unit struct { + path string + source sourceType +}