From fbf5ef2b0b59263e5f6aae8b64841973e7419b52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 17 Jun 2023 19:54:58 +0530 Subject: [PATCH] chore(deps): bump github.com/projectdiscovery/clistats from 0.0.12 to 0.0.18 (#1190) * chore(deps): bump github.com/projectdiscovery/clistats Bumps [github.com/projectdiscovery/clistats](https://github.com/projectdiscovery/clistats) from 0.0.12 to 0.0.18. - [Release notes](https://github.com/projectdiscovery/clistats/releases) - [Commits](https://github.com/projectdiscovery/clistats/compare/v0.0.12...v0.0.18) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/clistats dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * fix showing stats on clistat update --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ramana Reddy --- go.mod | 4 ++-- go.sum | 8 ++++---- runner/runner.go | 20 ++++++++++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 6f6ac9f..bc2e506 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/miekg/dns v1.1.54 // indirect github.com/pkg/errors v0.9.1 github.com/projectdiscovery/cdncheck v1.0.9 - github.com/projectdiscovery/clistats v0.0.12 + github.com/projectdiscovery/clistats v0.0.18 github.com/projectdiscovery/fdmax v0.0.4 github.com/projectdiscovery/goconfig v0.0.1 github.com/projectdiscovery/goflags v0.1.9 @@ -102,7 +102,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/projectdiscovery/blackrock v0.0.1 // indirect - github.com/projectdiscovery/freeport v0.0.4 // indirect + github.com/projectdiscovery/freeport v0.0.5 // indirect github.com/projectdiscovery/networkpolicy v0.0.6 // indirect github.com/projectdiscovery/retryabledns v1.0.29 // indirect github.com/refraction-networking/utls v1.3.2 // indirect diff --git a/go.sum b/go.sum index 655c838..a70d290 100644 --- a/go.sum +++ b/go.sum @@ -185,16 +185,16 @@ github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= github.com/projectdiscovery/cdncheck v1.0.9 h1:BS15gzj9gb5AVSKqTDzPamfSgStu7nJQOocUvrssFlg= github.com/projectdiscovery/cdncheck v1.0.9/go.mod h1:18SSl1w7rMj53CGeRIZTbDoa286a6xZIxGbaiEo4Fxs= -github.com/projectdiscovery/clistats v0.0.12 h1:KLYJxpiwEFidduU4PbcwEcCQ2L7c5wrf7DI5IN5fZ+8= -github.com/projectdiscovery/clistats v0.0.12/go.mod h1:9luKJj+7Hjq3+a7g129sKWRYx4SbTdkUWZQxabn3H5Y= +github.com/projectdiscovery/clistats v0.0.18 h1:WLQNqLXsKvjoieDwXJO/1jlnxR0x9vdFaRUAR3gXfKQ= +github.com/projectdiscovery/clistats v0.0.18/go.mod h1:YUnUrMHFw+FHwUTIKr1KDUwz81x+SFjPU3xfLqXfzf0= github.com/projectdiscovery/dsl v0.0.9 h1:VfznBxpbNKMn2amQd9gtRnMfK1/Sf9MwsJD9x2Et/fY= github.com/projectdiscovery/dsl v0.0.9/go.mod h1:kdPdbbqceWxkSedXm99z0Hzh9z/DFj42A9L95GJjybo= github.com/projectdiscovery/fastdialer v0.0.29 h1:uDy2/bXHl8ISkuRp0EpmajkfWHewL3q5oDcYxB07ME8= github.com/projectdiscovery/fastdialer v0.0.29/go.mod h1:CBzmr7QS+Ml66h1jjuudR8Uzl6bt2YeqYmTg0IedWsI= github.com/projectdiscovery/fdmax v0.0.4 h1:K9tIl5MUZrEMzjvwn/G4drsHms2aufTn1xUdeVcmhmc= github.com/projectdiscovery/fdmax v0.0.4/go.mod h1:oZLqbhMuJ5FmcoaalOm31B1P4Vka/CqP50nWjgtSz+I= -github.com/projectdiscovery/freeport v0.0.4 h1:H4VrK/7hUcC1zbg46zv9iSMBACBDpUqcHkV+FUyXISw= -github.com/projectdiscovery/freeport v0.0.4/go.mod h1:PY0bxSJ34HVy67LHIeF3uIutiCSDwOqKD8ruBkdiCwE= +github.com/projectdiscovery/freeport v0.0.5 h1:jnd3Oqsl4S8n0KuFkE5Hm8WGDP24ITBvmyw5pFTHS8Q= +github.com/projectdiscovery/freeport v0.0.5/go.mod h1:PY0bxSJ34HVy67LHIeF3uIutiCSDwOqKD8ruBkdiCwE= github.com/projectdiscovery/goconfig v0.0.1 h1:36m3QjohZvemqh9bkJAakaHsm9iEZ2AcQSS18+0QX/s= github.com/projectdiscovery/goconfig v0.0.1/go.mod h1:CPO25zR+mzTtyBrsygqsHse0sp/4vB/PjaHi9upXlDw= github.com/projectdiscovery/goflags v0.1.9 h1:rLtdt7YNEIwsioT1HO48j01bZrqUTj45CiXPgNflTBk= diff --git a/runner/runner.go b/runner/runner.go index 043b329..eb342ec 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -374,11 +374,18 @@ func (r *Runner) prepareInput() { r.stats.AddCounter("hosts", 0) r.stats.AddStatic("startedAt", time.Now()) r.stats.AddCounter("requests", 0) - - err := r.stats.Start(makePrintCallback(), time.Duration(r.options.StatsInterval)*time.Second) + r.stats.AddDynamic("summary", makePrintCallback()) + err := r.stats.Start() if err != nil { gologger.Warning().Msgf("Could not create statistics: %s\n", err) } + + r.stats.GetStatResponse(time.Duration(r.options.StatsInterval)*time.Second, func(s string, err error) error { + if err != nil && r.options.Verbose { + gologger.Error().Msgf("Could not read statistics: %s\n", err) + } + return nil + }) } } @@ -497,9 +504,9 @@ var ( lastRequestsCount float64 ) -func makePrintCallback() func(stats clistats.StatisticsClient) { +func makePrintCallback() func(stats clistats.StatisticsClient) interface{} { builder := &strings.Builder{} - return func(stats clistats.StatisticsClient) { + return func(stats clistats.StatisticsClient) interface{} { startedAt, _ := stats.GetStatic("startedAt") duration := time.Since(startedAt.(time.Time)) @@ -534,11 +541,12 @@ func makePrintCallback() func(stats clistats.StatisticsClient) { builder.WriteRune(')') builder.WriteRune('\n') - - fmt.Fprintf(os.Stderr, "%s", builder.String()) + statString := builder.String() + fmt.Fprintf(os.Stderr, "%s", statString) builder.Reset() lastRequestsCount = currentRequests + return statString } }