From 12a8f863db1cfafb9f4b45d705518a662623f684 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 25 Mar 2023 17:58:45 +0100 Subject: Fix a few nits --- main.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 146a62e..6fcdd00 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ -// Package main provides onion-grab, a tool that visits a list of domains -// concurrently over HTTPS to see if they have Onion-Location configured. +// Package main provides onion-grab, a tool that visits a list of domains over +// HTTPS to see if they have Onion-Location configured. // // Install: // @@ -94,7 +94,7 @@ func main() { if opts.NextLine != 0 { warn += fmt.Sprintf(" (line %d relative to start)", nextLine-opts.NextLine) } - log.Printf("WARNING: %s\n", warn) + log.Printf("NOTICE: %s\n", warn) } } @@ -217,18 +217,19 @@ func workGenerator(ctx context.Context, opts options.Options, fp *os.File, quest scanner.Buffer(buf, opts.MaxFileBuffer*1024*1024) nextLine := int64(0) - for scanner.Scan() { - select { - case <-ctx.Done(): - return nextLine, false - default: - } + if opts.NextLine > nextLine { + for scanner.Scan() { + select { + case <-ctx.Done(): + return nextLine, false + default: + } - if nextLine == opts.NextLine { - break + if nextLine+1 == opts.NextLine { + break + } + nextLine++ } - scanner.Text() - nextLine++ } ticker := time.NewTicker(opts.MetricsInterval) @@ -244,8 +245,8 @@ func workGenerator(ctx context.Context, opts options.Options, fp *os.File, quest case <-ticker.C: now := time.Now().Unix() log.Printf("INFO: currently %.1f sites/s, %.1f sites/s since start\n", - float64(nextLine-opts.NextLine)/float64(now-startTime), float64(nextLine-latestCount)/float64(now-latestTime), + float64(nextLine-opts.NextLine)/float64(now-startTime), ) latestCount = nextLine -- cgit v1.2.3