mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-24 21:23:33 +00:00
Re-enable getStreamProps
function
This commit is contained in:
parent
58deed9eab
commit
4a8629c63e
@ -286,6 +286,15 @@ func startPassiveTapper(outputItems chan *api.OutputChannelItem) {
|
||||
var handle *pcap.Handle
|
||||
var err error
|
||||
|
||||
if localhostIPs, err := getLocalhostIPs(); err != nil {
|
||||
// TODO: think this over
|
||||
rlog.Info("Failed to get self IP addresses")
|
||||
rlog.Errorf("Getting-Self-Address", "Error getting self ip address: %s (%v,%+v)", err, err, err)
|
||||
ownIps = make([]string, 0)
|
||||
} else {
|
||||
ownIps = localhostIPs
|
||||
}
|
||||
|
||||
// Set up pcap packet capture
|
||||
if *fname != "" {
|
||||
log.Printf("Reading from pcap dump %q", *fname)
|
||||
|
@ -3,9 +3,11 @@ package tap
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/romana/rlog"
|
||||
"github.com/up9inc/mizu/tap/api"
|
||||
"log"
|
||||
|
||||
"github.com/google/gopacket" // pulls in all layers decoders
|
||||
"github.com/google/gopacket/tcpassembly"
|
||||
@ -26,11 +28,6 @@ func containsPort(ports []string, port string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: remove?
|
||||
func Emit(item *api.OutputChannelItem) {
|
||||
log.Printf("Emit item: %+v\n", item)
|
||||
}
|
||||
|
||||
func (h *tcpStream) clientRun(tcpID *api.TcpID, emitter api.Emitter) {
|
||||
b := bufio.NewReader(&h.r)
|
||||
for _, extension := range extensions {
|
||||
@ -65,20 +62,18 @@ func (h *tcpStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream
|
||||
DstPort: transport.Dst().String(),
|
||||
Ident: fmt.Sprintf("%s:%s", net, transport),
|
||||
}
|
||||
//dstPort, _ := strconv.Atoi(transport.Dst().String())
|
||||
//streamProps := h.getStreamProps(net.Src().String(), net.Dst().String(), dstPort)
|
||||
//if streamProps.isTapTarget {
|
||||
//
|
||||
//}
|
||||
dstPort, _ := strconv.Atoi(transport.Dst().String())
|
||||
streamProps := h.getStreamProps(net.Src().String(), net.Dst().String(), dstPort)
|
||||
if streamProps.isTapTarget {
|
||||
if containsPort(allOutboundPorts, transport.Dst().String()) {
|
||||
go stream.clientRun(tcpID, h.Emitter)
|
||||
} else if containsPort(allOutboundPorts, transport.Src().String()) {
|
||||
go stream.serverRun(tcpID, h.Emitter)
|
||||
}
|
||||
}
|
||||
//if h.shouldNotifyOnOutboundLink(net.Dst().String(), dstPort) {
|
||||
// h.outbountLinkWriter.WriteOutboundLink(net.Src().String(), net.Dst().String(), dstPort, "", "")
|
||||
//}
|
||||
|
||||
if containsPort(allOutboundPorts, transport.Dst().String()) {
|
||||
go stream.clientRun(tcpID, h.Emitter)
|
||||
} else if containsPort(allOutboundPorts, transport.Src().String()) {
|
||||
go stream.serverRun(tcpID, h.Emitter)
|
||||
}
|
||||
return &stream.r
|
||||
}
|
||||
|
||||
@ -96,12 +91,6 @@ func (factory *tcpStreamFactory) getStreamProps(srcIP string, dstIP string, dstP
|
||||
}
|
||||
return &streamProps{isTapTarget: false}
|
||||
} else {
|
||||
isTappedPort := dstPort == 80 || (gSettings.filterPorts != nil && (inArrayInt(gSettings.filterPorts, dstPort)))
|
||||
if !isTappedPort {
|
||||
rlog.Debugf("getStreamProps %s", fmt.Sprintf("- notHost1 %d", dstPort))
|
||||
return &streamProps{isTapTarget: false, isOutgoing: false}
|
||||
}
|
||||
|
||||
isOutgoing := !inArrayString(ownIps, dstIP)
|
||||
|
||||
if !*anydirection && isOutgoing {
|
||||
|
Loading…
Reference in New Issue
Block a user