aboutsummaryrefslogtreecommitdiff
path: root/internal/options/options.go
blob: b00d3f90ed56de47163c2737bdd61852315595fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package options

import (
	"flag"
	"time"
)

type Options struct {
	// Input file
	InputFile     string
	MaxFileBuffer int
	NextLine      int64

	// Website visits
	NumWorkers  int
	Timeout     time.Duration
	MaxResponse int64

	// Health and metrics
	CheckerDomain   string
	CheckerInterval time.Duration
	MetricsInterval time.Duration
}

func Parse() (opts Options) {
	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")

	flag.IntVar(&opts.NumWorkers, "w", 2, "number of parallel workers")
	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", "", "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")

	flag.Parse()
	return
}