aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/pkg/api
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-05-12 14:34:19 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-05-13 10:05:33 +0000
commit50f6de2f6c8b05193d0ca3f3881bd662b4babe60 (patch)
tree109620befa31a9696888a69a44a3cfaf06fa7cce /syz-cluster/pkg/api
parenta11966dc8beffc94c9f60f6ad1188b3a02f770f0 (diff)
syz-cluster: add reply tracking functionality
Add API to record replies under the reports that allows to determine the original report only by having the MessageID.
Diffstat (limited to 'syz-cluster/pkg/api')
-rw-r--r--syz-cluster/pkg/api/reporter.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/syz-cluster/pkg/api/reporter.go b/syz-cluster/pkg/api/reporter.go
index 5a7b7bfb4..e73bdb668 100644
--- a/syz-cluster/pkg/api/reporter.go
+++ b/syz-cluster/pkg/api/reporter.go
@@ -7,6 +7,7 @@ import (
"context"
"net/url"
"strings"
+ "time"
)
type ReporterClient struct {
@@ -53,3 +54,30 @@ func (client ReporterClient) UpstreamReport(ctx context.Context, id string, req
_, err := postJSON[UpstreamReportReq, any](ctx, client.baseURL+"/reports/"+id+"/upstream", req)
return err
}
+
+type RecordReplyReq struct {
+ MessageID string `json:"message_id"`
+ InReplyTo string `json:"in_reply_to"`
+ Reporter string `json:"reporter"`
+ Time time.Time `json:"time"`
+}
+
+type RecordReplyResp struct {
+ New bool `json:"new"`
+ ReportID string `json:"report_id"` // or empty, if no original message was found
+}
+
+func (client ReporterClient) RecordReply(ctx context.Context, req *RecordReplyReq) (*RecordReplyResp, error) {
+ return postJSON[RecordReplyReq, RecordReplyResp](ctx, client.baseURL+"/reports/record_reply", req)
+}
+
+type LastReplyResp struct {
+ Time time.Time `json:"time"`
+}
+
+// Returns nil if no reply has ever been recorded.
+func (client ReporterClient) LastReply(ctx context.Context, reporter string) (*LastReplyResp, error) {
+ v := url.Values{}
+ v.Add("reporter", reporter)
+ return postJSON[any, LastReplyResp](ctx, client.baseURL+"/reports/last_reply?"+v.Encode(), nil)
+}