error handle

This commit is contained in:
Pin
2023-04-18 23:18:56 -04:00
parent 963db705d9
commit a308a3aa13

12
main.go
View File

@@ -70,12 +70,20 @@ 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
}
}
}
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()