aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum-debug/spam/leaf/config.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-07-22 18:25:56 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-07-22 18:25:56 +0200
commitf04e26523189ac3fc54381376966f98d2f52440b (patch)
tree52f664a52759322947420f7313573e92002fa6f9 /cmd/sigsum-debug/spam/leaf/config.go
parent722e48feb2aa85d8cb75069a06024e506367e34f (diff)
add spam command to sigsum-debugsigsum-spam
Diffstat (limited to 'cmd/sigsum-debug/spam/leaf/config.go')
-rw-r--r--cmd/sigsum-debug/spam/leaf/config.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/cmd/sigsum-debug/spam/leaf/config.go b/cmd/sigsum-debug/spam/leaf/config.go
new file mode 100644
index 0000000..2e20777
--- /dev/null
+++ b/cmd/sigsum-debug/spam/leaf/config.go
@@ -0,0 +1,60 @@
+package leaf
+
+import (
+ "crypto"
+ "crypto/ed25519"
+ "fmt"
+ "net/http"
+ "time"
+
+ "git.sigsum.org/sigsum-go/internal/fmtio"
+ "git.sigsum.org/sigsum-go/pkg/types"
+)
+
+type Config struct {
+ LogURL string
+ PrivateKey string // a private key to sign checksum with in hex
+ DomainHint string // a domain hint that is valid for the above key
+ Duration time.Duration // how long to run test
+ Interval time.Duration // how often to emit stats
+ Wait time.Duration // time to wait between submits
+ NumSubmitters uint64 // at least one
+ NumCheckers uint64 // zero to disable checkers
+
+ url string
+ signer crypto.Signer
+ pub types.PublicKey
+ cli http.Client
+
+ maxEvents int // maximum number of events to queue at a checker
+ backoff time.Duration // time to backoff when waiting for 200 OK
+}
+
+func (cfg *Config) parse(args []string) (err error) {
+ if len(args) != 0 {
+ return fmt.Errorf("trailing arguments: %v", args)
+ }
+ if len(cfg.LogURL) == 0 {
+ return fmt.Errorf("url is a required option")
+ }
+ if len(cfg.PrivateKey) == 0 {
+ return fmt.Errorf("private key is a required option")
+ }
+ if len(cfg.DomainHint) == 0 {
+ return fmt.Errorf("domain hint is a required option")
+ }
+
+ if cfg.signer, err = fmtio.SignerFromHex(cfg.PrivateKey); err != nil {
+ return fmt.Errorf("parse private key: %v", err)
+ }
+ if cfg.NumSubmitters == 0 {
+ return fmt.Errorf("at least one submitter is required")
+ }
+
+ cfg.url = types.EndpointAddLeaf.Path(cfg.LogURL, "sigsum/v0")
+ cfg.maxEvents = 16384
+ cfg.backoff = 5 * time.Second
+ cfg.cli = http.Client{Timeout: 10 * time.Second}
+ copy(cfg.pub[:], (cfg.signer.Public().(ed25519.PublicKey))[:])
+ return nil
+}