mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-01 08:50:27 +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 handle *pcap.Handle
|
||||||
var err error
|
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
|
// Set up pcap packet capture
|
||||||
if *fname != "" {
|
if *fname != "" {
|
||||||
log.Printf("Reading from pcap dump %q", *fname)
|
log.Printf("Reading from pcap dump %q", *fname)
|
||||||
|
@ -3,9 +3,11 @@ package tap
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/romana/rlog"
|
"github.com/romana/rlog"
|
||||||
"github.com/up9inc/mizu/tap/api"
|
"github.com/up9inc/mizu/tap/api"
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/google/gopacket" // pulls in all layers decoders
|
"github.com/google/gopacket" // pulls in all layers decoders
|
||||||
"github.com/google/gopacket/tcpassembly"
|
"github.com/google/gopacket/tcpassembly"
|
||||||
@ -26,11 +28,6 @@ func containsPort(ports []string, port string) bool {
|
|||||||
return false
|
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) {
|
func (h *tcpStream) clientRun(tcpID *api.TcpID, emitter api.Emitter) {
|
||||||
b := bufio.NewReader(&h.r)
|
b := bufio.NewReader(&h.r)
|
||||||
for _, extension := range extensions {
|
for _, extension := range extensions {
|
||||||
@ -65,20 +62,18 @@ func (h *tcpStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream
|
|||||||
DstPort: transport.Dst().String(),
|
DstPort: transport.Dst().String(),
|
||||||
Ident: fmt.Sprintf("%s:%s", net, transport),
|
Ident: fmt.Sprintf("%s:%s", net, transport),
|
||||||
}
|
}
|
||||||
//dstPort, _ := strconv.Atoi(transport.Dst().String())
|
dstPort, _ := strconv.Atoi(transport.Dst().String())
|
||||||
//streamProps := h.getStreamProps(net.Src().String(), net.Dst().String(), dstPort)
|
streamProps := h.getStreamProps(net.Src().String(), net.Dst().String(), dstPort)
|
||||||
//if streamProps.isTapTarget {
|
if streamProps.isTapTarget {
|
||||||
//
|
|
||||||
//}
|
|
||||||
//if h.shouldNotifyOnOutboundLink(net.Dst().String(), dstPort) {
|
|
||||||
// h.outbountLinkWriter.WriteOutboundLink(net.Src().String(), net.Dst().String(), dstPort, "", "")
|
|
||||||
//}
|
|
||||||
|
|
||||||
if containsPort(allOutboundPorts, transport.Dst().String()) {
|
if containsPort(allOutboundPorts, transport.Dst().String()) {
|
||||||
go stream.clientRun(tcpID, h.Emitter)
|
go stream.clientRun(tcpID, h.Emitter)
|
||||||
} else if containsPort(allOutboundPorts, transport.Src().String()) {
|
} else if containsPort(allOutboundPorts, transport.Src().String()) {
|
||||||
go stream.serverRun(tcpID, h.Emitter)
|
go stream.serverRun(tcpID, h.Emitter)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//if h.shouldNotifyOnOutboundLink(net.Dst().String(), dstPort) {
|
||||||
|
// h.outbountLinkWriter.WriteOutboundLink(net.Src().String(), net.Dst().String(), dstPort, "", "")
|
||||||
|
//}
|
||||||
return &stream.r
|
return &stream.r
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +91,6 @@ func (factory *tcpStreamFactory) getStreamProps(srcIP string, dstIP string, dstP
|
|||||||
}
|
}
|
||||||
return &streamProps{isTapTarget: false}
|
return &streamProps{isTapTarget: false}
|
||||||
} else {
|
} 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)
|
isOutgoing := !inArrayString(ownIps, dstIP)
|
||||||
|
|
||||||
if !*anydirection && isOutgoing {
|
if !*anydirection && isOutgoing {
|
||||||
|
Loading…
Reference in New Issue
Block a user