Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions internal/record/recording_https_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ func (r *RecordingHTTPSProxy) proxyWebsocket(w http.ResponseWriter, req *http.Re
c := make(chan []byte)
quit := make(chan int)

go pumpWebsocket(clientConn, conn, c, quit, ">")
go pumpWebsocket(conn, clientConn, c, quit, "<")
go r.pumpWebsocket(clientConn, conn, c, quit, ">")
go r.pumpWebsocket(conn, clientConn, c, quit, "<")

recordPath := filepath.Join(r.recordingDir, fileName+".websocket.log")
f, err := os.Create(recordPath)
Expand Down Expand Up @@ -280,7 +280,7 @@ func (r *RecordingHTTPSProxy) proxyWebsocket(w http.ResponseWriter, req *http.Re
}
}

func pumpWebsocket(src, dst *websocket.Conn, c chan []byte, quit chan int, prepend string) {
func (r *RecordingHTTPSProxy) pumpWebsocket(src, dst *websocket.Conn, c chan []byte, quit chan int, prepend string) {
for {
msgType, buf, err := src.ReadMessage()
if err != nil {
Expand All @@ -293,8 +293,9 @@ func pumpWebsocket(src, dst *websocket.Conn, c chan []byte, quit chan int, prepe
return
}
buf = append(buf, '\n')
prefix := fmt.Sprintf("%s%d ", prepend, len(buf))
c <- append([]byte(prefix), buf...)
redactedBuf := r.redactor.Bytes(buf)
prefix := fmt.Sprintf("%s%d ", prepend, len(redactedBuf))
c <- append([]byte(prefix), redactedBuf...)
err = dst.WriteMessage(msgType, buf)
if err != nil {
fmt.Printf("Error writing to websocket: %v\n", err)
Expand Down
6 changes: 3 additions & 3 deletions internal/replay/replay_http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (r *ReplayHTTPServer) proxyWebsocket(w http.ResponseWriter, req *http.Reque
return
}
defer clientConn.Close()
replayWebsocket(clientConn, chunks)
r.replayWebsocket(clientConn, chunks)
}

func (r *ReplayHTTPServer) loadWebsocketChunks(fileName string) ([]string, error) {
Expand Down Expand Up @@ -273,11 +273,11 @@ func (r *ReplayHTTPServer) loadWebsocketChunks(fileName string) ([]string, error
return chunks, nil
}

func replayWebsocket(conn *websocket.Conn, chunks []string) {
func (r *ReplayHTTPServer) replayWebsocket(conn *websocket.Conn, chunks []string) {
for _, chunk := range chunks {
if strings.HasPrefix(chunk, ">") {
_, buf, err := conn.ReadMessage()
reqChunk := string(buf)
reqChunk := r.redactor.String(string(buf))
if err != nil {
fmt.Printf("Error reading from websocket: %v\n", err)
return
Expand Down
Loading