2 Commits
main ... dev2

Author SHA1 Message Date
Pin
3aec70289b sleeping 2023-04-19 01:00:49 -04:00
Pin
a308a3aa13 error handle 2023-04-18 23:18:56 -04:00

14
main.go
View File

@@ -9,6 +9,7 @@ import (
"os/exec"
"runtime"
"strings"
"time"
"strconv"
@@ -70,12 +71,21 @@ func sInit(os string) *targetInfo {
return &tInfo
}
func openCapture(tInfo *targetInfo) *pcap.Handle {
for {
handle, err := pcap.OpenLive(tInfo.iFace, tInfo.snaplen, true, pcap.BlockForever)
if err == nil {
return handle
}
time.Sleep(5 * time.Second)
}
}
func main() {
tInfo := sInit(runtime.GOOS)
// Read package and analze them
handle, err := pcap.OpenLive(tInfo.iFace, tInfo.snaplen, true, pcap.BlockForever)
errorPrinter(err)
handle := openCapture(tInfo)
handle.SetBPFFilter(tInfo.filter)
packets := gopacket.NewPacketSource(handle, handle.LinkType()).Packets()