mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-31 16:25:22 +00:00
Sort extension by priority
This commit is contained in:
parent
3ca6437320
commit
b2a07f37a4
@ -17,6 +17,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"plugin"
|
||||
"sort"
|
||||
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -149,7 +150,6 @@ func loadExtensions() {
|
||||
dissector, _ = symDissector.(tapApi.Dissector)
|
||||
dissector.Register(extension)
|
||||
extension.Dissector = dissector
|
||||
log.Printf("Extension Properties: %+v\n", extension)
|
||||
extensions[i] = extension
|
||||
if ports, ok := appPorts[extension.Protocol.Name]; ok {
|
||||
log.Printf("Overriding \"%s\" extension's ports to: %v", extension.Protocol.Name, ports)
|
||||
@ -158,6 +158,15 @@ func loadExtensions() {
|
||||
extensionsMap[extension.Protocol.Name] = extension
|
||||
allExtensionPorts = mergeUnique(allExtensionPorts, extension.Protocol.Ports)
|
||||
}
|
||||
|
||||
sort.Slice(extensions, func(i, j int) bool {
|
||||
return extensions[i].Protocol.Priority < extensions[j].Protocol.Priority
|
||||
})
|
||||
|
||||
for _, extension := range extensions {
|
||||
log.Printf("Extension Properties: %+v\n", extension)
|
||||
}
|
||||
|
||||
controllers.InitExtensionsMap(extensionsMap)
|
||||
log.Printf("All extension ports: %v\n", allExtensionPorts)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ type Protocol struct {
|
||||
FontSize int8 `json:"font_size"`
|
||||
ReferenceLink string `json:"reference_link"`
|
||||
Ports []string `json:"ports"`
|
||||
Priority uint8 `json:"priority"`
|
||||
}
|
||||
|
||||
type Extension struct {
|
||||
|
@ -21,6 +21,7 @@ var protocol api.Protocol = api.Protocol{
|
||||
FontSize: 12,
|
||||
ReferenceLink: "https://www.rabbitmq.com/amqp-0-9-1-reference.html",
|
||||
Ports: []string{"5671", "5672"},
|
||||
Priority: 1,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -25,6 +25,7 @@ var protocol api.Protocol = api.Protocol{
|
||||
FontSize: 12,
|
||||
ReferenceLink: "https://datatracker.ietf.org/doc/html/rfc2616",
|
||||
Ports: []string{"80", "8080", "50051"},
|
||||
Priority: 0,
|
||||
}
|
||||
|
||||
var http2Protocol api.Protocol = api.Protocol{
|
||||
@ -37,6 +38,7 @@ var http2Protocol api.Protocol = api.Protocol{
|
||||
FontSize: 11,
|
||||
ReferenceLink: "https://datatracker.ietf.org/doc/html/rfc7540",
|
||||
Ports: []string{"80", "8080"},
|
||||
Priority: 0,
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -20,6 +20,7 @@ var _protocol api.Protocol = api.Protocol{
|
||||
FontSize: 11,
|
||||
ReferenceLink: "https://kafka.apache.org/protocol",
|
||||
Ports: []string{"9092"},
|
||||
Priority: 2,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
Loading…
Reference in New Issue
Block a user