Handle Pcap EOF

This commit is contained in:
Josh Deprez 2024-04-07 13:11:06 +10:00
parent a59d7f7584
commit ce7b360dff
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

View file

@ -20,6 +20,7 @@ import (
"context" "context"
"errors" "errors"
"flag" "flag"
"io"
"log" "log"
"math/rand/v2" "math/rand/v2"
"net" "net"
@ -166,9 +167,12 @@ func main() {
if errors.Is(err, pcap.NextErrorTimeoutExpired) { if errors.Is(err, pcap.NextErrorTimeoutExpired) {
continue continue
} }
if errors.Is(err, io.EOF) || errors.Is(err, pcap.NextErrorNoMorePackets) {
return
}
if err != nil { if err != nil {
log.Fatalf("Couldn't read AppleTalk / AARP packet data: %v", err) log.Printf("Couldn't read AppleTalk / AARP packet data: %v", err)
return
} }
ethFrame := new(ethertalk.Packet) ethFrame := new(ethertalk.Packet)