From 2188b0cbc6d557aec171ff9562db73009927d0ff Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sun, 19 May 2024 13:04:55 +0200 Subject: Free up -f so that it can be used for force --- cmd/silentct-mon/examples.help2man | 4 ++-- cmd/silentct-mon/main.go | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'cmd') diff --git a/cmd/silentct-mon/examples.help2man b/cmd/silentct-mon/examples.help2man index 7a1e8fc..15f97cb 100644 --- a/cmd/silentct-mon/examples.help2man +++ b/cmd/silentct-mon/examples.help2man @@ -27,11 +27,11 @@ A basic configuration is shown below. Bootstrap a new monitor in a non-existent directory: -.B $ silentct-mon -b -d ~/.local/lib/silent-ct -f ~/.config/silent-ct/config.json +.B $ silentct-mon -b -c ~/.config/silent-ct/config.json -d ~/.local/lib/silent-ct Run the monitor continuously: -.B $ silentct-mon -d ~/.local/lib/silent-ct -f ~/.config/silent-ct/config.json +.B $ silentct-mon -c ~/.config/silent-ct/config.json -d ~/.local/lib/silent-ct Use .B -v DEBUG diff --git a/cmd/silentct-mon/main.go b/cmd/silentct-mon/main.go index 2d070fb..b11600f 100644 --- a/cmd/silentct-mon/main.go +++ b/cmd/silentct-mon/main.go @@ -31,17 +31,18 @@ utility on the trusted systems that legitimately request certificates. The same list of Certificate Transparency logs as Google Chrome is used. This list can be overridden in the silentct-mon configuration file. -Usage: silentct-mon [Options] -d DIRECTORY -f POLICY-FILE +Usage: silentct-mon [Options] -c CONFIGURATION-FILE -d DIRECTORY Options: -b, --bootstrap Initializes a new state directory (Default: false) - -c, --contact A string that helps log operators know who you are (Default: "") + -c, --configuration Path to the monitor's configuration file in JSON format + -C, --contact A string that helps log operators know who you are, + consider seting this to an email address (Default: "") -d, --directory Path to a directory where all state will be stored -w, --num-workers Number of parallel workers to fetch each log with (Default: 1) -o, --output-file File that all output will be written to (Default: stdout) -e, --please-exit Toggle to only run until up-to-date (Default: false) - -f, --policy-file Path to the monitor's policy file in JSON format -p, --pull-interval How often nodes are pulled for certificates (Default: 15m) -v, --verbosity Leveled logging output (default: NOTICE) ` @@ -50,10 +51,10 @@ type config struct { // Options verbosity string bootstrap bool + configFile string contact string directory string pleaseExit bool - policyFile string outputFile string pullInterval time.Duration numWorkers uint @@ -67,12 +68,12 @@ func configure(cmd string, args []string) (cfg config, err error) { fs := flag.NewFlagSet(cmd, flag.ContinueOnError) fs.Usage = func() {} flagopt.BoolOpt(fs, &cfg.bootstrap, "bootstrap", "b", false) - flagopt.StringOpt(fs, &cfg.contact, "contact", "c", "") + flagopt.StringOpt(fs, &cfg.configFile, "configuration", "c", "") + flagopt.StringOpt(fs, &cfg.contact, "contact", "C", "") flagopt.StringOpt(fs, &cfg.directory, "directory", "d", "") flagopt.UintOpt(fs, &cfg.numWorkers, "num-workers", "w", 1) flagopt.StringOpt(fs, &cfg.outputFile, "output-file", "o", "") flagopt.BoolOpt(fs, &cfg.pleaseExit, "please-exit", "e", false) - flagopt.StringOpt(fs, &cfg.policyFile, "policy-file", "f", "") flagopt.DurationOpt(fs, &cfg.pullInterval, "pull-interval", "p", 15*time.Minute) flagopt.StringOpt(fs, &cfg.verbosity, "verbosity", "v", logger.LevelNotice.String()) if err = fs.Parse(args); err != nil { @@ -92,14 +93,14 @@ func configure(cmd string, args []string) (cfg config, err error) { return cfg, fmt.Errorf("failed to open output file: %v", err) } } - if cfg.policyFile == "" { - return cfg, fmt.Errorf("policy file is a required option") + if cfg.configFile == "" { + return cfg, fmt.Errorf("configuration is a required option") } - if err := ioutil.ReadJSON(cfg.policyFile, &cfg.policy); err != nil { + if err := ioutil.ReadJSON(cfg.configFile, &cfg.policy); err != nil { return cfg, err } if len(cfg.policy.Monitor) == 0 { - return cfg, fmt.Errorf("policy: need at least one wildcard to monitor") + return cfg, fmt.Errorf("configuration: need at least one wildcard to monitor") } lv, err := logger.NewLevel(cfg.verbosity) if err != nil { -- cgit v1.2.3