Compare commits

..
Author SHA1 Message Date
gadotroeeandGitHub a3c236ff0a Fix colors map initialization (#1200) 2022-07-12 20:05:21 +03:00
2 changed files with 11 additions and 3 deletions
+1 -3
View File
@@ -5,7 +5,6 @@ import (
"encoding/hex"
"fmt"
"reflect"
"strings"
"sync"
"time"
@@ -82,8 +81,7 @@ func GetGeneralStats() *GeneralStats {
func InitProtocolToColor(protocolMap map[string]*api.Protocol) {
for item, value := range protocolMap {
splitted := strings.SplitN(item, "/", 3)
protocolToColor[splitted[len(splitted)-1]] = value.BackgroundColor
protocolToColor[api.GetProtocolSummary(item).Abbreviation] = value.BackgroundColor
}
}
+10
View File
@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"net"
"strings"
"sync"
"time"
@@ -25,6 +26,15 @@ func (protocol *ProtocolSummary) ToString() string {
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 {
ProtocolSummary
LongName string `json:"longName"`