mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-12 05:43:34 +00:00
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package redis
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/up9inc/mizu/tap/api"
|
|
)
|
|
|
|
func handleClientStream(tcpID *api.TcpID, counterPair *api.CounterPair, superTimer *api.SuperTimer, emitter api.Emitter, request *RedisPacket) error {
|
|
counterPair.Request++
|
|
ident := fmt.Sprintf(
|
|
"%s->%s %s->%s %d",
|
|
tcpID.SrcIP,
|
|
tcpID.DstIP,
|
|
tcpID.SrcPort,
|
|
tcpID.DstPort,
|
|
counterPair.Request,
|
|
)
|
|
item := reqResMatcher.registerRequest(ident, request, superTimer.CaptureTime)
|
|
if item != nil {
|
|
item.ConnectionInfo = &api.ConnectionInfo{
|
|
ClientIP: tcpID.SrcIP,
|
|
ClientPort: tcpID.SrcPort,
|
|
ServerIP: tcpID.DstIP,
|
|
ServerPort: tcpID.DstPort,
|
|
IsOutgoing: true,
|
|
}
|
|
emitter.Emit(item)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func handleServerStream(tcpID *api.TcpID, counterPair *api.CounterPair, superTimer *api.SuperTimer, emitter api.Emitter, response *RedisPacket) error {
|
|
counterPair.Response++
|
|
ident := fmt.Sprintf(
|
|
"%s->%s %s->%s %d",
|
|
tcpID.DstIP,
|
|
tcpID.SrcIP,
|
|
tcpID.DstPort,
|
|
tcpID.SrcPort,
|
|
counterPair.Response,
|
|
)
|
|
item := reqResMatcher.registerResponse(ident, response, superTimer.CaptureTime)
|
|
if item != nil {
|
|
item.ConnectionInfo = &api.ConnectionInfo{
|
|
ClientIP: tcpID.DstIP,
|
|
ClientPort: tcpID.DstPort,
|
|
ServerIP: tcpID.SrcIP,
|
|
ServerPort: tcpID.SrcPort,
|
|
IsOutgoing: false,
|
|
}
|
|
emitter.Emit(item)
|
|
}
|
|
return nil
|
|
}
|