aboutsummaryrefslogtreecommitdiff
path: root/internal/manager/helpers.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2023-12-09 17:08:45 +0100
committerRasmus Dahlberg <rasmus@rgdd.se>2023-12-10 20:38:21 +0100
commit895d5fea41177e444c18f4fdc820fffa5f67d5bf (patch)
tree42fd1e9507384abcd9c6e82f18ccca813f8b6296 /internal/manager/helpers.go
parentf124940f75e1f49100fe5381019d2f65d6915304 (diff)
Add drafty skeleton
Diffstat (limited to 'internal/manager/helpers.go')
-rw-r--r--internal/manager/helpers.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/manager/helpers.go b/internal/manager/helpers.go
new file mode 100644
index 0000000..a9a2158
--- /dev/null
+++ b/internal/manager/helpers.go
@@ -0,0 +1,52 @@
+package manager
+
+import (
+ "crypto/sha256"
+ "encoding/base64"
+ "fmt"
+
+ ct "github.com/google/certificate-transparency-go"
+ "gitlab.torproject.org/rgdd/ct/pkg/metadata"
+ "rgdd.se/silent-ct/pkg/monitor"
+)
+
+func selectLogs(m metadata.Metadata) []monitor.MessageLogConfig {
+ var logs []monitor.MessageLogConfig
+ for _, operator := range m.Operators {
+ for _, log := range operator.Logs {
+ if log.State == nil {
+ continue // ignore logs without a state (should not happen)
+ }
+ if log.State.Name == metadata.LogStatePending {
+ continue // log is not yet relevant
+ }
+ if log.State.Name == metadata.LogStateRetired {
+ continue // log is not expected to be reachable
+ }
+ if log.State.Name == metadata.LogStateRejected {
+ continue // log is not expected to be reachable
+ }
+
+ // FIXME: remove me instead of hard coding Argon 2024
+ id, _ := log.Key.ID()
+ got := fmt.Sprintf("%s", base64.StdEncoding.EncodeToString(id[:]))
+ want := "7s3QZNXbGs7FXLedtM0TojKHRny87N7DUUhZRnEftZs="
+ if got != want {
+ continue
+ }
+
+ logs = append(logs, monitor.MessageLogConfig{
+ Metadata: log,
+ State: monitor.MonitorState{
+ LogState: monitor.LogState{ct.SignedTreeHead{
+ SHA256RootHash: [sha256.Size]byte{47, 66, 110, 15, 246, 154, 8, 100, 150, 140, 206, 208, 17, 57, 112, 116, 210, 3, 19, 55, 46, 63, 209, 12, 234, 130, 225, 124, 237, 2, 64, 228},
+ TreeSize: 610650601,
+ Timestamp: 1702108968538,
+ }},
+ NextIndex: 388452203,
+ },
+ })
+ }
+ }
+ return logs
+}