mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-05-17 14:47:15 +00:00
73 lines
1.3 KiB
Go
73 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"plugin"
|
|
"time"
|
|
)
|
|
|
|
type Extension struct {
|
|
Name string
|
|
Path string
|
|
Plug *plugin.Plugin
|
|
InboundPorts []string
|
|
OutboundPorts []string
|
|
Dissector Dissector
|
|
}
|
|
|
|
type ConnectionInfo struct {
|
|
ClientIP string
|
|
ClientPort string
|
|
ServerIP string
|
|
ServerPort string
|
|
IsOutgoing bool
|
|
}
|
|
|
|
type TcpID struct {
|
|
SrcIP string
|
|
DstIP string
|
|
SrcPort string
|
|
DstPort string
|
|
}
|
|
|
|
type GenericMessage struct {
|
|
IsRequest bool
|
|
CaptureTime time.Time
|
|
Orig interface{}
|
|
}
|
|
|
|
type RequestResponsePair struct {
|
|
Request GenericMessage `json:"request"`
|
|
Response GenericMessage `json:"response"`
|
|
}
|
|
|
|
type OutputChannelItem struct {
|
|
Type string
|
|
Timestamp int64
|
|
ConnectionInfo *ConnectionInfo
|
|
Data *RequestResponsePair
|
|
}
|
|
|
|
type Dissector interface {
|
|
Register(*Extension)
|
|
Ping()
|
|
Dissect(b *bufio.Reader, isClient bool, tcpID *TcpID, emitter Emitter)
|
|
}
|
|
|
|
type Emitting struct {
|
|
OutputChannel chan *OutputChannelItem
|
|
}
|
|
|
|
type Emitter interface {
|
|
Emit(item *OutputChannelItem)
|
|
}
|
|
|
|
func (e *Emitting) Emit(item *OutputChannelItem) {
|
|
fmt.Printf("item: %+v\n", item)
|
|
fmt.Printf("item.Data: %+v\n", item.Data)
|
|
fmt.Printf("item.Data.Request.Orig: %v\n", item.Data.Request.Orig)
|
|
fmt.Printf("item.Data.Response.Orig: %v\n", item.Data.Response.Orig)
|
|
e.OutputChannel <- item
|
|
}
|