diff --git a/agent/main.go b/agent/main.go index 99f4934af..31e421a19 100644 --- a/agent/main.go +++ b/agent/main.go @@ -61,7 +61,6 @@ func main() { go filterItems(outputItemsChannel, filteredOutputItemsChannel, filteringOptions) go api.StartReadingEntries(filteredOutputItemsChannel, nil, extensionsMap) - // go api.StartReadingOutbound(outboundLinkOutputChannel) hostApi(nil) } else if *tapperMode { diff --git a/agent/pkg/api/main.go b/agent/pkg/api/main.go index bf3be722a..a540fd356 100644 --- a/agent/pkg/api/main.go +++ b/agent/pkg/api/main.go @@ -8,7 +8,6 @@ import ( "mizuserver/pkg/database" "mizuserver/pkg/holder" "mizuserver/pkg/providers" - "net/url" "os" "path" "sort" @@ -19,7 +18,6 @@ import ( "github.com/google/martian/har" "github.com/romana/rlog" - "github.com/up9inc/mizu/tap" tapApi "github.com/up9inc/mizu/tap/api" "mizuserver/pkg/models" @@ -60,8 +58,10 @@ func StartReadingEntries(harChannel <-chan *tapApi.OutputChannelItem, workingDir } func startReadingFiles(workingDir string) { - err := os.MkdirAll(workingDir, os.ModePerm) - utils.CheckErr(err) + if err := os.MkdirAll(workingDir, os.ModePerm); err != nil { + rlog.Errorf("Failed to make dir: %s, err: %v", workingDir, err) + return + } for true { dir, _ := os.Open(workingDir) @@ -89,17 +89,6 @@ func startReadingFiles(workingDir string) { decErr := json.NewDecoder(bufio.NewReader(file)).Decode(&inputHar) utils.CheckErr(decErr) - // for _, entry := range inputHar.Log.Entries { - // time.Sleep(time.Millisecond * 250) - // // connectionInfo := &tap.ConnectionInfo{ - // // ClientIP: fileInfo.Name(), - // // ClientPort: "", - // // ServerIP: "", - // // ServerPort: "", - // // IsOutgoing: false, - // // } - // // saveHarToDb(entry, connectionInfo) - // } rmErr := os.Remove(inputFilePath) utils.CheckErr(rmErr) } @@ -135,13 +124,6 @@ func startReadingChannel(outputItems <-chan *tapApi.OutputChannelItem, extension } } -func StartReadingOutbound(outboundLinkChannel <-chan *tap.OutboundLink) { - // tcpStreamFactory will block on write to channel. Empty channel to unblock. - // TODO: Make write to channel optional. - for range outboundLinkChannel { - } -} - func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, resolvedDestination string) { if k8sResolver != nil { unresolvedSource := connectionInfo.ClientIP @@ -164,12 +146,6 @@ func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, re return resolvedSource, resolvedDestination } -func getServiceNameFromUrl(inputUrl string) (string, string) { - parsed, err := url.Parse(inputUrl) - utils.CheckErr(err) - return fmt.Sprintf("%s://%s", parsed.Scheme, parsed.Host), parsed.Path -} - func CheckIsServiceIP(address string) bool { if k8sResolver == nil { return false diff --git a/agent/pkg/utils/utils.go b/agent/pkg/utils/utils.go index e4ac80232..966049370 100644 --- a/agent/pkg/utils/utils.go +++ b/agent/pkg/utils/utils.go @@ -54,15 +54,14 @@ func ReverseSlice(data interface{}) { func CheckErr(e error) { if e != nil { - rlog.Infof("%v", e) - //panic(e) + rlog.Errorf("%v", e) } } func SetHostname(address, newHostname string) string { replacedUrl, err := url.Parse(address) if err != nil { - rlog.Infof("error replacing hostname to %s in address %s, returning original %v", newHostname, address, err) + rlog.Errorf("error replacing hostname to %s in address %s, returning original %v", newHostname, address, err) return address } replacedUrl.Host = newHostname