package options import ( "flag" "time" ) type Options struct { // Input file InputFile string MaxFileBuffer int StartLineInclusive int64 EndLineExclusive int64 // Website visits NumWorkers int Timeout time.Duration MaxResponse int64 // Health and metrics CheckerDomain string CheckerInterval time.Duration MetricsInterval time.Duration Limit int } 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.StartLineInclusive, "s", 0, "first line to read in input file, inclusive and zero-based index") flag.Int64Var(&opts.EndLineExclusive, "e", 0, "last line to read in input file, exclusive and zero-based; 0 to disable") 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.IntVar(&opts.Limit, "l", 10, "rate-limit that kicks in before feeding workers in reads/s") flag.Parse() return }