From 2abd058f83d57c2437812f9562c32edc711fe75d Mon Sep 17 00:00:00 2001 From: Ice3man Date: Sat, 15 Jan 2022 06:13:25 +0530 Subject: [PATCH 1/2] Added stats-interval for changing stats display frequency --- runner/options.go | 2 ++ runner/runner.go | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/runner/options.go b/runner/options.go index 43cbeb2f..2a29cee5 100644 --- a/runner/options.go +++ b/runner/options.go @@ -191,6 +191,7 @@ type Options struct { TLSGrab bool protocol string ShowStatistics bool + StatsInterval int RandomAgent bool StoreChain bool Deny customlist.CustomList @@ -337,6 +338,7 @@ func ParseOptions() *Options { flagSet.BoolVar(&options.DebugRequests, "debug-req", false, "Show all sent requests"), flagSet.BoolVar(&options.DebugResponse, "debug-resp", false, "Show all received responses"), flagSet.BoolVar(&options.ShowStatistics, "stats", false, "Display scan statistic"), + flagSet.IntVarP(&options.StatsInterval, "stats-interval", "si", 5, "number of seconds to wait between showing a statistics update"), ) createGroup(flagSet, "Optimizations", "Optimizations", diff --git a/runner/runner.go b/runner/runner.go index a399e0cd..4d7f583a 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -54,10 +54,6 @@ import ( "go.uber.org/ratelimit" ) -const ( - statsDisplayInterval = 5 -) - // Runner is a client for running the enumeration process. type Runner struct { options *Options @@ -320,7 +316,7 @@ 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(statsDisplayInterval)*time.Second) + err := r.stats.Start(makePrintCallback(), time.Duration(r.options.StatsInterval)*time.Second) if err != nil { gologger.Warning().Msgf("Could not create statistics: %s\n", err) } From 9b9a95a2107f7f082166f4ae60dcba10b4026e36 Mon Sep 17 00:00:00 2001 From: Ice3man Date: Sun, 16 Jan 2022 17:34:17 +0530 Subject: [PATCH 2/2] Enable show-statistics if an interval is passed for stats --- runner/options.go | 7 ++++++- runner/runner.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/runner/options.go b/runner/options.go index 2a29cee5..3fda78a2 100644 --- a/runner/options.go +++ b/runner/options.go @@ -338,7 +338,7 @@ func ParseOptions() *Options { flagSet.BoolVar(&options.DebugRequests, "debug-req", false, "Show all sent requests"), flagSet.BoolVar(&options.DebugResponse, "debug-resp", false, "Show all received responses"), flagSet.BoolVar(&options.ShowStatistics, "stats", false, "Display scan statistic"), - flagSet.IntVarP(&options.StatsInterval, "stats-interval", "si", 5, "number of seconds to wait between showing a statistics update"), + flagSet.IntVarP(&options.StatsInterval, "stats-interval", "si", 0, "number of seconds to wait between showing a statistics update (default: 5)"), ) createGroup(flagSet, "Optimizations", "Optimizations", @@ -353,6 +353,11 @@ func ParseOptions() *Options { ) _ = flagSet.Parse() + + if options.StatsInterval != 0 { + options.ShowStatistics = true + } + // Read the inputs and configure the logging options.configureOutput() diff --git a/runner/runner.go b/runner/runner.go index 4d7f583a..034c6559 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -235,6 +235,9 @@ func New(options *Options) (*Runner, error) { if err != nil { return nil, err } + if options.StatsInterval == 0 { + options.StatsInterval = 5 + } } hmapOptions := hybrid.DefaultDiskOptions @@ -316,6 +319,7 @@ 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) if err != nil { gologger.Warning().Msgf("Could not create statistics: %s\n", err)