aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2023-03-17 14:35:13 +0100
committerRasmus Dahlberg <rasmus@rgdd.se>2023-03-17 14:35:13 +0100
commit14a8a232e78599caf8c037e85e2549b10951c1af (patch)
treea6c02a33078d89dcba7a1b43958e02d7cd222958 /main.go
parentfe4f2c413996fbcbfecce1e138cffa8a612dfceb (diff)
Make a few constants into flags
Diffstat (limited to 'main.go')
-rw-r--r--main.go41
1 files changed, 19 insertions, 22 deletions
diff --git a/main.go b/main.go
index 53cfd65..a13ba34 100644
--- a/main.go
+++ b/main.go
@@ -21,13 +21,13 @@ const usage = `ct-sans collects SANs in CT-logged certificates
Usage:
- ct-sans snapshot [-d DIRECTORY]
+ ct-sans snapshot [Options...]
Refresh log lists, signed tree heads, and timestamps
- ct-sans collect [-d DIRECTORY]
+ ct-sans collect [Options...]
Collect SANs with regards to the current snapshot
- ct-sans assemble [-d DIRECTORY]
+ ct-sans assemble [Options...]
Assemble a dataset manifest and print a command that combines,
sorts, and removes duplicate SANs that were collected.
@@ -37,12 +37,20 @@ Help:
Options:
- -d, --directory: The ct-sans working directory (Default: "ct-sans")
+ -d, --directory: The ct-sans working directory (Default: "ct-sans")
+ -w, --workers: Number of parallel download workers per log (Default: 2)
+ -k, --batch-disk: Certificate batch size before persisting (Default: 16384)
+ -q, --batch-req: Certificate batch size to use in request (Default: 512)
+ -a, --http-agent: HTTP agent to use in all request (Default: "rgdd.se/ct-sans")
`
type options struct {
- Directory string
+ Directory string
+ WorkersPerLog uint64
+ PersistSize uint64
+ BatchSize uint64
+ HTTPAgent string
logDirectory string
metadataFile string
@@ -51,12 +59,6 @@ type options struct {
sthFile string
stateFile string
sansFile string
-
- workersPerLog uint64
- batchSize uint64
- persistSize uint64
-
- httpAgent string
}
func main() {
@@ -69,8 +71,12 @@ func main() {
fs := ctflag.NewFlagSet()
opts := options{}
ctflag.String(&fs, &opts.Directory, "directory", "d", "ct-sans")
+ ctflag.Uint64(&fs, &opts.WorkersPerLog, "workers", "w", 2)
+ ctflag.Uint64(&fs, &opts.PersistSize, "batch-disk", "k", 16384)
+ ctflag.Uint64(&fs, &opts.BatchSize, "batch-req", "q", 512)
+ ctflag.String(&fs, &opts.HTTPAgent, "http-agent", "a", "rgdd.se/ct-sans")
- // Parse command-line options and hardcode default values
+ // Parse command-line options and hardcode additional values
if err := ctflag.Parse(fs, os.Args[2:]); err != nil {
if err == flag.ErrHelp {
fmt.Fprintf(os.Stderr, usage)
@@ -83,20 +89,11 @@ func main() {
opts.logDirectory = opts.Directory + "/" + "logs"
opts.metadataFile = "metadata.json"
opts.metadataSignatureFile = "metadata.sig"
- opts.metadataTimestampFile = "metadata.sig"
+ opts.metadataTimestampFile = "metadata.timestamp"
opts.sthFile = "sth.json"
opts.stateFile = "th.json"
opts.sansFile = "sans.lst"
- //opts.workersPerLog = 100
- //opts.batchSize = 100
- //opts.persistSize = 10000
- opts.workersPerLog = 1
- opts.batchSize = 10
- opts.persistSize = 1
-
- opts.httpAgent = "wip"
-
// Hand-over to the respective subcommands
var err error
switch cmd := os.Args[1]; cmd {