mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-22 14:32:35 +00:00
Adding the upload interval as parameter to tap function
This commit is contained in:
parent
79816ae337
commit
8fab07494c
@ -141,7 +141,7 @@ func GetHARs(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
func UploadEntries(c *fiber.Ctx) error {
|
||||
rlog.Debugf("Upload entries - started\n")
|
||||
rlog.Infof("Upload entries - started\n")
|
||||
|
||||
uploadRequestBody := &models.UploadEntriesRequestBody{}
|
||||
if err := c.QueryParser(uploadRequestBody); err != nil {
|
||||
@ -153,13 +153,13 @@ func UploadEntries(c *fiber.Ctx) error {
|
||||
if up9.GetAnalyzeInfo().IsAnalyzing {
|
||||
return c.Status(fiber.StatusBadRequest).SendString("Cannot analyze, mizu is already analyzing")
|
||||
}
|
||||
rlog.Debugf("Upload entries - creating token. dest %s\n", uploadRequestBody.Dest)
|
||||
rlog.Infof("Upload entries - creating token. dest %s\n", uploadRequestBody.Dest)
|
||||
token, err := up9.CreateAnonymousToken(uploadRequestBody.Dest)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).SendString("Can't get token")
|
||||
}
|
||||
rlog.Infof("Upload entries - uploading. token: %s model: %s\n", token.Token, token.Model)
|
||||
go up9.UploadEntriesImpl(token.Token, token.Model, uploadRequestBody.Dest, uploadRequestBody.sleepIntervalSec)
|
||||
go up9.UploadEntriesImpl(token.Token, token.Model, uploadRequestBody.Dest, uploadRequestBody.SleepIntervalSec)
|
||||
return c.Status(fiber.StatusOK).SendString("OK")
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ type EntriesFilter struct {
|
||||
|
||||
type UploadEntriesRequestBody struct {
|
||||
Dest string `query:"dest"`
|
||||
sleepIntervalSec int `query:"interval"`
|
||||
SleepIntervalSec int `query:"interval"`
|
||||
}
|
||||
|
||||
type HarFetchRequestBody struct {
|
||||
|
@ -36,7 +36,7 @@ func getGuestToken(url string, target *GuestToken) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
rlog.Debugf("Got token from the server, starting to json decode... status code: %v", resp.StatusCode)
|
||||
rlog.Infof("Got token from the server, starting to json decode... status code: %v", resp.StatusCode)
|
||||
return json.NewDecoder(resp.Body).Decode(target)
|
||||
}
|
||||
|
||||
|
@ -253,14 +253,14 @@ func portForwardApiPod(ctx context.Context, kubernetesProvider *kubernetes.Provi
|
||||
|
||||
time.Sleep(time.Second * 5) // Waiting to be sure the proxy is ready
|
||||
if tappingOptions.Analyze {
|
||||
url_path := fmt.Sprintf("http://%s/api/uploadEntries?dest=%s&interval=%s", mizuProxiedUrl, url.QueryEscape(tappingOptions.AnalyzeDestination), tappingOptions.SleepIntervalSec)
|
||||
url_path := fmt.Sprintf("http://%s/api/uploadEntries?dest=%s&interval=%v", mizuProxiedUrl, url.QueryEscape(tappingOptions.AnalyzeDestination), tappingOptions.SleepIntervalSec)
|
||||
u, err := url.ParseRequestURI(url_path)
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Sprintf("Failed parsing the URL %v\n", err))
|
||||
}
|
||||
rlog.Debugf("Sending get request to %v\n", u.String())
|
||||
if response, err := http.Get(u.String()); err != nil && response.StatusCode != 200 {
|
||||
fmt.Printf("error sending upload entries req %v\n", err)
|
||||
if response, err := http.Get(u.String()); err != nil || response.StatusCode != 200 {
|
||||
fmt.Printf("error sending upload entries req, status code: %v, err: %v\n", response.StatusCode, err)
|
||||
} else {
|
||||
fmt.Printf(mizu.Purple, "Traffic is uploading to UP9 for further analsys")
|
||||
fmt.Println()
|
||||
|
Loading…
Reference in New Issue
Block a user