mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-29 06:17:40 +00:00
* Update config.go, tapConfig.go, and models.go * WIP * Update go.sum * Update tapRunner.go * Update tap.go * WIP * WIP * Update Dockerfile, main.go, and 2 more files... * WIP * Update utils.go, tapClusterResourceManagement.go, and utils.go * Merge branch 'develop' * Update metadata_controller.go, utils.go, and 2 more files... * Update main.go, utils.go, and tapRunner.go * Update tapRunner.go * Update config.go, config.go, and models.go * Update main.go, main.go, and stats_provider_test.go * Update provider.go * bug fixes * Update main.go, metadata_controller.go, and 13 more files... * Update metadata_controller.go, status_controller.go, and 4 more files... * Update main.go, config.go, and 3 more files... * Update tapRunner.go * Update config.go, stats_provider_test.go, and consts.go
79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
package controllers
|
|
|
|
import (
|
|
"encoding/json"
|
|
"mizuserver/pkg/api"
|
|
"mizuserver/pkg/holder"
|
|
"mizuserver/pkg/providers"
|
|
"mizuserver/pkg/up9"
|
|
"mizuserver/pkg/validation"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/up9inc/mizu/shared"
|
|
"github.com/up9inc/mizu/shared/logger"
|
|
)
|
|
|
|
func HealthCheck(c *gin.Context) {
|
|
response := shared.HealthResponse{
|
|
TapStatus: providers.TapStatus,
|
|
TappersCount: providers.TappersCount,
|
|
}
|
|
c.JSON(http.StatusOK, response)
|
|
}
|
|
|
|
|
|
func PostTappedPods(c *gin.Context) {
|
|
tapStatus := &shared.TapStatus{}
|
|
if err := c.Bind(tapStatus); err != nil {
|
|
c.JSON(http.StatusBadRequest, err)
|
|
return
|
|
}
|
|
if err := validation.Validate(tapStatus); err != nil {
|
|
c.JSON(http.StatusBadRequest, err)
|
|
return
|
|
}
|
|
logger.Log.Infof("[Status] POST request: %d tapped pods", len(tapStatus.Pods))
|
|
providers.TapStatus.Pods = tapStatus.Pods
|
|
message := shared.CreateWebSocketStatusMessage(*tapStatus)
|
|
if jsonBytes, err := json.Marshal(message); err != nil {
|
|
logger.Log.Errorf("Could not Marshal message %v\n", err)
|
|
} else {
|
|
api.BroadcastToBrowserClients(jsonBytes)
|
|
}
|
|
}
|
|
|
|
func GetTappersCount(c *gin.Context) {
|
|
c.JSON(http.StatusOK, providers.TappersCount)
|
|
}
|
|
|
|
func GetAuthStatus(c *gin.Context) {
|
|
authStatus, err := providers.GetAuthStatus()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, err)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, authStatus)
|
|
}
|
|
|
|
func GetTappingStatus(c *gin.Context) {
|
|
c.JSON(http.StatusOK, providers.TapStatus)
|
|
}
|
|
|
|
func AnalyzeInformation(c *gin.Context) {
|
|
c.JSON(http.StatusOK, up9.GetAnalyzeInfo())
|
|
}
|
|
|
|
func GetGeneralStats(c *gin.Context) {
|
|
c.JSON(http.StatusOK, providers.GetGeneralStats())
|
|
}
|
|
|
|
func GetRecentTLSLinks(c *gin.Context) {
|
|
c.JSON(http.StatusOK, providers.GetAllRecentTLSAddresses())
|
|
}
|
|
|
|
func GetCurrentResolvingInformation(c *gin.Context) {
|
|
c.JSON(http.StatusOK, holder.GetResolver().GetMap())
|
|
}
|