mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-02 03:00:41 +00:00
Improving logs and cleaning un-referenced code (#295)
This commit is contained in:
@@ -61,7 +61,6 @@ func main() {
|
|||||||
|
|
||||||
go filterItems(outputItemsChannel, filteredOutputItemsChannel, filteringOptions)
|
go filterItems(outputItemsChannel, filteredOutputItemsChannel, filteringOptions)
|
||||||
go api.StartReadingEntries(filteredOutputItemsChannel, nil, extensionsMap)
|
go api.StartReadingEntries(filteredOutputItemsChannel, nil, extensionsMap)
|
||||||
// go api.StartReadingOutbound(outboundLinkOutputChannel)
|
|
||||||
|
|
||||||
hostApi(nil)
|
hostApi(nil)
|
||||||
} else if *tapperMode {
|
} else if *tapperMode {
|
||||||
|
@@ -8,7 +8,6 @@ import (
|
|||||||
"mizuserver/pkg/database"
|
"mizuserver/pkg/database"
|
||||||
"mizuserver/pkg/holder"
|
"mizuserver/pkg/holder"
|
||||||
"mizuserver/pkg/providers"
|
"mizuserver/pkg/providers"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -19,7 +18,6 @@ import (
|
|||||||
|
|
||||||
"github.com/google/martian/har"
|
"github.com/google/martian/har"
|
||||||
"github.com/romana/rlog"
|
"github.com/romana/rlog"
|
||||||
"github.com/up9inc/mizu/tap"
|
|
||||||
tapApi "github.com/up9inc/mizu/tap/api"
|
tapApi "github.com/up9inc/mizu/tap/api"
|
||||||
|
|
||||||
"mizuserver/pkg/models"
|
"mizuserver/pkg/models"
|
||||||
@@ -60,8 +58,10 @@ func StartReadingEntries(harChannel <-chan *tapApi.OutputChannelItem, workingDir
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startReadingFiles(workingDir string) {
|
func startReadingFiles(workingDir string) {
|
||||||
err := os.MkdirAll(workingDir, os.ModePerm)
|
if err := os.MkdirAll(workingDir, os.ModePerm); err != nil {
|
||||||
utils.CheckErr(err)
|
rlog.Errorf("Failed to make dir: %s, err: %v", workingDir, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for true {
|
for true {
|
||||||
dir, _ := os.Open(workingDir)
|
dir, _ := os.Open(workingDir)
|
||||||
@@ -89,17 +89,6 @@ func startReadingFiles(workingDir string) {
|
|||||||
decErr := json.NewDecoder(bufio.NewReader(file)).Decode(&inputHar)
|
decErr := json.NewDecoder(bufio.NewReader(file)).Decode(&inputHar)
|
||||||
utils.CheckErr(decErr)
|
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)
|
rmErr := os.Remove(inputFilePath)
|
||||||
utils.CheckErr(rmErr)
|
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) {
|
func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, resolvedDestination string) {
|
||||||
if k8sResolver != nil {
|
if k8sResolver != nil {
|
||||||
unresolvedSource := connectionInfo.ClientIP
|
unresolvedSource := connectionInfo.ClientIP
|
||||||
@@ -164,12 +146,6 @@ func resolveIP(connectionInfo *tapApi.ConnectionInfo) (resolvedSource string, re
|
|||||||
return resolvedSource, resolvedDestination
|
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 {
|
func CheckIsServiceIP(address string) bool {
|
||||||
if k8sResolver == nil {
|
if k8sResolver == nil {
|
||||||
return false
|
return false
|
||||||
|
@@ -54,15 +54,14 @@ func ReverseSlice(data interface{}) {
|
|||||||
|
|
||||||
func CheckErr(e error) {
|
func CheckErr(e error) {
|
||||||
if e != nil {
|
if e != nil {
|
||||||
rlog.Infof("%v", e)
|
rlog.Errorf("%v", e)
|
||||||
//panic(e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetHostname(address, newHostname string) string {
|
func SetHostname(address, newHostname string) string {
|
||||||
replacedUrl, err := url.Parse(address)
|
replacedUrl, err := url.Parse(address)
|
||||||
if err != nil {
|
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
|
return address
|
||||||
}
|
}
|
||||||
replacedUrl.Host = newHostname
|
replacedUrl.Host = newHostname
|
||||||
|
Reference in New Issue
Block a user