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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package main
import (
"crypto/sha256"
logger "log"
"strings"
"gitlab.torproject.org/rgdd/ct/pkg/metadata"
)
// logs select logs that count towards CT-compliance checks. Logs that don't
// have a description are skipped after printing a warning.
func logs(md metadata.Metadata) (logs []metadata.Log) {
for _, operators := range md.Operators {
for _, log := range operators.Logs {
if log.Description == nil {
logger.Printf("WARNING: skipping log without description")
continue
}
if log.State == nil {
continue // skip logs with unknown states
}
if log.State.Name == metadata.LogStatePending {
continue // pending logs do not count towards CT-compliance
}
if log.State.Name == metadata.LogStateRetired {
continue // retired logs are not necessarily reachable
}
if log.State.Name == metadata.LogStateRejected {
continue // rejected logs do not count towards CT-compliance
}
logs = append(logs, log)
}
}
return
}
// maxWorkers reduces the number of workers for logs that don't appreciate too
// much parallel fetching (errors), or for which performance is equal or worse.
// Warning: this may be system-dependent, determined "by-hand" on 2023-03-18.
func maxWorkers(log metadata.Log, workers uint64) int {
if max := 40; strings.Contains(*log.Description, "Argon") && int(workers) > max {
return max
}
if max := 16; strings.Contains(*log.Description, "Google") && int(workers) > max {
return max
}
if max := 4; strings.Contains(*log.Description, "Cloudflare") && int(workers) > max {
return max
}
if max := 12; strings.Contains(*log.Description, "Let's Encrypt") && int(workers) > max {
return max
}
if max := 5; strings.Contains(*log.Description, "Sectigo") && int(workers) > max {
return max
}
if max := 2; strings.Contains(*log.Description, "DigiCert") && int(workers) > max {
return max
}
if max := 2; strings.Contains(*log.Description, "Trust Asia") && int(workers) > max {
return max
}
return int(workers)
}
// proof formats hashes so that they can be passed to the merkle package
func proof(hashes [][]byte) (p [][sha256.Size]byte) {
for _, hash := range hashes {
var h [sha256.Size]byte
copy(h[:], hash)
p = append(p, h)
}
return
}
|