srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ipc/ipc.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ipc/ipc.go')
-rw-r--r--internal/ipc/ipc.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/ipc/ipc.go b/internal/ipc/ipc.go
index 68217c2..dc7a1df 100644
--- a/internal/ipc/ipc.go
+++ b/internal/ipc/ipc.go
@@ -114,6 +114,7 @@ type Response struct {
Rules []rules.Rule `json:"rules,omitempty"` // for "rules"
ScopeRules []scope.Rule `json:"scope_rules,omitempty"` // for "scope_rules"
ClientCerts []clientcert.Cert `json:"client_certs,omitempty"` // for "client_certs"
+ WSMessages []store.WSMessage `json:"ws_messages,omitempty"` // for "ws_messages"
Status *StatusMsg `json:"status,omitempty"` // for "status"
// For "import_done": how many entries were actually inserted (a
@@ -331,6 +332,25 @@ func (c *Client) Get(id int64) (*EntryDetail, error) {
return resp.Detail, nil
}
+// ListWSMessages returns every WebSocket frame captured for entryID's
+// connection, in the order they were sent - empty (not an error) if the
+// entry wasn't a WebSocket upgrade or nothing was captured.
+func (c *Client) ListWSMessages(entryID int64) ([]store.WSMessage, error) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ if err := c.enc.Encode(Request{Type: "ws_messages", ID: entryID}); err != nil {
+ return nil, err
+ }
+ var resp Response
+ if err := c.dec.Decode(&resp); err != nil {
+ return nil, err
+ }
+ if resp.Type == "error" {
+ return nil, errors.New(resp.Error)
+ }
+ return resp.WSMessages, nil
+}
+
// Repeat sends raw to scheme://host exactly as given (no re-serialization,
// no header injection) and returns the resulting entry, including the raw
// response bytes. The exchange is also recorded to history.