aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/options/options.go4
-rw-r--r--main.go29
2 files changed, 17 insertions, 16 deletions
diff --git a/internal/options/options.go b/internal/options/options.go
index a567b0e..b00d3f9 100644
--- a/internal/options/options.go
+++ b/internal/options/options.go
@@ -23,7 +23,7 @@ type Options struct {
}
func Parse() (opts Options) {
- flag.StringVar(&opts.InputFile, "i", "lists/small.lst", "input file, one domain name per line")
+ flag.StringVar(&opts.InputFile, "i", "", "input file, one domain name per line")
flag.IntVar(&opts.MaxFileBuffer, "b", 512, "max bytes to read from input file at once in MiB")
flag.Int64Var(&opts.NextLine, "n", 0, "next line to start reading the input file from")
@@ -31,7 +31,7 @@ func Parse() (opts Options) {
flag.DurationVar(&opts.Timeout, "t", 10*time.Second, "timeout for each website visit")
flag.Int64Var(&opts.MaxResponse, "r", 128, "max response body size to accept in MiB")
- flag.StringVar(&opts.CheckerDomain, "c", "rgdd.se", "domain with onion location for setup santity-checks")
+ flag.StringVar(&opts.CheckerDomain, "c", "", "domain with onion location for setup santity-checks")
flag.DurationVar(&opts.CheckerInterval, "C", 10*time.Second, "how often to to run checker")
flag.DurationVar(&opts.MetricsInterval, "m", 5*time.Second, "how often to emit metrics")
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