mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-26 16:24:54 +00:00
Fix colors map initialization (#1200)
This commit is contained in:
parent
4b280ecd6d
commit
a3c236ff0a
@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -82,8 +81,7 @@ func GetGeneralStats() *GeneralStats {
|
|||||||
|
|
||||||
func InitProtocolToColor(protocolMap map[string]*api.Protocol) {
|
func InitProtocolToColor(protocolMap map[string]*api.Protocol) {
|
||||||
for item, value := range protocolMap {
|
for item, value := range protocolMap {
|
||||||
splitted := strings.SplitN(item, "/", 3)
|
protocolToColor[api.GetProtocolSummary(item).Abbreviation] = value.BackgroundColor
|
||||||
protocolToColor[splitted[len(splitted)-1]] = value.BackgroundColor
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -25,6 +26,15 @@ func (protocol *ProtocolSummary) ToString() string {
|
|||||||
return fmt.Sprintf("%s?%s?%s", protocol.Name, protocol.Version, protocol.Abbreviation)
|
return fmt.Sprintf("%s?%s?%s", protocol.Name, protocol.Version, protocol.Abbreviation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetProtocolSummary(inputString string) *ProtocolSummary {
|
||||||
|
splitted := strings.SplitN(inputString, "?", 3)
|
||||||
|
return &ProtocolSummary{
|
||||||
|
Name: splitted[0],
|
||||||
|
Version: splitted[1],
|
||||||
|
Abbreviation: splitted[2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type Protocol struct {
|
type Protocol struct {
|
||||||
ProtocolSummary
|
ProtocolSummary
|
||||||
LongName string `json:"longName"`
|
LongName string `json:"longName"`
|
||||||
|
Loading…
Reference in New Issue
Block a user