mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-04-14 22:51:41 +00:00
Compare commits
3 Commits
36.0-dev16
...
36.0-dev19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d98ac0e8f7 | ||
|
|
a3c236ff0a | ||
|
|
4b280ecd6d |
@@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,17 +151,18 @@ func printTappedPodsPreview(ctx context.Context, kubernetesProvider *kubernetes.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func startTapperSyncer(ctx context.Context, cancel context.CancelFunc, provider *kubernetes.Provider, targetNamespaces []string, mizuApiFilteringOptions api.TrafficFilteringOptions, startTime time.Time) error {
|
func startTapperSyncer(ctx context.Context, cancel context.CancelFunc, provider *kubernetes.Provider, targetNamespaces []string, startTime time.Time) error {
|
||||||
tapperSyncer, err := kubernetes.CreateAndStartMizuTapperSyncer(ctx, provider, kubernetes.TapperSyncerConfig{
|
tapperSyncer, err := kubernetes.CreateAndStartMizuTapperSyncer(ctx, provider, kubernetes.TapperSyncerConfig{
|
||||||
TargetNamespaces: targetNamespaces,
|
TargetNamespaces: targetNamespaces,
|
||||||
PodFilterRegex: *config.Config.Tap.PodRegex(),
|
PodFilterRegex: *config.Config.Tap.PodRegex(),
|
||||||
MizuResourcesNamespace: config.Config.MizuResourcesNamespace,
|
MizuResourcesNamespace: config.Config.MizuResourcesNamespace,
|
||||||
AgentImage: config.Config.AgentImage,
|
AgentImage: config.Config.AgentImage,
|
||||||
TapperResources: config.Config.Tap.TapperResources,
|
TapperResources: config.Config.Tap.TapperResources,
|
||||||
ImagePullPolicy: config.Config.ImagePullPolicy(),
|
ImagePullPolicy: config.Config.ImagePullPolicy(),
|
||||||
LogLevel: config.Config.LogLevel(),
|
LogLevel: config.Config.LogLevel(),
|
||||||
IgnoredUserAgents: config.Config.Tap.IgnoredUserAgents,
|
MizuApiFilteringOptions: api.TrafficFilteringOptions{
|
||||||
MizuApiFilteringOptions: mizuApiFilteringOptions,
|
IgnoredUserAgents: config.Config.Tap.IgnoredUserAgents,
|
||||||
|
},
|
||||||
MizuServiceAccountExists: state.mizuServiceAccountExists,
|
MizuServiceAccountExists: state.mizuServiceAccountExists,
|
||||||
ServiceMesh: config.Config.Tap.ServiceMesh,
|
ServiceMesh: config.Config.Tap.ServiceMesh,
|
||||||
Tls: config.Config.Tap.Tls,
|
Tls: config.Config.Tap.Tls,
|
||||||
@@ -229,12 +230,6 @@ func getErrorDisplayTextForK8sTapManagerError(err kubernetes.K8sTapManagerError)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMizuApiFilteringOptions() (*api.TrafficFilteringOptions, error) {
|
|
||||||
return &api.TrafficFilteringOptions{
|
|
||||||
IgnoredUserAgents: config.Config.Tap.IgnoredUserAgents,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func watchApiServerPod(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
func watchApiServerPod(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
||||||
podExactRegex := regexp.MustCompile(fmt.Sprintf("^%s$", kubernetes.ApiServerPodName))
|
podExactRegex := regexp.MustCompile(fmt.Sprintf("^%s$", kubernetes.ApiServerPodName))
|
||||||
podWatchHelper := kubernetes.NewPodWatchHelper(kubernetesProvider, podExactRegex)
|
podWatchHelper := kubernetes.NewPodWatchHelper(kubernetesProvider, podExactRegex)
|
||||||
@@ -352,8 +347,7 @@ func watchApiServerEvents(ctx context.Context, kubernetesProvider *kubernetes.Pr
|
|||||||
func postApiServerStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
func postApiServerStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
||||||
startProxyReportErrorIfAny(kubernetesProvider, ctx, cancel, config.Config.Tap.GuiPort)
|
startProxyReportErrorIfAny(kubernetesProvider, ctx, cancel, config.Config.Tap.GuiPort)
|
||||||
|
|
||||||
options, _ := getMizuApiFilteringOptions()
|
if err := startTapperSyncer(ctx, cancel, kubernetesProvider, state.targetNamespaces, state.startTime); err != nil {
|
||||||
if err := startTapperSyncer(ctx, cancel, kubernetesProvider, state.targetNamespaces, *options, state.startTime); err != nil {
|
|
||||||
logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Error starting mizu tapper syncer: %v", errormessage.FormatError(err)))
|
logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Error starting mizu tapper syncer: %v", errormessage.FormatError(err)))
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ type TapperSyncerConfig struct {
|
|||||||
TapperResources shared.Resources
|
TapperResources shared.Resources
|
||||||
ImagePullPolicy core.PullPolicy
|
ImagePullPolicy core.PullPolicy
|
||||||
LogLevel logging.Level
|
LogLevel logging.Level
|
||||||
IgnoredUserAgents []string
|
|
||||||
MizuApiFilteringOptions api.TrafficFilteringOptions
|
MizuApiFilteringOptions api.TrafficFilteringOptions
|
||||||
MizuServiceAccountExists bool
|
MizuServiceAccountExists bool
|
||||||
ServiceMesh bool
|
ServiceMesh bool
|
||||||
|
|||||||
@@ -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"`
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const AutoRepresentation: React.FC<any> = ({ representation, color, opene
|
|||||||
badge: null
|
badge: null
|
||||||
}]
|
}]
|
||||||
|
|
||||||
if (response) {
|
if (response && response.length > 0) {
|
||||||
arr.push({
|
arr.push({
|
||||||
tab: 'Response',
|
tab: 'Response',
|
||||||
badge: null
|
badge: null
|
||||||
@@ -71,7 +71,7 @@ export const AutoRepresentation: React.FC<any> = ({ representation, color, opene
|
|||||||
{getOpenedTabIndex() === TabsEnum.Request && <React.Fragment>
|
{getOpenedTabIndex() === TabsEnum.Request && <React.Fragment>
|
||||||
<SectionsRepresentation data={request} color={color} requestRepresentation={request} />
|
<SectionsRepresentation data={request} color={color} requestRepresentation={request} />
|
||||||
</React.Fragment>}
|
</React.Fragment>}
|
||||||
{response && getOpenedTabIndex() === TabsEnum.Response && <React.Fragment>
|
{response && response.length > 0 && getOpenedTabIndex() === TabsEnum.Response && <React.Fragment>
|
||||||
<SectionsRepresentation data={response} color={color} />
|
<SectionsRepresentation data={response} color={color} />
|
||||||
</React.Fragment>}
|
</React.Fragment>}
|
||||||
</div>}
|
</div>}
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ const SectionsRepresentation: React.FC<any> = ({ data, color }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sections.length === 0) {
|
|
||||||
sections.push(<div>This request or response has no data.</div>);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <React.Fragment>{sections}</React.Fragment>;
|
return <React.Fragment>{sections}</React.Fragment>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user