Skip to content

Commit da9336b

Browse files
authored
Add SubProtocol for api2 (#26)
1 parent bb85962 commit da9336b

File tree

3 files changed

+48
-46
lines changed

3 files changed

+48
-46
lines changed

api.go

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/google/uuid"
1212
capture "github.com/kubeshark/api2/pkg/proto/capture/v1"
13-
common "github.com/kubeshark/api2/pkg/proto/common/v1"
1413
protoCommon "github.com/kubeshark/api2/pkg/proto/common/v1"
1514
"github.com/kubeshark/gopacket"
1615
corev1 "k8s.io/api/core/v1"
@@ -364,9 +363,10 @@ type ResolutionSummary struct {
364363
}
365364

366365
type Extension struct {
367-
Protocol *Protocol
368-
Path string
369-
Dissector Dissector
366+
Protocol *Protocol
367+
SubProtocol *protoCommon.DissectedSubProtocol
368+
Path string
369+
Dissector Dissector
370370
}
371371

372372
type VLAN struct {
@@ -714,7 +714,7 @@ type OutputChannelItem struct {
714714
Protocol Protocol
715715
Timestamp int64
716716
ConnectionInfo *ConnectionInfo
717-
NetworkProps *common.NetworkProperties
717+
NetworkProps *protoCommon.NetworkProperties
718718
CaptureSource protoCommon.CaptureSource
719719
Pair *RequestResponsePair
720720
Data *GenericMessage
@@ -858,41 +858,42 @@ type Event struct {
858858

859859
// {Worker}/{Stream}-{Index} uniquely identifies an item
860860
type Entry struct {
861-
Id string `json:"id"`
862-
Index int64 `json:"index"`
863-
Stream string `json:"stream"`
864-
Worker string `json:"worker"`
865-
Node *Node `json:"node"`
866-
Protocol Protocol `json:"protocol"`
867-
Tls bool `json:"tls"`
868-
Source *Resolution `json:"src"`
869-
Destination *Resolution `json:"dst"`
870-
Timestamp int64 `json:"timestamp"`
871-
StartTime time.Time `json:"startTime"`
872-
Request interface{} `json:"request"`
873-
Response interface{} `json:"response"`
874-
RequestRef string `json:"requestRef"`
875-
ResponseRef string `json:"responseRef"`
876-
RequestSize int `json:"requestSize"`
877-
ResponseSize int `json:"responseSize"`
878-
ElapsedTime int64 `json:"elapsedTime"`
879-
Passed bool `json:"passed"`
880-
Failed bool `json:"failed"`
881-
Error *Error `json:"error"`
882-
EntryFile string `json:"entryFile"`
883-
Record string `json:"record"`
884-
Event *Event `json:"event"`
885-
EventRef string `json:"eventRef"`
886-
Base *BaseEntry `json:"base"`
887-
Capture *Capture `json:"capture"`
888-
Checksums []string `json:"checksums"`
889-
Duplicate string `json:"duplicate"`
890-
Data interface{} `json:"data"`
891-
DataRef string `json:"dataRef"`
892-
Size int `json:"size"`
893-
MatcherKey string `json:"matcherKey"`
894-
NetworkProps *common.NetworkProperties
895-
CaptureSource protoCommon.CaptureSource
861+
Id string `json:"id"`
862+
Index int64 `json:"index"`
863+
Stream string `json:"stream"`
864+
Worker string `json:"worker"`
865+
Node *Node `json:"node"`
866+
Protocol Protocol `json:"protocol"`
867+
Tls bool `json:"tls"`
868+
Source *Resolution `json:"src"`
869+
Destination *Resolution `json:"dst"`
870+
Timestamp int64 `json:"timestamp"`
871+
StartTime time.Time `json:"startTime"`
872+
Request interface{} `json:"request"`
873+
Response interface{} `json:"response"`
874+
RequestRef string `json:"requestRef"`
875+
ResponseRef string `json:"responseRef"`
876+
RequestSize int `json:"requestSize"`
877+
ResponseSize int `json:"responseSize"`
878+
ElapsedTime int64 `json:"elapsedTime"`
879+
Passed bool `json:"passed"`
880+
Failed bool `json:"failed"`
881+
Error *Error `json:"error"`
882+
EntryFile string `json:"entryFile"`
883+
Record string `json:"record"`
884+
Event *Event `json:"event"`
885+
EventRef string `json:"eventRef"`
886+
Base *BaseEntry `json:"base"`
887+
Capture *Capture `json:"capture"`
888+
Checksums []string `json:"checksums"`
889+
Duplicate string `json:"duplicate"`
890+
Data interface{} `json:"data"`
891+
DataRef string `json:"dataRef"`
892+
Size int `json:"size"`
893+
MatcherKey string `json:"matcherKey"`
894+
NetworkProps *protoCommon.NetworkProperties `json:"networkProps"`
895+
CaptureSource protoCommon.CaptureSource `json:"captureSource"`
896+
SubProtocol protoCommon.DissectedSubProtocol `json:"subProtocol"`
896897
}
897898

898899
func (e *Entry) BuildId() {
@@ -1130,7 +1131,8 @@ type TcpStream interface {
11301131
GetTls() bool
11311132
GetCapture() *Capture
11321133
GetChecksums() []string
1133-
GetNetworkProps() *common.NetworkProperties
1134+
GetNetworkProps() *protoCommon.NetworkProperties
1135+
GetCaptureSource() protoCommon.CaptureSource
11341136
Lock()
11351137
Unlock()
11361138
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.5
44

55
require (
66
github.com/google/uuid v1.6.0
7-
github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a
7+
github.com/kubeshark/api2 v0.0.0-20250721140118-e9883b737a5e
88
github.com/kubeshark/gopacket v1.1.30
99
k8s.io/api v0.27.2
1010
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
2020
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
2121
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2222
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
23-
github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a h1:+0APmVFqmmpibP2oluAdyqnD05z17iq+sSQvSXj2w2A=
24-
github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a/go.mod h1:naOqOy71RRXeKPVH7/Vr2cGbyRDLg9sPKDBeOxdNCWU=
23+
github.com/kubeshark/api2 v0.0.0-20250721140118-e9883b737a5e h1:D3iK1id1o03JWZ0s0d/bNvFhsN5hBGiol45ZvxpSG10=
24+
github.com/kubeshark/api2 v0.0.0-20250721140118-e9883b737a5e/go.mod h1:u+RE/jKLCmogSqEVuTgV3/g5ae2g2Jr/Bz5L/w8rLZc=
2525
github.com/kubeshark/gopacket v1.1.30 h1:Dz6eo7b6+NdVCrgiyKxlGEVTm0L6PwgbVvSomsuwIyU=
2626
github.com/kubeshark/gopacket v1.1.30/go.mod h1:Qo8/i/tdT74CCT7/pjO0L55Pktv5dQfj7M/Arv8MKm8=
2727
github.com/kubeshark/tracerproto v1.0.0 h1:/euPX9KMrKDS92hSMrLuhncYAX22dYlsnM2aD4AYhhE=
@@ -39,8 +39,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
3939
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
4040
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
4141
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
42-
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
43-
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
42+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
43+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4444
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
4545
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
4646
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=

0 commit comments

Comments
 (0)