mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-05-18 23:27:55 +00:00
Add Protocol struct and make it effect the UI
This commit is contained in:
@@ -7,13 +7,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Protocol struct {
|
||||
Name string `json:"name"`
|
||||
LongName string `json:"long_name"`
|
||||
Abbreviation string `json:"abbreviation"`
|
||||
BackgroundColor string `json:"background_color"`
|
||||
ForegroundColor string `json:"foreground_color"`
|
||||
FontSize int8 `json:"font_size"`
|
||||
ReferenceLink string `json:"reference_link"`
|
||||
OutboundPorts []string `json:"outbound_ports"`
|
||||
InboundPorts []string `json:"inbound_ports"`
|
||||
}
|
||||
|
||||
type Extension struct {
|
||||
Name string
|
||||
Path string
|
||||
Plug *plugin.Plugin
|
||||
InboundPorts []string
|
||||
OutboundPorts []string
|
||||
Dissector Dissector
|
||||
Protocol Protocol
|
||||
Path string
|
||||
Plug *plugin.Plugin
|
||||
Dissector Dissector
|
||||
}
|
||||
|
||||
type ConnectionInfo struct {
|
||||
@@ -44,7 +54,7 @@ type RequestResponsePair struct {
|
||||
}
|
||||
|
||||
type OutputChannelItem struct {
|
||||
Protocol string
|
||||
Protocol Protocol
|
||||
Timestamp int64
|
||||
ConnectionInfo *ConnectionInfo
|
||||
Pair *RequestResponsePair
|
||||
@@ -95,6 +105,7 @@ type MizuEntry struct {
|
||||
|
||||
type BaseEntryDetails struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Protocol Protocol `json:"protocol,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
RequestSenderIp string `json:"requestSenderIp,omitempty"`
|
||||
Service string `json:"service,omitempty"`
|
||||
|
||||
@@ -7,20 +7,30 @@ import (
|
||||
"github.com/up9inc/mizu/tap/api"
|
||||
)
|
||||
|
||||
var protocol api.Protocol = api.Protocol{
|
||||
Name: "amqp",
|
||||
LongName: "Advanced Message Queuing Protocol",
|
||||
Abbreviation: "AMQP",
|
||||
BackgroundColor: "#ff6600",
|
||||
ForegroundColor: "#ffffff",
|
||||
FontSize: 10,
|
||||
ReferenceLink: "https://www.rabbitmq.com/amqp-0-9-1-reference.html",
|
||||
OutboundPorts: []string{"5671", "5672"},
|
||||
InboundPorts: []string{},
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.Println("Initializing AMQP extension.")
|
||||
log.Println("Initializing AMQP extension...")
|
||||
}
|
||||
|
||||
type dissecting string
|
||||
|
||||
func (d dissecting) Register(extension *api.Extension) {
|
||||
extension.Name = "amqp"
|
||||
extension.OutboundPorts = []string{"5671", "5672"}
|
||||
extension.InboundPorts = []string{}
|
||||
extension.Protocol = protocol
|
||||
}
|
||||
|
||||
func (d dissecting) Ping() {
|
||||
log.Printf("pong AMQP\n")
|
||||
log.Printf("pong %s\n", protocol.Name)
|
||||
}
|
||||
|
||||
func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, emitter api.Emitter) {
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/romana/rlog"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/romana/rlog"
|
||||
|
||||
"github.com/up9inc/mizu/tap/api"
|
||||
)
|
||||
|
||||
@@ -66,6 +67,7 @@ func handleHTTP2Stream(grpcAssembler *GrpcAssembler, tcpID *api.TcpID, emitter a
|
||||
}
|
||||
|
||||
if item != nil {
|
||||
item.Protocol = http2Protocol
|
||||
emitter.Emit(item)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,30 @@ import (
|
||||
var requestCounter uint
|
||||
var responseCounter uint
|
||||
|
||||
var protocol api.Protocol = api.Protocol{
|
||||
Name: "http",
|
||||
LongName: "Hypertext Transfer Protocol -- HTTP/1.0",
|
||||
Abbreviation: "HTTP",
|
||||
BackgroundColor: "#205cf5",
|
||||
ForegroundColor: "#ffffff",
|
||||
FontSize: 10,
|
||||
ReferenceLink: "https://www.ietf.org/rfc/rfc1945.txt",
|
||||
OutboundPorts: []string{"80", "8080", "443"},
|
||||
InboundPorts: []string{},
|
||||
}
|
||||
|
||||
var http2Protocol api.Protocol = api.Protocol{
|
||||
Name: "http",
|
||||
LongName: "Hypertext Transfer Protocol Version 2 (HTTP/2)",
|
||||
Abbreviation: "HTTP/2",
|
||||
BackgroundColor: "#244c5a",
|
||||
ForegroundColor: "#ffffff",
|
||||
FontSize: 10,
|
||||
ReferenceLink: "https://datatracker.ietf.org/doc/html/rfc7540",
|
||||
OutboundPorts: []string{"80", "8080", "443"},
|
||||
InboundPorts: []string{},
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.Println("Initializing HTTP extension.")
|
||||
requestCounter = 0
|
||||
@@ -23,16 +47,12 @@ func init() {
|
||||
|
||||
type dissecting string
|
||||
|
||||
const ExtensionName = "http"
|
||||
|
||||
func (d dissecting) Register(extension *api.Extension) {
|
||||
extension.Name = ExtensionName
|
||||
extension.OutboundPorts = []string{"80", "8080", "443"}
|
||||
extension.InboundPorts = []string{}
|
||||
extension.Protocol = protocol
|
||||
}
|
||||
|
||||
func (d dissecting) Ping() {
|
||||
log.Printf("pong HTTP\n")
|
||||
log.Printf("pong %s\n", protocol.Name)
|
||||
}
|
||||
|
||||
func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, emitter api.Emitter) {
|
||||
@@ -114,6 +134,7 @@ func (d dissecting) Analyze(item *api.OutputChannelItem, entryId string, resolve
|
||||
func (d dissecting) Summarize(entry *api.MizuEntry) *api.BaseEntryDetails {
|
||||
return &api.BaseEntryDetails{
|
||||
Id: entry.EntryId,
|
||||
Protocol: protocol,
|
||||
Url: entry.Url,
|
||||
RequestSenderIp: entry.RequestSenderIp,
|
||||
Service: entry.Service,
|
||||
|
||||
@@ -86,7 +86,7 @@ func (matcher *requestResponseMatcher) registerResponse(ident string, response *
|
||||
|
||||
func (matcher *requestResponseMatcher) preparePair(requestHTTPMessage *api.GenericMessage, responseHTTPMessage *api.GenericMessage) *api.OutputChannelItem {
|
||||
return &api.OutputChannelItem{
|
||||
Protocol: ExtensionName,
|
||||
Protocol: protocol,
|
||||
Timestamp: time.Now().UnixNano() / int64(time.Millisecond),
|
||||
ConnectionInfo: nil,
|
||||
Pair: &api.RequestResponsePair{
|
||||
|
||||
@@ -7,20 +7,30 @@ import (
|
||||
"github.com/up9inc/mizu/tap/api"
|
||||
)
|
||||
|
||||
var protocol api.Protocol = api.Protocol{
|
||||
Name: "kafka",
|
||||
LongName: "Apache Kafka Protocol",
|
||||
Abbreviation: "KAFKA",
|
||||
BackgroundColor: "#000000",
|
||||
ForegroundColor: "#ffffff",
|
||||
FontSize: 10,
|
||||
ReferenceLink: "https://kafka.apache.org/protocol",
|
||||
OutboundPorts: []string{"9092"},
|
||||
InboundPorts: []string{},
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.Println("Initializing Kafka extension.")
|
||||
log.Println("Initializing Kafka extension...")
|
||||
}
|
||||
|
||||
type dissecting string
|
||||
|
||||
func (d dissecting) Register(extension *api.Extension) {
|
||||
extension.Name = "kafka"
|
||||
extension.OutboundPorts = []string{"9092"}
|
||||
extension.InboundPorts = []string{}
|
||||
extension.Protocol = protocol
|
||||
}
|
||||
|
||||
func (d dissecting) Ping() {
|
||||
log.Printf("pong Kafka\n")
|
||||
log.Printf("pong %s\n", protocol.Name)
|
||||
}
|
||||
|
||||
func (d dissecting) Dissect(b *bufio.Reader, isClient bool, tcpID *api.TcpID, emitter api.Emitter) {
|
||||
|
||||
Reference in New Issue
Block a user