blob: 2e20777b288e7af0069767032667398579b9fb6f (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
}
|