Skip to content

Commit c177480

Browse files
authored
Integrate API2 module (#24)
1 parent 88efb49 commit c177480

File tree

3 files changed

+69
-40
lines changed

3 files changed

+69
-40
lines changed

api.go

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"sync"
99
"time"
1010

11+
"github.com/google/uuid"
12+
capture "github.com/kubeshark/api2/pkg/proto/capture/v1"
13+
common "github.com/kubeshark/api2/pkg/proto/common/v1"
14+
protoCommon "github.com/kubeshark/api2/pkg/proto/common/v1"
1115
"github.com/kubeshark/gopacket"
1216
corev1 "k8s.io/api/core/v1"
1317
)
@@ -694,6 +698,8 @@ type OutputChannelItem struct {
694698
Protocol Protocol
695699
Timestamp int64
696700
ConnectionInfo *ConnectionInfo
701+
NetworkProps *common.NetworkProperties
702+
CaptureSource protoCommon.CaptureSource
697703
Pair *RequestResponsePair
698704
Data *GenericMessage
699705
Tls bool
@@ -735,6 +741,7 @@ type Dissector interface {
735741
Dissect(b *bufio.Reader, reader TcpReader) (err error)
736742
Analyze(item *OutputChannelItem, resolvedSource *Resolution, resolvedDestination *Resolution) *Entry
737743
Summarize(entry *Entry) *BaseEntry
744+
Summarize2(entry *Entry, id uuid.UUID) *capture.BaseEntry
738745
Represent(request interface{}, response interface{}, event *Event, data interface{}) (representation *Representation)
739746
Macros() map[string]string
740747
NewResponseRequestMatcher() RequestResponseMatcher
@@ -835,39 +842,41 @@ type Event struct {
835842

836843
// {Worker}/{Stream}-{Index} uniquely identifies an item
837844
type Entry struct {
838-
Id string `json:"id"`
839-
Index int64 `json:"index"`
840-
Stream string `json:"stream"`
841-
Worker string `json:"worker"`
842-
Node *Node `json:"node"`
843-
Protocol Protocol `json:"protocol"`
844-
Tls bool `json:"tls"`
845-
Source *Resolution `json:"src"`
846-
Destination *Resolution `json:"dst"`
847-
Timestamp int64 `json:"timestamp"`
848-
StartTime time.Time `json:"startTime"`
849-
Request interface{} `json:"request"`
850-
Response interface{} `json:"response"`
851-
RequestRef string `json:"requestRef"`
852-
ResponseRef string `json:"responseRef"`
853-
RequestSize int `json:"requestSize"`
854-
ResponseSize int `json:"responseSize"`
855-
ElapsedTime int64 `json:"elapsedTime"`
856-
Passed bool `json:"passed"`
857-
Failed bool `json:"failed"`
858-
Error *Error `json:"error"`
859-
EntryFile string `json:"entryFile"`
860-
Record string `json:"record"`
861-
Event *Event `json:"event"`
862-
EventRef string `json:"eventRef"`
863-
Base *BaseEntry `json:"base"`
864-
Capture *Capture `json:"capture"`
865-
Checksums []string `json:"checksums"`
866-
Duplicate string `json:"duplicate"`
867-
Data interface{} `json:"data"`
868-
DataRef string `json:"dataRef"`
869-
Size int `json:"size"`
870-
MatcherKey string `json:"matcherKey"`
845+
Id string `json:"id"`
846+
Index int64 `json:"index"`
847+
Stream string `json:"stream"`
848+
Worker string `json:"worker"`
849+
Node *Node `json:"node"`
850+
Protocol Protocol `json:"protocol"`
851+
Tls bool `json:"tls"`
852+
Source *Resolution `json:"src"`
853+
Destination *Resolution `json:"dst"`
854+
Timestamp int64 `json:"timestamp"`
855+
StartTime time.Time `json:"startTime"`
856+
Request interface{} `json:"request"`
857+
Response interface{} `json:"response"`
858+
RequestRef string `json:"requestRef"`
859+
ResponseRef string `json:"responseRef"`
860+
RequestSize int `json:"requestSize"`
861+
ResponseSize int `json:"responseSize"`
862+
ElapsedTime int64 `json:"elapsedTime"`
863+
Passed bool `json:"passed"`
864+
Failed bool `json:"failed"`
865+
Error *Error `json:"error"`
866+
EntryFile string `json:"entryFile"`
867+
Record string `json:"record"`
868+
Event *Event `json:"event"`
869+
EventRef string `json:"eventRef"`
870+
Base *BaseEntry `json:"base"`
871+
Capture *Capture `json:"capture"`
872+
Checksums []string `json:"checksums"`
873+
Duplicate string `json:"duplicate"`
874+
Data interface{} `json:"data"`
875+
DataRef string `json:"dataRef"`
876+
Size int `json:"size"`
877+
MatcherKey string `json:"matcherKey"`
878+
NetworkProps *common.NetworkProperties
879+
CaptureSource protoCommon.CaptureSource
871880
}
872881

873882
func (e *Entry) BuildId() {
@@ -1105,6 +1114,7 @@ type TcpStream interface {
11051114
GetTls() bool
11061115
GetCapture() *Capture
11071116
GetChecksums() []string
1117+
GetNetworkProps() *common.NetworkProperties
11081118
Lock()
11091119
Unlock()
11101120
}

go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module github.com/kubeshark/api
22

3-
go 1.20
3+
go 1.22.5
44

55
require (
6+
github.com/google/uuid v1.6.0
7+
github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a
68
github.com/kubeshark/gopacket v1.1.30
79
k8s.io/api v0.27.2
810
)
@@ -15,8 +17,9 @@ require (
1517
github.com/kubeshark/tracerproto v1.0.0 // indirect
1618
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
1719
github.com/modern-go/reflect2 v1.0.2 // indirect
18-
golang.org/x/net v0.19.0 // indirect
19-
golang.org/x/text v0.14.0 // indirect
20+
golang.org/x/net v0.26.0 // indirect
21+
golang.org/x/text v0.16.0 // indirect
22+
google.golang.org/protobuf v1.36.6 // indirect
2023
gopkg.in/inf.v0 v0.9.1 // indirect
2124
gopkg.in/yaml.v2 v2.4.0 // indirect
2225
k8s.io/apimachinery v0.27.2 // indirect

go.sum

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
1010
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
1111
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
1212
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
13+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
14+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1315
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
1416
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
1517
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
1618
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
1719
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
20+
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
1821
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
22+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
23+
github.com/kubeshark/api2 v0.0.0-20250613175225-65be260e56f6 h1:yDx1eb+qQ3hB3xHQzSP7MLTDAFW9/jWuKGUA1GpFG7U=
24+
github.com/kubeshark/api2 v0.0.0-20250613175225-65be260e56f6/go.mod h1:naOqOy71RRXeKPVH7/Vr2cGbyRDLg9sPKDBeOxdNCWU=
25+
github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a h1:+0APmVFqmmpibP2oluAdyqnD05z17iq+sSQvSXj2w2A=
26+
github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a/go.mod h1:naOqOy71RRXeKPVH7/Vr2cGbyRDLg9sPKDBeOxdNCWU=
1927
github.com/kubeshark/gopacket v1.1.30 h1:Dz6eo7b6+NdVCrgiyKxlGEVTm0L6PwgbVvSomsuwIyU=
2028
github.com/kubeshark/gopacket v1.1.30/go.mod h1:Qo8/i/tdT74CCT7/pjO0L55Pktv5dQfj7M/Arv8MKm8=
2129
github.com/kubeshark/tracerproto v1.0.0 h1:/euPX9KMrKDS92hSMrLuhncYAX22dYlsnM2aD4AYhhE=
@@ -28,10 +36,13 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
2836
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2937
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3038
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
39+
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
3140
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
41+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
3242
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3343
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
3444
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
45+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
3546
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
3647
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
3748
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
@@ -46,8 +57,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
4657
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
4758
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
4859
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
49-
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
50-
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
60+
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
61+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
5162
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5263
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5364
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -58,8 +69,8 @@ golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7w
5869
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5970
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
6071
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
61-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
62-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
72+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
73+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
6374
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
6475
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
6576
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -68,14 +79,18 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
6879
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6980
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7081
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
82+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
83+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
7184
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7285
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
86+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
7387
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
7488
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
7589
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
7690
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
7791
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
7892
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
93+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7994
k8s.io/api v0.27.2 h1:+H17AJpUMvl+clT+BPnKf0E3ksMAzoBBg7CntpSuADo=
8095
k8s.io/api v0.27.2/go.mod h1:ENmbocXfBT2ADujUXcBhHV55RIT31IIEvkntP6vZKS4=
8196
k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg=
@@ -89,3 +104,4 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h6
89104
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
90105
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
91106
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
107+
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=

0 commit comments

Comments
 (0)