mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-02 11:05:22 +00:00
Add support of defining multiple ports to the extension API
This commit is contained in:
@@ -6,7 +6,7 @@ type Extension struct {
|
|||||||
Name string
|
Name string
|
||||||
Path string
|
Path string
|
||||||
Plug *plugin.Plugin
|
Plug *plugin.Plugin
|
||||||
Port string
|
Ports []string
|
||||||
Dissector Dissector
|
Dissector Dissector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,11 +15,11 @@ type dissecting string
|
|||||||
|
|
||||||
func (g dissecting) Register(extension *api.Extension) {
|
func (g dissecting) Register(extension *api.Extension) {
|
||||||
fmt.Printf("extension: %v\n", extension)
|
fmt.Printf("extension: %v\n", extension)
|
||||||
extension.Port = "5672"
|
extension.Ports = []string{"5671", "5672"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g dissecting) Ping() {
|
func (g dissecting) Ping() {
|
||||||
fmt.Printf("pong\n")
|
fmt.Printf("pong AMQP\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// exported as symbol named "Greeter"
|
// exported as symbol named "Greeter"
|
||||||
|
@@ -15,11 +15,11 @@ type dissecting string
|
|||||||
|
|
||||||
func (g dissecting) Register(extension *api.Extension) {
|
func (g dissecting) Register(extension *api.Extension) {
|
||||||
fmt.Printf("extension: %v\n", extension)
|
fmt.Printf("extension: %v\n", extension)
|
||||||
extension.Port = "80"
|
extension.Ports = []string{"80", "8080", "443"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g dissecting) Ping() {
|
func (g dissecting) Ping() {
|
||||||
fmt.Printf("pong\n")
|
fmt.Printf("pong HTTP\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// exported as symbol named "Greeter"
|
// exported as symbol named "Greeter"
|
||||||
|
@@ -15,11 +15,11 @@ type dissecting string
|
|||||||
|
|
||||||
func (g dissecting) Register(extension *api.Extension) {
|
func (g dissecting) Register(extension *api.Extension) {
|
||||||
fmt.Printf("extension: %v\n", extension)
|
fmt.Printf("extension: %v\n", extension)
|
||||||
extension.Port = "9092"
|
extension.Ports = []string{"9092"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g dissecting) Ping() {
|
func (g dissecting) Ping() {
|
||||||
fmt.Printf("pong\n")
|
fmt.Printf("pong Kafka\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// exported as symbol named "Greeter"
|
// exported as symbol named "Greeter"
|
||||||
|
@@ -26,10 +26,19 @@ type tcpStreamFactory struct {
|
|||||||
|
|
||||||
const checkTLSPacketAmount = 100
|
const checkTLSPacketAmount = 100
|
||||||
|
|
||||||
|
func containsPort(ports []string, port string) bool {
|
||||||
|
for _, x := range ports {
|
||||||
|
if x == port {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (h *tcpStream) run(wg *sync.WaitGroup) {
|
func (h *tcpStream) run(wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for _, extension := range extensions {
|
for _, extension := range extensions {
|
||||||
if extension.Port == h.transport.Dst().String() {
|
if containsPort(extension.Ports, h.transport.Dst().String()) {
|
||||||
extension.Dissector.Ping()
|
extension.Dissector.Ping()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user