Skip to content

Commit

Permalink
Merge pull request #635 from cloudfoundry/pcapgo-not-pcap
Browse files Browse the repository at this point in the history
Avoid `gopacket/pcap` import to ease builds
  • Loading branch information
jpalermo authored Nov 28, 2023
2 parents fbc14eb + 48b75b7 commit cdee0b9
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 2,684 deletions.
15 changes: 5 additions & 10 deletions pcap/pcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/gopacket/gopacket"
"github.com/gopacket/gopacket/layers"
"github.com/gopacket/gopacket/pcap"
"github.com/gopacket/gopacket/pcapgo"
"golang.org/x/crypto/ssh"

Expand Down Expand Up @@ -286,22 +285,18 @@ func openPcapHandle(tcpdumpCmd string, session *ssh.Session, wg *sync.WaitGroup,
// The pcap handle can be created without blocking after readable exists.
out := make(chan gopacket.Packet)
go func() {
handle, err := pcap.OpenOfflineFile(readable)
ngReader, err := pcapgo.NewReader(readable)
if err != nil {
cancel(openHandleError)
return
}

packetSource := gopacket.NewPacketSource(handle, layers.LayerTypeEthernet)
packetSource := gopacket.NewPacketSource(ngReader, layers.LayerTypeEthernet)

// Run a goroutine that will write packets to the channel
go func() {
defer handle.Close()

for packet := range packetSource.Packets() {
out <- packet
}
}()
for packet := range packetSource.Packets() {
out <- packet
}
}()
return out, nil
}
Expand Down
74 changes: 0 additions & 74 deletions vendor/github.com/gopacket/gopacket/pcap/defs_windows.go

This file was deleted.

114 changes: 0 additions & 114 deletions vendor/github.com/gopacket/gopacket/pcap/doc.go

This file was deleted.

Loading

0 comments on commit cdee0b9

Please sign in to comment.